2 pop and 3 pop whip for the same hammer build-up

Powerfaker

Warlord
Joined
Mar 30, 2016
Messages
297
Hi everybody.

Recently I've noticed one can build up hammers in a city to the exact limits for max overflow.
By this I mean for example for a library on marathon (270h) that could be 90h or180h, where you would expect 89h and 179h maybe.

So I've done this numerous times in my current game. Then something odd happens. For an aquaduct (300h) with org rel + forge bonus max overflow with a 3 pop whip is 30h. but in one city I get as some sort of exception a 2 pop whip, (and zero overflow of course).

So my question is, is there an explanation for this?

One thing I can tell it's not. There is no hidden unrounded value floating around, I started the build with a switch, so no overflow from previous build, production was set to 20h + 50% = 30h
 

sampsa

Ghost
Joined
Jan 1, 2006
Messages
3,446
Location
Finland
By this I mean for example for a library on marathon (270h) that could be 90h or180h, where you would expect 89h and 179h maybe.
This is the odd part. On marathon 90:hammers: short of a build is supposed to be a 1-pop whip, 91:hammers: short is a 2-pop whip.
 

Pangaea

Rock N Roller
Joined
Sep 17, 2010
Messages
6,390
Hammer multipliers affect whips. So on Marathon with Forge + OR (50% bonus), each pop is worth 90 * 1.5 = 135 :hammers: If you had invested 30 hammers, it makes sense with a 2-pop whip with no overflow on an aqueduct.
 

elmurcis

Emperor
Joined
Feb 16, 2011
Messages
1,174
Location
Latvia
Reason why I "don't like" EXP trait that much on Marathon speed - worker becomes 112.5 (if correct, its 112) hammer worth so have to somehow manually change tiles to minimal yield to get into 7 hammers.. Same time non-EXP workers are great for early 2-pop whips (1-29/120-> nice overflow), have used 6->4 and 4->2 in just few turns to finish key Wonder :D
 

Powerfaker

Warlord
Joined
Mar 30, 2016
Messages
297
This is the odd part. On marathon 90:hammers: short of a build is supposed to be a 1-pop whip, 91:hammers: short is a 2-pop whip.

I agree. But when an odd thing frequntly happens odd becomes normal, normal becomes odd :crazyeye:


I've tested this a little more, and it's not entirely like I presented it. The aquaduct doesn't work in any city while a set of other buildings do (at least at a certain level).

Since I don't read any ''hey I recognize this'' in the responses here is a save of my current game. I'll demonstrate

Several cities have or are close to a prepped item on the limit (given mostly 135h per pop due to org rel and forge
Examples:
Antioch - Barracks 15h (150-135) 2 pop
Houston - Theatre 15h (150-135) 2 pop
Buffalo - Forge 135h (360 - 2*112,5) 3 pop
Tiwanaku - Aquaduct 30h (300 - 2*135) 2 pop not 3

Almost there, available for checking with 1-2 turns playing:
Amsterdam - Harbor needs 105h (240-135) will 2 pop
Atlanta - Library needs 135h (270-135) will 2 pop
Boston - Courthouse needs 135h (360-225) will 2 pop (135+90 for org trait=225)
Hastings - Settler needs 75h (300-2*112,5) will 3 pop

Not working:
Tiwanaku - Aquaduct 30h (300-2*135) 2 pop instead of 3

The relevance of all this is rather low I suppose,...(?)
I thought it is noteworthy.

One non-related remark by the way: I also noticed overflow after finishing a forge is reduced as if it contained the 25% forge bonus, fe 90h becomes 72h as 72*1,25=90)... for the people who do not know this...

