Forced peace and ai war plotting

civac

King
Joined
Oct 22, 2010
Messages
913
Hey all,

in my recent game my neighbour Willem plotted war. I begged 10 gold from him resulting in a 10 turn peace treaty. He kept plotting so I assumed he was targetting someone else. However, a couple turns after the treaty ended he attacked me anyway which I had assumed was not possible. So how does this begging mechanic actually work? (I only saw it in a Lain video.) Or did he switch targets? I am 95% sure the red fist in bug mod indicating war plotting was there the whole time.
 
Last edited:
Willie can Plot at Pleased, so it is possible that begging will not negate it. It just delayed the DOW by virtue of the Peace Treaty. While it's possible that a leader may be plotting on someone else you should assume that leader is still plotting on you and prepare accordingly, if the red fist does not disappear with the beg.

The Know Your Enemy article is a great way to see how leader think:

https://forums.civfanatics.com/threads/civ-illustrated-1-know-your-enemy.478563/
 
I was aware that he can plot at Pleased. But why does the war plotting get cancelled then so often? This is the first time the beg did not actually work for me.
 
I actually see the opposite quite often, but honestly I'm not sure how this stuff is coded. Is it one's ability to Plot at Pleased that is a factor? Or are there other variables at play here. Whenever in doubt I like to often simply ping @elitetroops for answers :D
 
I don't know what can cause this to happen but I do know it's possible. I remember very well one game where some AI had an army approaching, I begged but the army didn't stop. The army entered my lands and walked around for some turns until the peace treaty was over and they declared. Don't remember who the AI was.
 
I've never figured out what (besides entering a state of war with someone) can knock an AI out of dagger prep. The one time I went code-diving looking nothing seemed to do it, but I have seen them occasionally abandon war plans so clearly I missed something.
 
I've never figured out what (besides entering a state of war with someone) can knock an AI out of dagger prep. The one time I went code-diving looking nothing seemed to do it, but I have seen them occasionally abandon war plans so clearly I missed something.

The thing is that the begging technique to get ais out of war plotting (if they are plotting against you) works so consistently that I had assumed the peace treaty cancels the war plotting because war is logically impossible for some turns. But that doesn't seem to be right. Do ais have a pre-determined time horizon for their attack? Can you remember which functions are used to determine ai war plotting?
 
The thing is that the begging technique to get ais out of war plotting (if they are plotting against you) works so consistently that I had assumed the peace treaty cancels the war plotting because war is logically impossible for some turns.
The most bizarre thing is that I've done the "beg for a ten turn peace treaty" thing plenty of times myself, but I don't think I've ever had an AI drop out of war plotting as a result. It always just delayed the inevitable, assuming that AI was actually plotting on me.
 
That's interesting. Lain uses the technique a lot. I should be able to find some examples of ai stopping its war preparation. You made me unsure of myself. ^^
 
Off topic somewhat, but I’ve always found this mechanic a bit like an exploit in the game. I can understand why the person demanding or begging can’t declare war, but I’ve never really understood why the person giving the gift / tribute can’t.

I guess one way peace treaties aren’t in the game but it seems a bit odd to me from a RP point of view? Also not something that is obvious to do as a player, unless you frequent forums such as these!
 
Or watch Lain videos, yeah.

I am also rather glad this trick doesn't work flawlessly. Better start building some more units.
 
Can you remember which functions are used to determine ai war plotting?

Mostly CvTeamAI::AI_doWar(). But there's some interaction with other functions, such as calls to CvTeamAI::AI_setWarPlanStateCounter and CvPlayerAI_getStrategyHash(). Which in turn draws in other functions like CvTeamAI::AI_doCounter(). The problem is that I'm obviously not reading the code right, because it looks (to me) like an AI preparing for a limited war should almost always declare the first turn it's allowed to after 5 turns have passed preparing (on normal speed) while one preparing for a total war should wait at least 10 turns, and abandon war plans if over 20 turns have passed preparing (on normal speed) and it still doesn't feel prepared to pull the trigger. Which means you should basically never see an AI in war prep mode for more than 21 turns on normal speed - it should have either attacked or abandoned the plan by then. Which flies counter to some actual in-game experience where I'm pretty sure I've observed that in the past. Although since the function doesn't actually return right away, I suppose it's possible an AI preparing for total war could shift to no war plan, continue on further down the function, realize it has no war plan, and come up with a new one - potentially picking a new target, or the same target again - all on the same turn.
 
