Another question from the community, this time from Cornflakes
So Can you trust the odds for great people creation?
Once again we look into CvCity and here into the method doGreatPeople:
This looks more complicated then expected, which is often a sign that something is up. Let's take the example of 15 points into Great Prophet, 35 into Great Artist and 50 into Great Scientist and see what the algorithm does:
Looking at this process my first intention was: "Oh the order in which the Great Persons are checked is important and changes the odds". But looking at some examples proved that this is not the case. In fact this time the presented odds are correct and reliable. So you can trust the game with Great Person creation.
Cornflakes Wrote:@Charriu, would you be interested in looking up the actual mechanics of deciding the dice roll for great people? It is a true proportional split between number of points invested in each type, or does some additional weighting get factored in due to the way the code is written (such as with religions favoring earlier founded cities).
So Can you trust the odds for great people creation?
Once again we look into CvCity and here into the method doGreatPeople:
Code:
int iTotalGreatPeopleUnitProgress = 0;
for (int iI = 0; iI < GC.getNumUnitInfos(); iI++)
{
iTotalGreatPeopleUnitProgress += getGreatPeopleUnitProgress((UnitTypes)iI);
}
int iGreatPeopleUnitRand = GC.getGameINLINE().getSorenRandNum(iTotalGreatPeopleUnitProgress, "Great Person");
UnitTypes eGreatPeopleUnit = NO_UNIT;
for (int iI = 0; iI < GC.getNumUnitInfos(); iI++)
{
if (iGreatPeopleUnitRand < getGreatPeopleUnitProgress((UnitTypes)iI))
{
eGreatPeopleUnit = ((UnitTypes)iI);
break;
}
else
{
iGreatPeopleUnitRand -= getGreatPeopleUnitProgress((UnitTypes)iI);
}
}
This looks more complicated then expected, which is often a sign that something is up. Let's take the example of 15 points into Great Prophet, 35 into Great Artist and 50 into Great Scientist and see what the algorithm does:
- First we add up all the individual GreatPerson points in the first for loop. In our example this would be 15+35+50=100. Now the reason why they are doing that is, that if I stand at 99/100 GPP And add 3 more to any single Great Person I and up with 102 points for the creation algorithm and not 100.
- We generate a random number between 0 and the totalGreatPeoplePoints we just calculated in 1. In our example let's assume we roll the number 49.
- In the next for loop we iterate through all the unit types. This is done because every Great Person is a single unit type. That way we iterate across every single great person type.
- In this loop we check if the rolled random number is smaller then the current Great Person points. For this it is important to know in which order the Great Persons are checked and that would be Prophet->Artist->Scientist->Merchant->Engineer. If the number is smaller, then this is the Great Person to be created. If it's not then we subtract the current Great Person points from the randomly generated number and continue with the loop.
- First we check the Great Prophet. We have 15 points into that type, which is smaller then our random number of 49. Therefore we subtract 49-15=34. 34 is our new number to check against.
- Next we check against the Great Artist. We have 35 points into that, which is bigger then our random number of 34. Great we create a Great Artist and stop the loop.
- Great Scientist points are no longer checked, because we already found our Great Person to be created.
Looking at this process my first intention was: "Oh the order in which the Great Persons are checked is important and changes the odds". But looking at some examples proved that this is not the case. In fact this time the presented odds are correct and reliable. So you can trust the game with Great Person creation.
Mods: RtR CtH
Pitboss: PB39, PB40, PB52, PB59 Useful Collections: Pickmethods, Mapmaking, Curious Civplayer
Buy me a coffee
Pitboss: PB39, PB40, PB52, PB59 Useful Collections: Pickmethods, Mapmaking, Curious Civplayer
Buy me a coffee