Nightinggale
Deity
- Joined
- Feb 2, 2009
- Messages
- 5,378
CvCity::doGrowth() loops civics to get random growth units. I'm not particularly happy with this code as I don't like how it handles randomness. If we have 50% change of a blacksmith and 2*25% chance of a farmer, then without calculations we would assume to get equal amount of each. However the odds for getting a blacksmith is 33,8% while getting a farmer is 38%. If we give the farmer 50% too, then the odds for each unit will be 37,5%. The second calculation is doable even without an advanced education, while the former (current setup) is far from trivial. It is far beyond anything I would even attempt in my head and while I would assume farmers to be more likely, I would not attempt to estimate how much based on a calculation in my head.
If we remove the blacksmith, then the odds for getting a farmer will be 50% if we stack, while it is 43,75% with the current code.
Because of this I propose caching the odds for each unit to allow civics to stack effects in a manner people is most likely to expect.
If we remove the blacksmith, then the odds for getting a farmer will be 50% if we stack, while it is 43,75% with the current code.
Because of this I propose caching the odds for each unit to allow civics to stack effects in a manner people is most likely to expect.