C7-Game / Prototype

An early-stage, open-source 4X strategy game
https://c7-game.github.io/
MIT License
34 stars 9 forks source link

City Production Order Needs to be Fixed to Avoid Size-Zero Cities #295

Closed QuintillusCFC closed 1 year ago

QuintillusCFC commented 2 years ago

Splitting this out from the CxC/CxxC work. It's not really related to it but I figured out what was going on while working on that.

Figured out why (but have not yet fixed) the AI building settlers in too-small cities. The problem is that the turn order goes like this:

Assigning the new citizen should happen before deciding what to produce next, because it affects both growth and production rate. In the fixed-seed reproducible example (on the 93_CxC branch), Sippar's second citizen gets assigned to a forest tile, which increases production rate more than food rate. Thus, while the city production AI thinks Sippar has enough time to grow before the Settler is produced, in reality it does not because its production rate is about to increase considerably.

QuintillusCFC commented 1 year ago

To reproduce, check out 9d51565c16289fb7f7a933c86bdd17d15835d595, uncomment line 38 of GameData.cs to set the fixed seeds, fortify all your units, and shift+enter play until turn 147. Note Sippar is about to build a Warrior, and grow, in 1 turn. End the turn. Sippar now is growing in 7 turns and producing the Settler in 6 turns.

image

IRL this is not necessarily a terrible choice of what to build, but the general principle still applies - we should decide what to build with knowledge of our actual tile yields.

QuintillusCFC commented 1 year ago

Confirmed in Civ that the actual order is:

We do it in the opposite order, production first.