AI trade valuation quest

In fact, I vaguely recall TMIT himself ranting about that once...in some game where he was between two civilizations and he was at war with one. Probably, the one at war with Phil randomly contacted the other side AI for trading something stupid for their iron (since they are coerced into that trade according to the code).
Yes I remember him ranting about it, but did he know just how ridiculous the mechanic was?
While it would never have actually been the case in civ, there could, hypothetically have been something to lower strategic resource trade value as some kind of measure to either prevent a civ getting wiped out by a third party, or to help fight against a rival.
He will probably go on an even bigger rant due to its random nature :lol:
I'm confused by the last part where it says you become weaker and gets more. I don't think so by perusing the code. I think you are confusing something. The numerator is the soldier count of the asking player as it fetches the functoin GET_PLAYER, which means "us". Thus, it's our power over theirs. Not the inverse. Otherwise, that would gainsay a lot of functions I saw in the past as much as the game logic.
I probably am confusing myself. It still seems awful low, i'll just have to track the numbers through a game at some point to rectify this!
In conclusion, yes, bonuses values are recalculated each turn, making the whole "how strong is exactly resource impact on attitude over time for fair trades and worst enemy attitudes?" a bit messy. But also, it's unnecessary to make prediction as it is a continuous trade where small bits of attitude value are added progressively and once +4 of fair trades reached (simply checks over diplo screen), just cancel the gifts. The importance of predicting an instantaneous trade is to avoid giving too much over +4 OR more important, avoid as much as possible to max out the -4 for worst enemy as the human wants to extract the most benefits of trades.
On the diplo points I agree, but it also would affect the grant value for either GPT or resource begs, which may very well be annoying.
I'm unsure of its meaning. Isn't there 10 turns of unbreakable period for any continuous deals?
Self pillage, end turn :p
There *may* be some kind of termination hit somewhere, but I very much doubt it.
Here's the function. I don't think it's necessary I translate this as it is clearly exposed.
I came across it previously, and hunted down a thread you explained it in for someone who asked about it in the newbie questions thread earlier.
 
Looking at what Tachy posted on resources, and at and around this specific line in CvPlayerAI.cpp
Code:
iTempValue += kLoopBuilding.getBonusProductionModifier(eBonus) / 10;
On this, being as we cant build it right now it comes out nice and simple, just an extra 10% on top of a standard :)/:health: resource as SP is the only thing it has an impact on. If we could build it now it would be 20%.
After SP is built gold loses its extra value, becoming equal to the other :)/:health: resources.
So heres some worked example from a save stolen (and WBd) from NC 131!

First a picture of the trade screen
Spoiler :
Tradeexample1_zps996870b2.jpg
Here if we count up the named cities we find we have 10 and the French have 11, but the capitals don't show up on the trade screen so we need to add 1 to both so we have 11 and Louis has 12.

Now using the formula gained earlier in the thread
((Lowest out of buyers citycount vs sellers citycount) + 3) * 30
We get (11 + 3) * 30 = 420 for a standard resource.
Calculating GPT from this. 420 / 20 = 21
Spoiler :
Tradeexample2_zpse13025c7.jpg
Which we can see above is correct (I don't see any necessity in showing screens of the AI refusing values just below, you'll just have to trust i tested it :p.

The claim for gold is that the equation will be (11 + 3) * 1.1 * 30
This gives us 462. This will round down to 460 on the trade table so the GPT cost will be 460 / 20 = 23
Spoiler :
Tradeexample3_zpsc40181c2.jpg


Looking at this its pretty obvious that the AI tries to seriously rip off the player when we ask what the AI wants for gold, its request will be two standard :)/:health: resoruces or a resource of higher value where available, wheras it would only want 1 st resource + a small amount of GPT! Just 1-2GPT more in the overwhelming majority of games.

The rest of basebonusval is still proving difficult to find a satisfactory way of dealing with in a useable way (though it may be unreasonable in general) and testing as the values for strategic resources change often through the game.
Maybe i'll crack ivory tomorrow.
 
GPhstage, muster all your ultraballs/masterball. There's a wild pokieman around here at level 72. It's downright rare appearance.
 
GPhstage, muster all your ultraballs/masterball. There's a wild pokieman around here at level 72. It's downright rare appearance.
:confused:

Ok so Ivory, its at least relatively simple compared to the full strategic resources so will be useful for understanding how some of the unit related factors are taken into account.

Case 1
Classical era, before we have the techs to allow Wellies, SoZ isn't built

We already know that the happiness has an initial value of + 100 and the previous testing explained why SoZ will give us + 10.
As there will be multiplications of later values during this its best to say that the 100 value from hapiness is an initial ivalue, while the +10 from SoZ is part of a rolling tempvalue that needs to be kept seperate for now.

After modifying the NC 131 test game some more I played around with trades to find that in this case, the minimum Louis would take is 29 :gold:.
Spoiler :
TradeexampleIvory_zps84bb0af4.jpg