I guess one way peace treaties aren’t in the game!
Because there’s no such thing. It’s illogical.

Note that ceasefire is on option though.
 
The most bizarre thing is that I've done the "beg for a ten turn peace treaty" thing plenty of times myself, but I don't think I've ever had an AI drop out of war plotting as a result. It always just delayed the inevitable, assuming that AI was actually plotting on me.
This has been my experience too, but I recently was part of a game where begging and getting a 10 turn peace treaty instantly made the fist vanish.

So the beg does occasionally get the AI to stop plotting I think.

Some more code diving on this subject would be appreciated if anyone can do it.
 
In CvTeam::setForcePeace
Code:
if (AI_isSneakAttackPreparing(eIndex))
       {
           AI_setWarPlan(eIndex, NO_WARPLAN);
       }
Now I'll let someone wiser explain what sneak attack preparing means...

Edit: AI_isSneakAttackPreparing should return true if they are preparing a limited or total war.

If I'm reading this correctly that method should be called whenever AI gives help or accepts a demand and it should result in them abandoning their war plans if in the preparation phase of limited or total war. Need to refresh my memory on how these preparation phases work.

The relevant code:
Spoiler :

CvPlayer::handleDiploEvent
Code:
    case DIPLOEVENT_GIVE_HELP:
       AI_changeMemoryCount(ePlayer, MEMORY_GIVE_HELP, 1);
       forcePeace(ePlayer);
       break;

   case DIPLOEVENT_ACCEPT_DEMAND:
       AI_changeMemoryCount(ePlayer, MEMORY_ACCEPT_DEMAND, 1);
       forcePeace(ePlayer);
       break;
CvPlayer::forcePeace
Code:
       setTradeItem(&kTradeData, TRADE_PEACE_TREATY);
CvDeal::startTrade
Code:
    case TRADE_PEACE_TREATY:
       GET_TEAM(GET_PLAYER(eFromPlayer).getTeam()).setForcePeace(((TeamTypes)(GET_PLAYER(eToPlayer).getTeam())), true);
CvTeam::setForcePeace
Code:
       if (AI_isSneakAttackPreparing(eIndex))
       {
           AI_setWarPlan(eIndex, NO_WARPLAN);
       }
CvTeamAI::AI_isSneakAttackPreparing
Code:
{
   return ((AI_getWarPlan(eIndex) == WARPLAN_PREPARING_LIMITED) || (AI_getWarPlan(eIndex) == WARPLAN_PREPARING_TOTAL));
}
Let me know if I got it all wrong. I'm absolutely not a C++ expert. :lol:
 
Last edited:
So much code diving. This life is easier:

Beg. Fist goes away. Good :)
Beg. Fist stays. Crap. Build units (just in case it's on me). :sad:

But...wouldn't we still be better off knowing at which points begging makes the AI stop plotting if it is plotting on you, and which points begging does nothing?

If we has this knowledge, thinking would go:

Beg. Fist goes away. Good :)
Beg. Fist stays. If [X], that means they're plotting on someone else, get ready to watch some fireworks :popcorn:. Otherwise...storm's comin' :run:.
 
Code looks pretty clear, except it doesn't always seem to abandon the war planning. There must be something else going on.
 
Do they always go straight from preparing to declaring or can there be turns in between when preparations are done but they haven't declared yet? For example when done preparing they switch from WARPLAN_PREPARING_TOTAL to WARPLAN_TOTAL and send their army towards target but declaration doesn't happen until they cross the border? This would be consistent with my experience of fist not disappearing. Army was on the move towards me when I begged.

Also not sure if there are other types of preparations than limited and total. Can't check code now.
 
Back
Top Bottom