[v150] CS Influence & decimal places

Sanguinus

Chieftain
Joined
Apr 23, 2012
Messages
93
Location
Germany
Hey,

I just earned some influence with a City State and my influence will change by -0,7 per round, but is shown instead as -0,69999998807907.
I guess this number should be better rounded up. :king:
 
That's strange... the only place I see this in the code appears to round it. Which tooltip is this on, do you have any Patronage policies, and what gamespeed are you playing?
local iInfluenceChangeThisTurn = Game.Round(pPlayer:GetFriendshipChangePerTurn(iForPlayer), 1);
 
@Thalassicus
in deatil: small continents, large map, marathon speed

I haven't got any Patronage policies nor has Russia (my CS Rival).
My influence in Lhasa will change by -0,7 per round, but is still shown instead as -0,69999998807907 with Rival Catherine/Russia.
My influence in Brussels will change by -1 per round (which is shown as -1) and there is no rival nation.
In Venice, where my rival is China, the number is again shown as -0,69999998807907.
 
Thanks; I'm investigating it further now.

Update: Which tooltip are you seeing this on? I'm trying to reproduce the situation you describe. I followed these steps:

  1. Started a marathon game.
  2. Revealed the map.
  3. Gave myself a citystate ally, and the Philanthropy policy (-25% :c5influence: rate).
attachment.php


It correctly rounded -0.75 to -0.7; I'm puzzled that it could show up differently.

Edit: I just read you don't have Philanthropy. What mods do you have installed? I'm trying to think of what else could affect influence rates...
 

Attachments

  • Rounding.JPG
    Rounding.JPG
    46.5 KB · Views: 273
I've seen the OP's problem before with only VEM and InfoAddict. I can't recall any specifics as it's been maybe a month.

It seems possible that it involves opposing AIs filling out patronage for the 10%.
 
The odd thing is... it did round the number in this test. 25% off is 0.75 and it shows 0.7. Full patronage for 10% higher would be 1.1111, rounded to 1.1.
 
@Thalassicus
I'm hovering with my mouse over the CSs name and I haven't got any other mods installed for stability reasons.
I've attached a screenshot.
 

Attachments

  • Civ5Screen0000.jpg
    Civ5Screen0000.jpg
    44.2 KB · Views: 261
The question is, what can make a citystate influence rate -0.7 instead of -1? I have not been able to reproduce this situation in my tests. :think:

Alexander's trait is -0.5, Philanthropy is -0.75...

If their personality is Neutral.

\skodkim
 
Are you sure about that? I started a game and gave my self a neutral CS ally... it's got -1 rate per turn, same as the others. The only influence rate modifiers I see are:
PHP:
<Row Name="MINOR_FRIENDSHIP_DROP_PER_TURN">
	<Value>-100</Value>
</Row>
<Row Name="MINOR_FRIENDSHIP_DROP_PER_TURN_HOSTILE">
	<Value>-150</Value>
</Row>
<Row Name="MINOR_FRIENDSHIP_DROP_PER_TURN_AGGRESSOR">
	<Value>-150</Value>
</Row>
<Row Name="MINOR_FRIENDSHIP_NEGATIVE_INCREASE_PER_TURN">
	<Value>100</Value>
</Row>
 
The question is, what can make a citystate influence rate -0.7 instead of -1? Alexander's trait is -0.5, Philanthropy is -0.75... :think:

Alexander with two opponents having full patronage.

EDIT: If so, that would explain why I haven't seen it in a month: I've only been playing Gandhi lately so I can compare between versions.
 
Sanguinus said the opponent does not have any patronage policies. Even in that unusual situation, there's still how Game.Round() works correctly in my tests... we're overlooking something.
 
attachment.php


Just started this game a bit ago, on quick speed. No abilities or policies that affect city states should be in play yet. Bucharest is hostile. (the anger was from an opportunity just now)
 

Attachments

  • civ-v-citystate-decimal-bug.png
    civ-v-citystate-decimal-bug.png
    196.8 KB · Views: 256
This appears to be a problem with precision loss, a somewhat obscure computer hardware thing. A difference in CPU is why...

I see:
attachment.php


Sanguinus sees:
attachment.php


The code is exactly the same, and technically the numbers are exactly the same! Our CPUs each think they're showing the number 0.7 because of precision loss. I'm not sure how to best fix this. I've made a change for v151.15 which might work.
 

Attachments

  • FloatingPoint.JPG
    FloatingPoint.JPG
    54.2 KB · Views: 235
It's a feature of floating point numbers, yes. I figured you'd be rounding up with a function that takes the number of decimal places, e.g. round(value, decimals). I guess Civ V doesn't provide one?
 
Ah, this is the same issue as 1+2=3.000000000001 that you get on some calculators, isn't it?

To be pedantic here, 1.0 + 2.0 can be exactly represented in IEEE 754 floating point representation (used by pretty much every processsor) and the sum will be exactly 3.0. If one of the two initial isn't exact then all bets are off of course.

Now 0.1 + 0.2 is a completely different beast entirely and could absolutely result in something like 0.300000000001. This is because those numbers cannot be exactly represented in floating point.
 
Back
Top Bottom