1) For buildings enabled with more than one resource, adds +30
2) For buildings enabled with either one or another resource, adds +20
3) The points modifier when the resource gives a production multipler. It's *ProdMultiplier/10 again. Now, there are buildings affected by resources like the walls or the castles.
4) If the resource provides power to certain buildings, adds +60.
5) If the resource augments the yield modifier of a building, the it's +Yield/2. Additionally, if the building provides yield modifier from power now, it's +YieldModifierFromPower to the points pool. The IronWorks is the sole case of building having a yield modifier from a resource accessibility (coal and iron).
6) Now joins the situational conditions not to make future buildings affecting the value of a resource before its time. If build-able, then the points pool for the resource case of a case of a building is doubled. Otherwise, the value collapses. So buildings don't increase their cost of a resource just because it exists.
7) Impact of a heavy coastal empire on water buildings enabled by a resource. Let imagine a coastal building already having 80 points. The modifier is the number of coastal cities divided by the cityCount/2 is the modifier. Thus if more than 50% of cities are coastal, the modifier is a gain.
8) The exact same effect from era. Revisit the unit section for the formula. It's the exact same.
Spoiler :
Code:
					if (kLoopUnit.getPrereqAndTech() != NO_TECH)
						{
							iDiff = abs(GC.getTechInfo((TechTypes)(kLoopBuilding.getPrereqAndTech())).getEra() - getCurrentEra());

							if (iDiff == 0)
							{
								iTempValue *= 3;
								iTempValue /= 2;
							}
							else
							{
								iTempValue /= iDiff;
							}
						}
As its the same era we multiply our 60 by 3 / 2 giving us 90.
Right now the rest is irrelevant so adding this temp value to the initial ivalue gives 190.

Thrown back into the bonustradeval function we can simplify by dividing this by 100 to get
1.9 * (lowest city count + 3) * 30 = 570
Turn to gold per turn by dividing by 20 = 28.5 which due to AIs wanting equal or more value in a trade, rounds up to 29GPT

Case 2
Same era, don't have techs for Wellies, SoZ built
((1 + (50 * 3 / 2) / 100) * (lowest city count +3) * 30 = 525 due to trade values rounding down to nearest 10 so 520.
Then to GPT by dividng by 20 gives 26

Case 3
Same era, SoZ not built (but have Aesthetics), we do have techs for Wellies. Looking at Tachys list
Spoiler :
1) Adds 50 points to units unlocked by more than one resource
2) Adds 40 points to units unlocked by either one or other resources
3) Adds the first modifier to the pool of points if the bonus concerned give unit production multiplier
4) Another modifier, but concerning only water units. If the count of coastal cities is less than the empire city count, then the modifier diminishes the base points pool (either the +50 or +40 from point (1) )
5) Units that can be trained gets a modifier of 2 while units that can't be trained are now worth as cheap as 2 points.
6) Era effects on units from older eras.
Starts same as case 1 to get ivalue = 100, and tempvalue of 60. but now we need to double it on top of the * 3 / 2 factor we have already used.
60 * 2 * 3 / 2 = 180
(180 + 100) / 100 = 2.8
2.8 * 10 * 30 = 840
As GPT 840 / 20 = 42.
Spoiler :
tradeivoryexample3_zps2400676c.jpg

So far so good. Will add the cases of medieval cost, and obsoletion at Cuirassiers later.

But I have had an issue, where the cost was only 39GPT when we could build Wellies, and I didn't have Aesthetics while SoZ hadn't been built. This is a problem as if we remove the +10 from SoZ (by building it) the predicted value drops to 38 as shown below, and if we remove that 10 we mess up the pre-SP value of the gold resource too. EDIT - There are further problems I have seen while messing around in WB.
Spoiler :
tradeivoryexample4_zps380185dd.jpg
:confused:

I think with the shear number of resource dependant units, and building/wonder/project speeding impacts of the proper strategic resources it'll be too comlicated to follow. As such if you want to calculate it'll be best to follow Tachy's steps as they have been given quite a good trial, though for now I have no clue how the Cathedrals will react due to the religious requirement.

As a small thing to take away from this, it means that its cheaper to trade for Ivory before you get HBR and Construction.
A similar thing should happen with other strat resources (e.g. Horse cost reducing when getting Knights due to both Chariots and HA obsoleting!), but it will be very hard to track and test without a spreadsheet.

I have started a spreadsheet to cover all the resources, and am getting some success under some conditions. I'm going to just carry on with that rather than try to get my head around the rest of it as it will be much faster to test under varying conditions and will actually be useable in the end, despite the mass of equations it'll probably be quicker to debug too. And once thats conquered, then corps.
 
So far the spreadsheet for calculating basebonusval is actually going quite well. Its managed to produce the values in the above posts (even the wierd ones) and covers standard :)/:health: resources, Gold and Ivory and should even take into account the era and obsoletion.

I have hit an obstacle I need to get around before going forward, that is the shear number of imputs from each resource (Ivory needed a 3 line formula....). For marble theres 14 things to evaluate (15 if Creative Constructions HQ is counted as i suspect), to Ivories 3, just repeating the same functions over and over again will make it ridiculously time consuming and easy to make mistakes.

As a result i'm now trying to find a way to repeat a function group for certain cells to a range of other cells (they are right next to each other) without adding up the intenal. Maybe someone here will have an idea

e.g. If I had
(Max($C12,S5)-Min($C12,S5)+IF(R5=blah,1,0)*IF(Q= blah,2,1))
Is there a function that would allow me to repeat the evaluation for say, the next X cells downward without having to repeat the whole function in the original formula X times while changing the S, R and Q values.

EDIT - Horse values are damn close right now, seems like there may be a rounding error somewhere, either that or the excel auto fix screwed something up.....
 
Back
Top Bottom