They need to hotfix AI agression now

It's not just the approach to war but the approach to the other victories as well - or have we concluded the AI is not being passive and is being aggressive in those and war is the only issue?

As far as I am aware they choose a specific victory to pursue from the start and stubbornly stick to it even if they cant reach their goal. However they seem to limp technologically after the Renaissance but not even the warmongers (versus other AIs) neglect their culture and tourism, not enough to win but enough to delay your victory. However it seems 'not quite there'. IDK if this tech limping is due to the new science per city penalty but I assume that in higher difficulties the bonuses out weight that no?

EDIT: Another thing that occurred to me is that they always, try pass the arts founding and world fair resolutions as if its some kind of feature promo :lol:
 
In the light of the newly released DLL source and the piece of code above, I wonder if we should start a new thread? The discussion here will become mixed now, with some people answering to questions/speculations pre-DLL code that are probably not relevant anymore... yet if we start a new thread, how to title it so that the mods do not end up merging again? I fear that important piece of information will be buried under dozens of now-obsolete questions/answers...

Thank you very much Aristos for clarifying that...and also thanks to eric for the additional input. Its good to see we eventually solved it through investigating the code :)

As for your thread suggestion, I agree with it and recommend you mingle with some of the other DLL modders on the C&C section who might be interested in assisting with ideas. As for the title of the thread........Civ V Better AI :think:
 
In the light of the newly released DLL source and the piece of code above, I wonder if we should start a new thread? The discussion here will become mixed now, with some people answering to questions/speculations pre-DLL code that are probably not relevant anymore... yet if we start a new thread, how to title it so that the mods do not end up merging again? I fear that important piece of information will be buried under dozens of now-obsolete questions/answers...

I think the idea of a new thread makes a lot of sense. The question is... do you want to limit the new thread to just this code or all code related to making the decision to go to war?

If you want to limit the thread to the economic decisions related to war, then the thread's title should reflect that (for example: How Trade Effects War in BNW). If you want the thread to have a broader focus on the decision to go to war, then the thread should reflect that (for example: The Decision to Make War from the AIs Perspective).
 
Ideally, if the AI wants to go to war with someone, they'll stop sending trade units in that person's direction.

Ideally.
 
viApproachWeights[] is a vector of weights defining how each AI will "approach" any other player... whatever is inside the brackets is the index of the vector, and there is an index for each of the possible approaches (WAR, HOSTILE, FRIENDLY, DECEPTIVE, etc). The diplomacy code is truly complex, and takes into account many different factors (and even more now with all the new systems). In the case of the piece of code being analyzed, MAJOR_CIV_APPROACH_WAR is the index that points to the "cell" of the vector that holds the weight of the "WAR" decision (approach); each of these weights is modified by many actions/situations/history/treaties/etcetcetc, and the modification is stored in the corresponding cell.

So, in this case, whenever the GPT of the AI is positive, and the GPT without the trade routes to that target is negative, then the weight for the approach WAR is reduced by that amount (summed but is a negative value according to the IF condition). In simple numbers, say the GPT of the AI is 100, and the total gold of the trade routes to/from the target is 120, then the weight for the WAR decision will be reduced by 20.

Later on, the vector gets sorted by highest weight, so that the highest weight at the end of the calculations is chosen. If the highest weight corresponds to the index MAJOR_CIV_APPROACH_WAR, then WAR is the decision. More or less, that is how it works.


EDIT: all that has been extracted and affects this calculations can be seen/edited inside the file GlobalDiplomacyAIDefines.xml. To analyze the specific war decision, every variable that starts with APPROACH_WAR is related in some way to the algorithms that modify the weight of index MAJOR_CIV_WAR_APPROACH. The file is located in


...\Steam\steamapps\common\Sid Meier's Civilization V\Assets\DLC\Expansion2\Gameplay\XML\AI



To break down the crucial part of the code, here's how I read it:

