DanF5771
Emperor
- Joined
- Feb 21, 2008
- Messages
- 1,194
Hmmmh nobody else cares to post -- I wonder why? Anyway:Awesome thread!
I also have some questions:
What about war declarations when you don't do what they ask? I guess that iDemandRebukedSneakProb and iDemandRebukedWarProb have sth to do with that. There is also iDeclareWarTradeRand, 40 for everybody. How does it work exactly?
Thanks in advance!
iDemandRebukedSneakProb is a leader's probability to start preparing for a Limited War against you after not giving in to one of his demands. Washington surprisingly shows a value of 100 here (as the only leader), which means you better pay tribute to him. Cathy and Ragnar have 80 -- that's not that much of a surprise. But Washington's and Ragnar's ContactRands for DemandTribute are only 1000, whereas Cathy's is 50 (for all the xml values check out the spreadsheet attached to this post)!
iDemandRebukedWarProb suggests that the AI will switch to a Limited War directly after rebuking a demand, but there is currently no such thing implemented in the code! Setting the values to 100 and repeatedly rejecting their empty threats had no effect at all, except the usual "-1: You refused to give us tribute!". So currently these leader values are completely irrelevant.
iDeclareWarTradeRand - this is where it gets interesting. This xml value is 40 for all leaders except for one, Pacal's is 60; it is used to determine the probability that an AI bribes another player to join a war it is currently fighting with a 3rd player. The formula for the chance to consider a bribe strongly depends on the duration of the most recent war (CHOSEN dogpile wars get a penalty -> fewer bribes):[pre]WarCounter: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | ...
Chance: 50%| 33%| 25%|5.8%|4.7%| 4%|3.4%| 3%|2.7%|2.5%|2.5%|2.5%| ...[/pre]These numbers are for the xml value of 40; since higher values result in lower chances (it's a "...Rand" in contrast to the "...Prob"s), Pacal's chances are 50%|25%|20%|4%... There is a sharp drop after the 3rd turn.
In CvPlayerAI::AI_doDiplo() the AI loops over all other players (the human player comes last); if it doesn't decide to contact the current potential trading partner for any other reasons it will try to bribe him into one of its wars (this does not need to be the most recent war!) with the above mentioned probability. That's how I understand the code, I'm quite shocked about the 50/50 chance on the first turn after the DoW, but more requirements must be met. The human player cannot be bribed (normally, see below ).
If the RNG agrees to a potential bribery, the code loops over all valid dogpile victims and determines the "best".
Example:
Stalin DoWed Cyrus 20 turns ago and DeGaulle - the master dogpiler - decided (unbribed) to jump in at Cyrus' side last turn, so Stalin is currently at war with Cyrus and DeGaulle. He also knows Suleiman and hasn't contacted him for any other reasons --> he has a 50% chance to ask Suleiman to dogpile on either Cyrus or DeGaulle. Suleiman checks whether he can be bribed to war them (he must like Stalin enough [>Annoyed] and dislike the others enough [<Friendly, those are Suleiman's thresholds], not at war yet, no peace treaties, enough power). If both players pass the test, the "best" victim is chosen by [pre]iValue = Random(1...1000)*(101+AttitudeWeight)/100.[/pre]AttitudeWeight is a value between -100 and +100 depending on the victim's attitude towards the instigator (Furious: -100; Annoyed: -40; Cautious: -5; Pleased: +50; Friendly: +100). This is a bit strange and at first I thought it might be a bug because the player with the highest iValue "wins". So if DeGaulle is Pleased with Stalin and Cyrus is Furious towards him, Suleiman is much more likely to be bribed against DeGaulle (iValue=1...1510) than against Cyrus (iValue=0...10). But maybe it is intended to compensate for the additional drop in attitude "-2: You brought in a war ally against us!" after the bribe.
What about the price?
Stalin determines iOurValue = AI_declareWarTradeVal(victim, Suleiman) which depends on:
- number and size of the victim's cities: 10*NumCities + 2*TotalPopulation(incl.Vassals)
- Suleiman's attitude towards the victim: * 1| 1.25| 1.5| 2.5| 5 for Furious|Annoyed|Cautious|Pleased|Friendly
- Power Ratio (incl.Vassals): * ( 0.5 + Power_Victim/(Power_Suleiman+Power_Victim)) --> *(0.5...1.5)
- Victim not a LandTarget for Suleiman? --> *2
- Stalin's WarSuccess against victim: *(1...1.5) // 1.5 = no success
- number and size of Suleiman's cities: + 20*NumCities + 15*TotalPopulation(incl.Vassals)
- Suleiman's attitude towards Stalin and number of wars Stalin is fighting: * (0.75...0.9) | (0.5...0.8) for Pleased|Friendly
- number of victim's nukes: + 250*NumNukes //Don't want to get nuked
- number of Suleiman's nukes: + 150*NumNukes //Don't want to use nukes on another's behalf
- scaling for elapsed game turns: *(0.6...2.0) // early wars are cheaper
What can Stalin offer?
Stalin loops over all techs he knows and which he can trade to Suleiman and determines the "best" tech with the highest value according to [pre]iValue = Random(1...100)*(Number of beakers Suleiman needs to research this tech)[/pre]He then determines iTheirValue = Suleiman.AI_techTradeVal(eBestGiveTech, Stalin) which depends on:
- Number of beakers Suleiman needs to research this tech
- percentage of known other players who have the tech
- AITradeModifier for the tech (+10% for most military techs)
Then there is most certainly a bug in the code:
Stalin compares the two values and if (iTheirValue > iOurValue) he puts another tech on top of the deal!!! I'm sure it should be the other way around, Suleiman should get a second tech only if one tech is not enough to cover his costs. There are further attempts to level the difference between iTheirValue and iOurValue by trading gold (iGiveGold, iReceiveGold) but the amounts are capped at the leader's AI_maxGoldTrade. {There is a minor bug in this calculation too. If Stalin is in financial trouble (his iGoldValuePercent=3) he asks for 50% less cash than if he is not (his iGoldValuePercent=2) due to iGold = ((iTheirValue - iOurValue) * 100) / iGoldValuePercent.}
Finally if (iTheirValue > (iOurValue * 3 / 4)) the deal is good and Suleiman will DoW the victim for 1 or 2 techs +- some gold.
This condition also indicates that giving a second tech if (iTheirValue > iOurValue) is unnecessary. Furthermore it shows that the bug prevents successful bribe deals when 1 tech is not enough and the instigator does not have the necessary cash to reach the 75% threshold. I personally think this should be fixed -- it might entail some more dogpile wars due to successful bribes.
Here are some screenshots I made after lifting some restrictions in the SDK.
Stalin in very generous mood (2-tech-BUG!), I have only 20 to compensate:
This is too good for me - I ask to renegotiate and suddenly all he offers is:
Stalin is offering the following trades when I contact him depending on whether he is currently in financial trouble:
If he is in financial trouble he only asks for 70 instead of the 105 he wants if he is not. It appears this behaviour affects all sort of trades and maybe it IS intended, to have the AI sell stuff for bargain prices at times of financial trouble to get SOME cash.