(oh and ignore the game, it's heavily manipulated by reloading)
 

Attachments

  • current 03.CivBeyondSwordSave
    653.5 KB · Views: 163

Powerfaker

Warlord
Joined
Mar 30, 2016
Messages
297
I've got a (wild?) hypothysis

Prepped h carrying a factor 10 (10-20-30-40-50... etc) you need to stay 1h below to secure max overflow.

=> examples the above mentioned aquaduct at 30h, the well known (I think) 90/180 granary, another I noticed was a grocer.at 180h (450-2*135)

Prepped h carrying a factor 5 (5-15-25-35-45... etc) you can prep to the limit and still have the extra pop for overflow.

=> Plenty examples above.

So far the typically integer limits.

.....However when a rounding is involved:
It gets more crazy when I look at 90*1,25=112,5 limit and examine how to prep worker (120h)
-8 h/f prep leads to a 2pop whip
-3f/4h prep with forge (=8 h/f) leads to 1pop whip
-4f/3h prep with forge (=7,75 h/f) leads to a 2pop whip
(Edit: 8/h/f example has 90h limit because no forge, so nothing crazy in any of these examples)

I don't know if this covers all predictability or if it's 100% true. It's certainly not an explanation, just an observation.

Is this a marathon phenomena? Anyone else who can relate this?
 
Last edited:

Anysense

Emperor
Joined
Jan 30, 2015
Messages
1,419
On normal speed 15/60 granary with is a 2-pop whip (45:hammers:/pop). That is the theory applies to normal speed as well. If a theory corresponds to practice then its a good theory.
In my case its bureau capital, not OR+forge, so it isn't some OR related weirdness as I thought first.
 

Anysense

Emperor
Joined
Jan 30, 2015
Messages
1,419
I think it has something to do with the way the math is done by computer. Its very straightforward when calculations involve only integers, but when the multiplier for production is real there may be a tiny difference like granary being 14.9999/60 instead of round 15.
 

Dhoomstriker

Girlie Builder
Joined
Aug 12, 2006
Messages
13,418
Several cities have or are close to a prepped item on the limit (given mostly 135h per pop due to org rel and forge
Examples:
Antioch - Barracks 15h (150-135) 2 pop
State Religion = Christianity
Antioch's Religions = Judaism only
Antioch has a Forge
Expected multiplier = 1.25
Hypothesis: Whipping 1 population point might give: floor( 1 * 90 * 1.25 ) = 112 H
Barracks Hammers remaining = 150 H - 15 H = 135 H
135 H > 112 H, so it's a 2-pop-whipping action
2-pop-whipping brings us to 240 H / 150 H, as expected: floor( 2 * 90 * 1.25) = 225; 15 H + 225 H = 240 H

So, that example doesn't help, because the City didn't have Christianity in it.


Houston - Theatre 15h (150-135) 2 pop
Houston's Religions = Christianity + Judaism
Houston has a Forge
Expected multiplier = 1.5
Hypothesis: Whipping 1 population point might give: floor( 1 * 90 * 1.5 ) = 135 H
Theatre Hammers remaining = 150 H - 15 H = 135 H
135 H = 135 H, so you'd expect it to be a 1-pop-whipping action, but it's a 2-pop-whipping action. Hence, our hypothesis must be incorrect and the math must be slightly different than guessed.
2-pop-whipping bring us to 285 H / 150 H; floor( 2 * 90 * 1.5 ) = 270; 15 H + 270 H = 285 H. So, at least you don't get free Hammers or anything game-breaking.

If you have 16 H in the Theatre, it becomes a 1-pop-whipping action and you end up with 151 / 150 H in the Theatre.


Thus, the math seems pretty close to what we had hypothesized, but isn't quite there. Probably the best approach at this point would be to code-dive.


Buffalo - Forge 135h (360 - 2*112,5) 3 pop
Yes, I agree, according to our hypothesis, you'd have expected a 2-pop-whipping action for Buffalo's Forge.


Tiwanaku - Aquaduct 30h (300 - 2*135) 2 pop not 3
...
Not working:
Tiwanaku - Aquaduct 30h (300-2*135) 2 pop instead of 3
Well, by "not working," it fits with our hypothesis, in that we'd expect it to be a 2-pop-whipping action.
But, since it is a 2-pop-whipping action and you only get 300 H / 300 H, the game isn't giving any extra Hammers, so there's nothing game-breaking here, again.


I think that the relevant code is likely to be in CvCity.cpp, with the word "hurry" being used instead of "whipping." For example, the following "round up" comments look to be a bit suspicious:
Code:
int CvCity::getHurryCost(bool bExtra, int iProductionLeft, int iHurryModifier, int iModifier) const
{
   int iProduction = (iProductionLeft * iHurryModifier + 99) / 100; // round up

   if (bExtra)
   {
       int iExtraProduction = getExtraProductionDifference(iProduction, iModifier);
       if (iExtraProduction > 0)
       {
           int iAdjustedProd = iProduction * iProduction;
        
           // round up
           iProduction = (iAdjustedProd + (iExtraProduction - 1)) / iExtraProduction;
       }
   }

   return std::max(0, iProduction);
}

The following functions are probably also be related, but I'm not sufficiently experienced with code-diving to offer any real insights:
Code:
int CvCity::getHurryPopulation(HurryTypes eHurry, int iHurryCost) const
{
   if (GC.getHurryInfo(eHurry).getProductionPerPopulation() == 0)
   {
       return 0;
   }

   int iPopulation = (iHurryCost - 1) / GC.getGameINLINE().getProductionPerPopulation(eHurry);

   return std::max(1, (iPopulation + 1));
}

int CvCity::hurryProduction(HurryTypes eHurry) const
{
   int iProduction;

   if (GC.getHurryInfo(eHurry).getProductionPerPopulation() > 0)
   {
       iProduction = (100 * getExtraProductionDifference(hurryPopulation(eHurry) * GC.getGameINLINE().getProductionPerPopulation(eHurry))) / std::max(1, getHurryCostModifier());
       FAssert(iProduction >= productionLeft());
   }
   else
   {
       iProduction = productionLeft();
   }

   return iProduction;
}


.....However when a rounding is involved:
It gets more crazy when I look at 90*1,25=112,5 limit and examine how to prep worker (120h)
-8 h/f prep leads to a 2pop whip
-3f/4h prep with forge (=8 h/f) leads to 1pop whip
-4f/3h prep with forge (=7,75 h/f) leads to a 2pop whip
Is that a typo, where you meant to say "-8 h/f prep leads to a 1pop whip"?

Fractional Hammers are not carried-forward into the following turn, so -4f/3h really only gives you 4 H for the 4 F and 3 H for the 3 H, and thus it's not unexpected to only have 7 H at the start of the next turn--you won't have 7.75 H behind the scenes and the "extra" 0.75 H just get lost.
 

Powerfaker

Warlord
Joined
Mar 30, 2016
Messages
297
@Dhoomstriker
Apology for the late reaction, but thanks for looking up the codes.
I have trouble readings these codes, but maybe if I work out my own maths and compair I can decyfer it and find the answer.

There was no typo, but there was a mistake. The 8h/f example misses the forge so the limit is 90 not 112/113.
I edited a remark => nothing crazy, everything is as one would expect.


I don't expect to find anything ''crazy'' if I looked any further, so it's just the 5-15-25-35 etc integer numbers being different.
Glad to get some responses that supported this.

For me this is enough effort put into this for now.
 
Top Bottom