Code:
// sanity check - if we will go negative from war with this player, don't go to war
This threw me at first, as it sounds like it's staying, if revenue goes negative, don't war. But, I'm pretty sure it's saying something else. See *** below

Code:
int iGPT = GetPlayer()->calculateGoldRate();
int iDeltaGPT = iGPT - iCurrentTradeValue;
iGPT = player's overall gold per turn
iDeltaGPT = the change in gold per turn if the AI goes to war.

Code:
if (iGPT >= 0 && (iDeltaGPT < 0))
{
viApproachWeights[MAJOR_CIV_APPROACH_WAR] += iDeltaGPT;
}
This is the crux of it all. If GPT is not negative AND if iDeltaGPT IS negative (i.e., going to war will reduce gold), then add iDeltGPT to viApproachWeights[MAJOR_CIV_APPROACH_WAR] (which I take to be a constant for a given civ's likelihood to war with a major civ). If iDeltaGPT is negative, then adding it to viApproachWeights[MAJOR_CIV_APPROACH_WAR] will cause the latter to be reduced.

My guess is the sanity check means *** If adding iDeltaGPT (reduction in GPT due to DoW) to viApproachWeights[MAJOR_CIV_APPROACH_WAR] (Civ's likelihood to war) causes the latter to go negative, then don't go to war.

The viApproachWeights[MAJOR_CIV_APPROACH_WAR] is very likely different from civ to civ, and, iirc how flavors are handled in Civ V, even different for the same civ from one roll to the next...so that comes to bear on how much of a drop in GPT it takes to deter a DoW in any given situation.
 
OK, here is something for all you warmongers that want to burn the world in 3000 BC... :)

I may have found a way for you to try to get some more wars without touching the dll code. If my understanding is correct, and I am not missing something else, this may work for you but will need some testing. Look at the following piece of code:

Code:
////////////////////////////////////
	// MODIFY WAR BASED ON HUMAN DIFFICULTY LEVEL
	////////////////////////////////////

	if(GET_PLAYER(ePlayer).isHuman())
	{
		HandicapTypes eHandicap = GET_PLAYER(ePlayer).getHandicapType();
		int iWarMod = 100;

		CvHandicapInfo* pHandicap = GC.getHandicapInfo(eHandicap);
		if(pHandicap)
			iWarMod = pHandicap->getAIDeclareWarProb();

		viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= iWarMod;
		viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 100;
		viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] *= iWarMod;
		viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] /= 100;
	}

This block is the last before the approach weights vector gets sorted; the code in the file runs for every turn, and apparently in strict order. In other words, after all modifications to the weights have been done, the Difficulty level of the human player is fetched, and one specific value is used to adjust the final weight for MAJOR_CIV_WAR_APPROACH and MAJOR_CIV_DECEPTIVE. That value is read from the Civ5HandicapInfos.xml file inside

...\Steam\steamapps\common\Sid Meier's Civilization V\Assets\DLC\Expansion2\Gameplay\XML\GameInfo

The value read is the variable <AIDeclareWarProb> </AIDeclareWarProb> for the corresponding difficulty level; if you read that file, you will notice that the value increases from zero (Settler) to 100 (Prince and above). The value is then applied as a product to the weight for WAR, and divided by 100 (percentage). In other words, in Prince and above the weight that resulted from all the modifications stays the same, and below Prince it gets reduced to a certain percentage (and is zero for Settler, thus Settler has no AI war declarations :) ). That is the iWarMod argument in the code above.

Now, if this is correct and it works as I think it does, then you just need to adjust the values of <AIDeclareWarProb> </AIDeclareWarProb> for King and above in your HandicapInfos file to something bigger than 100. I cannot guarantee any result from that, but if you miss war so much it is worth trying. I would recommend the following:

1) COPY your original file first as backup.
2) Increment the value in 10 points per dif level and see what happens
3) If nothing happens, add some more (15 per level?)
4) Report back.

I will not test it as I am still fine with how it is working for me, and if I decide to change something I would work on the dll. But this approach, if it works, is really fast and simple enough for anyone to modify their own game without waiting for magic.

Test it, and let us know if it works and how. I would expect imbalances as a result (for example, you may have more early wars, but the mid-end game might become a troll festival), but it should make for a fun experiment (with very little risk).
 
On another note, and related to the specific trade code, the first thing that comes to my mind is that using the absolute gold value of the projected deficit in the GPT might be disproportionate. The key word is proportion; maybe the reduction in the weight for MAJOR_CIV_WAR_APPROACH should be a proportion of something instead of the absolute value; not sure what something, but I am just brainstorming.

For example, if I had cash reserves of 2500, and the projected deficit of a declaration of war against the AI is -50, would I go to war? If the prize is nice, heck yes! because I have savings for 50 turns of deficit. The AI right now is not doing that, it is just applying the -50 to reduce the weight. Right or wrong? I don't know, perhaps the word is incomplete. It should test for deficit ("sanity check"), but perhaps for more...? Cash reserves? Proportion of science points (as the deficit after ZERO cash gets deducted from there)?

Food for thought.
 
@Aristos
Would be interesting to see how these formulars differ from the ones used in trading.

I mean basically any AI would attack anyone if you just pay him like a total value of maybe 10 gold per turn. This is so little that it would not really make any difference in the formulars you presented about the war decisions the AI does on it's own.

So I guess for these trades the AI throws it's "insanity" overboard?
 
Just finished first Emperor game, standard, pang. Theodora.

I have to agree now. Something must be changed. None of my most bitter enemies, or my closest neighbors even came close to DoWing me. They didn't attack me when I was weak, and they sure didn't attack me when I was strong.

I won a DV, after Renaissance I consistently had at least 80% of the CSs, and no one even dared to attack them. I only had one consistent ally and kept making successful jerkball WC proposals, which of course got passed. I ignored the lower half of the tech tree as much as possible, so what little military I did have was pathetic.

So, no, the majority of anecdotes seem to be correct, the AI isn't playing smarter. GnK wasn't much better, but it's sad because if they just made the AI—oh, I don't know—DoW the Human player at least once throughout each game, BNW would be approaching perfection.

So, Firaxis, here's what you need to do:


Link to video.
 
Any talk of changing files should belong in the mod forum, if you are into that sort of thing. Shouldn't we just talk about desires and experiences relating to aggression and trust Firaxis to rebalance/tweak since they know the whole code?
 
For example, if I had cash reserves of 2500, and the projected deficit of a declaration of war against the AI is -50, would I go to war? If the prize is nice, heck yes! because I have savings for 50 turns of deficit. The AI right now is not doing that, it is just applying the -50 to reduce the weight. Right or wrong?

That's a great observation. IMO it would be flat wrong if the AI is universally prevented from deficit spending. Are you sure this isn't taken into account further downstream?
 
So if my understanding is right, from what Aristos tells us, war declaration is taking account a number of factors, focusing on gold income and adds a flat 'number' shall we say to the equation to get an end result. That flat number is the same from Prince and above...So in effect as far as DoWing is concearned we all are playing in Prince level?
I need to bang a wall now.

Anyways, that would explain A LOT! Thanks Aristos your info was invaluable.
 
So if my understanding is right, from what Aristos tells us, war declaration is taking account a number of factors, focusing on gold income and adds a flat 'number' shall we say to the equation to get an end result. That flat number is the same from Prince and above...So in effect as far as DoWing is concearned we all are playing in Prince level?
I need to bang a wall now.

Anyways, that would explain A LOT! Thanks Aristos your info was invaluable.

