Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Citizen Assignment Cycling #12890

Merged
merged 1 commit into from
Feb 1, 2025
Merged

Conversation

itanasi
Copy link
Contributor

@itanasi itanasi commented Feb 1, 2025

Fix rare bug where Citizen Assignment would cycle due to Civ Happiness going above and below the threshold.

Reported originally by Eggy here
https://discord.com/channels/586194543280390151/588357826758574106/1329106526761128058

Sample save file
Babylon - 0 turns.txt

In master, if you press Food Focus, the assignments will cycle. This is because the Civ Happiness stat isn't being updated. So when it tries to assign Pop, it may think the Civ is Happy and not assign to Kailesh. But this will result in Civ at -1 Happy (Unhappy!). Assign again, and the algo thinks we're unhappy, increases weight for Happiness, and assigns to Kailesh. Now the civ is +1 Happy!! Repeat.
image

Simple fix is to calculate the civ-wide Happiness stat at the start while all Citizens aren't assigned. An advanced fix would involve recalculating Happiness after every assignment, but that's probably not necessary.

@yairm210 yairm210 merged commit 3748eca into yairm210:master Feb 1, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants