Thanks. Looking at the code below this on GitHub it seems that the instant yields are incorporated as 10-turn-averages.
TL;DR: Just look at the bottom of the post.
Now I should note that I'm not a programmer and I don't know C++, I just write simple Java apps sometimes as a hobby. But looking at the code and chasing some of the leads, it seems to me that GetLastTurnInfluenceIPT(ePlayer) just makes some checks and returns m_aiLastTurnCulturalIPT[iIndex], which in turn seems to return the delta Influence
without forming 10-turn-averages. In fact, let's just lay out what the components do as far as my understanding of them goes:
GetInfluenceOn - int that is cast to float; seemingly doesn't include averages, as it comes from m_aiCulturalInfluence, which is directly incremented every turn from the direct Influence calculation method
GetTourismPerTurnIncludingInstant - int that is cast to float; does include averages, as it uses the same direct Influence from one turn as GetInfluenceOn but then adds a 10-turn-average from instant yields*
GetLastTurnInfluenceOn - int that is cast to float; returns m_aiLastTurnCulturalInfluence, which is m_aiCulturalInfluence from the last turn, so direct Influence without averages
GetLastTurnInfluenceIPT - int that is cast to float; returns m_aiLastTurnCulturalIPT, which is m_aiCulturalInfluence minus m_aiLastTurnCulturalInfluence, which means no averages
*: I can't check exactly what getInstantYieldValue does since I can't find the method on GitHub, but I'll just assume that it correctly returns the total instant yields of the specified type for the specified number of last past turns
Edit: found the method; the file was too large so the search didn't work lol...50,000 lines...crazy; my skills, or rather lack thereof, are really pushed here so I'm not sure but it looks like the instant yield history may not be stored exactly as one might expect for Tourism. I don't think the actual Influence for each player (of each player, respectively) is actually stored there but rather a single value for each player (I hope that makes sense). See below the TL;DR for why this may be significant.
So for calculating the float "base" in the algorithm you posted, only the component GetTourismPerTurnIncludingInstant includes 10-turn-averages, which is part of iOurTourismThisTurn.
For the culture part, it seems to me that it works the same way.
Instant Yields seem to be added to the total when they occur (m_aiCulturalInfluence for Tourism) and should thus get caught in the delta (m_aiLastTurnCulturalIPT, for example)
Let's make this algorithm easy to read for us noobs:
TheirCultureThisTurn = (Total culture so far) + ( (Culture that will be added as shown in the top bar in the UI, if they were a player) + (10-turn-average from instant yields) )
TheirCultureLastTurn = (Total culture when the DoTurn method was called the time before the last time) + (Culture that was added from all sources, including instant yields, during the last turn)
OurTourismThisTurn = (Total Influence on that player so far) + ( (Influence on that player that will be added as shown in our tourism screen) + (10-turn-average from instant yields) )
OurTourismLastTurn = (Total Influence on that player when the DoTurn method was called the time before the last time) + (Influence on that player that was added from all sources, including instant yields, during the last turn)
Base = OurTourismThisTurn - OurTourismLastTurn
if Base is <= 0, set it to 1
Slope = (TheirCultureThisTurn - TheirCultureLastTurn) / Base
Slope values.....Trend
< 0.9..................Rising
0.9 until 1.1........Static
> 1.1..................Falling
First, some questions: did I do this right? I'm assuming DoTurn is called when the player presses the Next Turn button.
It seems to me that OurTourismThisTurn's first component is the same as OurTourismLastTurn, is that right? Or is the reason why you don't just take that value for OurTourismLastTurn (i.e. just use GetInfluenceOn(ePlayer) for that) that there may have been instant yields that occurred during this turn (e.g. Great Musician Concert), is that right?
Anyway, if I have laid this out correctly, there are some oddities with this algorithm:
1. Let's consider the following example:
Player A has 10,000 culture and 200 culture per turn, which increments by 2 each turn in perpetuity.
Player B has 5,000 Tourism and 100 Tourism per turn, which increments by 1 each turn in perpetuity, with Player A.
Player B is at 50% Influencial with Player A and there are no instant yields from either.
For every following turn as far as the result is concerned, and using the numbers of the first turn, this algorithm would determine that ( Base = 5000 + 100 - (4901 + 99) = 100 ) and therefore ( Slope = ((10000 + 200) - (9802 + 198)) / 100 = 2 ), which would mean that the trend display shows "Falling".
In reality the trend is not falling, though, is it? It will remain static at 50% Influence.
2. Let's say there are some instant yields involved, such that Player B gets 5 additional Tourism with Player A every 10 turns (0.5 per turn on average)
This means that the algorithm would determine (Base = 5005 + 100 + 0.5 - (4901 + 99) = 105.5 ) and (Slope = ((10000 + 200) - (9802 + 198)) / 105.5 = 1.896) directly after the instant yield, which means the trend display still shows "Falling" when in reality the Influence is actually rising; the next turn the Slope will be 1.99 and thus still shown as "Falling", even though the Influence level would actually be static now, for the moment, until the next instant yield (over time it would increase, of course).
TL;DR
I think you get where I'm going with this: whoever wrote that algorithm seems to have forgotten to normalize the Slope variable.
If it were multiplied by the current Influence percentage, then there'd be a chance that the trend would actually mean what it says.
(Or I'm completely wrong and have butchered this entirely, which is why you should probably read the full post after all
)
If this is all correct, then I would suggest changing the yield averages to 20 or 30 turns in addition to fixing the missing normalization (for the instant yield UI as well); 10 turns is a bit too jumpy in my opinion, especially for Tourism.
Edit: I'm pretty sure there's even more wrong with the algorithm or the methods feeding it...I'm pretty tired though, so can't think atm. One problem is that the normalization issue doesn't explain why Poland does not get a Rising trend in my graph further up this page; it could only explain the incorrect trend on Denmark and me.
Edit2: okay I *think* that maybe the other issue has to do with the instant yields...now I'm really not sure here but from how I understand the code, there is only one Tourism history for each player, instead of an Influence history for each player, of each player. That means the averaged instant yields will not be accurate at all for Influence specific to a player, which could explain the wrong trend for Poland in my data.
@Gazebo should I post this on GitHub?