Factory Town Idle – How Are the Resource Prioritized for Use

How It Works?

The simulation works like this for each simulation ‘Tick’, which is 5 times a second.

Preprocessing:

  • For each town, run any passive generation (e.g. natural resources)
  • Within each town, for each item, calculate number available to consume and how much available storage capacity (e.g. has 400 planks available, with space for 100 more)

Then it runs this loop three times, first for all High priority recipes, then regular, then low:

  • Find all recipes across all towns with the matching priority
  • Calculate how much output each recipe would produce if they were running at 100%
  • If that causes any item to exceed storage capacity, then decrease all recipes producing that item by X% so that storage capacity is exactly met
  • Calculate how much input each recipe would consume, if they were running at the max rate allowed in previous step
  • If this would consume more of an item than is available in the tick, decrease all recipes consuming that item by X% so that they consume exactly all of the inputs
  • Run all the recipes at the calculated %, producing and consuming items
  • Reduce the amount of inputs & output capacity available in this Tick by the amounts produced

[Then repeat for the other priorities]

Postprocessing:

  • Calculate town happiness, town level gains, completed quests
  • Calculate stats like number of items produced within the tick

So if a construction needs 90 wood per tick, and planks needs 10 wood per tick, but there’s not enough wood, the construction will get 90% of the available wood. However, if the Planks are set as a high priority and construction is not, then the Planks will potentially get all of the wood and construction will get none.

There are some weird display issues where a production might occur in the lower priority loop, so it looks like there are items available that aren’t being used, when they’re actually used in a higher priority loop and then immediately replenished. There’s also issues if production is very high and storage is very limited, because the game will limit the amount that can be produced in a tick even if all the items would be consumed in the tick.

Volodymyr Azimoff
About Volodymyr Azimoff 13526 Articles
I love games and I live games. Video games are my passion, my hobby and my job. My experience with games started back in 1994 with the Metal Mutant game on ZX Spectrum computer. And since then, I’ve been playing on anything from consoles, to mobile devices. My first official job in the game industry started back in 2005, and I'm still doing what I love to do.

Be the first to comment

Leave a Reply

Your email address will not be published.


*