Not exactly. I told you, the diplo code is complex (and has many good things now). The AI Declaration Probability (as it is called in the files) is the LAST value to be applied, and it is applied as a factor after all other modifiers have been taken into account for the weight of the WAR decision. That factor did not change from previous versions, it was always 100 for Prince+. The effect of the modifiers may be another story, they may depend or not on difficulty (right now I don't remember seeing any like that, but I cannot discard it, so careful with rushing conclusions.

What can be said is that the last factor to be applied to the weight for WAR and for DECEPTIVE is the same for Prince+, and it is basically 1 (x times 1 is x), so the final weight is used as is in Prince+.

What has changed is the amount of modifiers applied BEFORE the last factor (most of the time they are added/subtracted, but I think I saw some that are also products), and how they work, to account for the new systems.

We have to acknowledge that if the trade route modifier ("sanity check") were not there, the complaints about economic suicide from the AIs would be filling the forum now. The modifier is there, as it should, and it is trying to preserve the economic sanity of the AI. We may debate as to the implementation and if it needs some balancing, but the concept is good. I would be seriously pissed off if the AI wouldn't take into account what this modifier does before considering WAR.
 
So, Firaxis, here's what you need to do:


Link to video.

Wrong. I hoped that by showing some snippets of the code some claims would become more rational. There is nothing to fix, there may be things to balance. The code is there; if the AIs would be committing economical suicide by declaring war like they did in G&K (that also meant military suicide), now THAT would need fixing (because that would mean the code for the modifier would be missing).

Try to do some experiments yourself; not that hard. Change just one number in your HandicapInfos file, and test it; put the probability of the AI declaring war to 110, or 120, for your preferred dif level, and see what happens. That may help a lot.
 
Something that we all need to understand now is that the AI has code to try and make it more competitive in ALL areas now; with all the new systems, that is clearly hard to balance (and honestly, I am surprised with the level of balance BNW has in its release version). The AI has code now that really makes it consider ALL aspects, that is what I wanted to find and partially show. As far as I remember, THAT IS EXACTLY what most of us have been asking for a long time.

With all the new systems, and the new AI trying to be more competitive in ALL of them, and trying to adapt to the situation, Civilization 5 is NOT A WARGAME anymore. It never should have been; that was a huge design failure derived exclusively from the original leadership.

War is an important part of the concept; I love war, especially when it is challenging. But if I want to play war only, I look for true masterpieces in that area: Norm Koger's Operational Art of War series, or maybe even Victor Reijkersz's Advanced Tactics. Civilization is something else, and that something has finally come back to V. We should give it the chance it deserves and help balance some things out. I can assure you after the re-learning phase is over (shall I say de-spoiling too?), you will most surely appreciate the original concept that defined the series.
 
Civilization is not "something else" exclusive of war and it should weigh warfare just as important (and with some civs, most important) as the other victories. You're right in that a balance must be achieved and right now, it is not balanced esp. At higher difficulties.
 
Civilization is not "something else" exclusive of war and it should weigh warfare just as important (and with some civs, most important) as the other victories. You're right in that a balance must be achieved and right now, it is not balanced esp. At higher difficulties.

See? That's my point; it's not "exclusive of war" right now yet you insist in painting it like that. It may be less "aggressive" (suicidal to me) than before, but I have shown you THERE IS A REASON. Thus, their lower AGGRESSIVENESS is REASONABLE. Can we be that too?

"Balance must be achieved now" sounds more like it is broken, which it is not.
 
That doesn't change the fact that some Civ's like the Aztec's are not taking advantage of their strength (early conquest). In my last game Monty sat there with two cities in the middle of the jungle with no chance to keep up in the economic, science or culture battle. Meanwhile with my tiny army I sat there worry free building up five great cities and buying up every CS I met. Everyone loved me because my trade routes offered a ton of gold and science. Three of my four games have been like that. I always play on Small/Emperor/Normal Speed. In my last game I was the Byzantines and I didn't even go for a religion! I did not need it to win. i just getting boring.
 
Back
Top Bottom