Digging into the code: Immigration

Discussion in 'Clockwork Empires General' started by Naffarin, Oct 4, 2016.

  1. Naffarin

    Naffarin Bureaucrat-Inspector Exemplar of The Empire

    Inspired by Alavaria in the threads about mine stratums i would like to explain how immigration works and how players can optimize their strategy of growing their colonies.

    Immigration is governed by two scripts, one that checks if an immigration may occur and one that does the actual immigration calculation.

    Immigration may occur when
    • the immigration event counter modulo (2 + the current game day divided by 10) is zero
    • total population < 150
    • the sum of available labourer slots + available overseer slots > 0

    The most relevant part for a player is the formula in the first point. To quote from the code it means immigration can occur every two days + an additional day every 10 in game days up to a limit of 12 days between immigrations but due to interferences of colonial versus empire rules (also known as "computer do what i want and not what i say") it behaves slightly different
    The third point is interesting because it is prone for error e.g. if you lowered your available labourer slots below the current labourer count it may prevent you from getting overseers IMHO and vice versa

    The actual immigration checks the same conditions again and if successful calculates the immigration wave of labourers by choosing a random value between
    • labourer cap - current labourers divided by 2 without reminder with the result being at least 1
    • 5 + (in game days divided by 10 without reminder ) * 2

    The immigration wave on day 4 would therefore give at least 1 labourer if there is housing capacity available and a maximum of 5 labourers regardless if there is more housing capacity.
    On day 119 you could get the maximum amount of 25 labourers if you have 50 slots of housing capacity available for sure or up to 25 labourers otherwise (because then the random value decides the amount of immigrating labourers)

    Overseers use almost the same calculation with the difference that the maximum amount to immigrate is limited at 2 + (in game days divided by 10 without reminder ) * 2

    Immigration waves (should) occur on the following in game days
    1,2,4,6,8,11,14,17,22,26,32,37,44,51,58,66,74,82,90,119,128,137,146,155...(every 9 days actually)

    So if you want to optimize immigration make sure that you have available slots > double of 2 * ingame days / 10 + 2 for overseers or + 5 for labourers
     
    Last edited: Oct 29, 2016
  2. Naffarin

    Naffarin Bureaucrat-Inspector Exemplar of The Empire

    Updated for 1.0B
    @dbaumgart The formula is still misbehaving in my opinion...gamestart.lua should set immigrationTimes to 2 not zero
     
    Last edited: Oct 26, 2016
  3. dbaumgart

    dbaumgart Art Director Staff Member

    Thanks, logged this as OC-5845 for review.