Peacemongerer
Prince
I think that the AI can be trained to make much smarter decisions in a war just by changing what numbers its looking at and giving it a better decision tree. Right now, it's pretty much just looking at the "military might" stat, which does the true state of affairs no justice. I have three suggestions on how to make it work a bit better.
Should I Continue?
The first question is how to make the AI sue for peace. I think the solution is to have the AI keep track of "score" in the war and determine whether continuing is worth it. Give cities taken a value, say 300 points base +25 per population (Capitals are worth triple), and units get a value of whatever a unit's cost in hammers is. Gold lost from pillaging and plundering cities is worth 5 each. Each side gets points based on what they've lost in the war.
Whichever side is outgunned militarily at any point sees their score inflated by 500 in the AI's eyes. Each turn spent at war increases the score by 10 no matter what. The count starts when the war begins and continues to build-up until peace is made.
Give AI three score threshholds to look at. Maybe 500, 1500 and 3000. This could be scaled to era and increased as units get more expensive and cities bigger. The first threshhold represents the point at which it will even consider peace (So it will always be willing to negotiate peace if no damage has been done and you're just stronger than them), but this check is done in net points (So it will consider peace if you have 900 points to their 1450, but not if it's 200 to 550). This is so the AI will always contiue a war if its causing more damage than you and stronger than you, but that high damages by defenders or long periods of combat will dissuade them from continuing the war.
The second number represents the treshhold where they have taken massive losses and will seek peace if their own score exceeds it and it is also any bit higher than yours. So if you have 1499 and they have 1501, they'll consider the war worthy of stopping simply because it is not doing enough damage to make-up for its lost units and hasn't been making enough gains to justify its losses thus far. If trying to take a population 10 city has cost you 550 hammers worth of units and you still haven't done so, then you likely will not be doing so any time soon.
The third threshhold represents the point where, if they exceed it, they begin to consider offering-up not just gold and luxuries, but also cities as tribute. This is so that no matter how strong you are, an AI must take major losses before it secedes territory. 3,000 points represents losing a city of population 108 or a capital of population 28 so losing one city by itself will almost never cause them to surrender cities willingly. Also, just because it has crossed that threshhold does not mean it will give-up cities, only that it is open to it in the event it deems the situation to be tribute-worthy.
Giving it a decision system where it's also keeping track of war losses ensures that the AI isn't wasting too many hammers on a war if it hasn't been weakening its opponent to a similar degree and gives it an effective cutoff point where the war is considered pointless. The AI tends to weaken itself against players at times by spending hammers that could be used on civilian improvements or wonders on fruitless campaigns against other AI. This would reduce that as well as make for more reasonable deals with players. The +10 per turn means that in any war where you've done a little bit better than them that has dragged on for 150 turns will be peaceworthy, because even if they're stronger, they clearly haven't been able to leverage that strength well, as you've inflicted more damage than them. Simply being at war for 150 turns will not deter the AI, as your score is also going-up by +10 each turn... you'll need to one-up them to get a peace offer.
Two possible ammendments would be to scale it so that if your score is higher than an opponent's at the end of a turn, your score goes-up by +15 or +20 instead of +10. The other is to give a civ who has determined his victory path to be domination an innate score of less than 0 (Maybe like -200) going into a war so that warmongers will be less apt to want peace.
That's how I think we could fix that issue of knowing whether a war is a good investment.
Who's Winning?
The other issue is how to determine what an AI wants to do with a peace deal once it has determined peace is viable. If the war continues, will I destroy my opponent, be destroyed or is it uncertain? Right now it just looks at military strength, but that doesn't tell the whole story, as a well-defended empire with walls and castles you can't tear down is not going to capitulate to tribute demands.
Prehaps give each civ an "offensive" and "defensive" value for the AI to look at.
Offensive would be primarily unit-based (Basically what it is now), and defensive would include both units (To a lesser degree) and city strengths. The offensive value would be weighted... perhaps 2x total combined unit strength + 15x the number of normal units + 20x the number of siege weapons (Inc. bombers) + 20x the number of highly-promoted (At least 3 promos) units. This ensures that armies with lots of units mean more in earlier eras, as combat strength is low, and are less significant in later eras compared to their combat strength, and also accounts for the offensive punch of siege units.
Defensive value could then be determined based-on city strength as well as unit strength/count. The defensive value is an unweighted version of the offensive algorithm (So siege units are no longer 20x their number, but 15x) and the sum of all city combat strengths, with those values being multiplied by city HP (So a 50-strength city with 117 HP at the moment would be 58.5; a city with strength 200 but only 5 hp left would just be 10).
The other thing is to multiply bonuses based-on what buffs and strategic considerations there are. For example, maybe augment empire defense by 10% if they're far away from you and by 10% if their empire has a lot of rough terrain blocking unit movement, by 15% if opponent has Himejii Castle, +25% if they have Great Wall, +10% if they're Ethiopia and you're a larger civ. Add bonuses to attack strength as well, like +5% if you have Statue of Zeus, etc. These are things a player would consider that can't be quantified easily, but must be considered at least slightly in AI decision-making.
The values are added-up and the AI is then given a decision tree to work-with in peace negotiations.
Your defense < Their offense: They seek tribute and will not take and even deal.
Your defense > Their offense or Their defense > Your offense: They ask for even terms.
Your offense > Their defense: They will offer some sort of tribute.
Since defense is based in-part on offense, there will almost never be a scenario in which both sides have offenses stronger than the opponent's defenses (This will only be possible if both sides spam siege units). If such a thing happens, then the AI then temporarily looks at unweighted unit scores when calculating offensive numbers.
How Much of a Payout?
The last question is that if the AI has determined to end a war and knows whether it wants to take or give away, just how much? I think the scores in part 1 will help make the decision a bit easier. If you've both taken huge casualties and you only are slightly stronger than an opponent, then you shouldn't be demanding everything in the treasury.
Give the AI an algorithm like this (Just an example):
Tribute points = 200 + Score Difference x O-D ratio + 50x number of units in their lands
If you have netted 700 points of war score on someone and have twice the offense that they have defense while 5 units are in their territory, then they will be willing to give you goodies worth up to 1,850 tribute points.
City value in tribute points is 1000 base + 100 per citizen, while everything else has a value of its gold value in normal trades. In the example above, the AI would be willing to give 1800 gold or 7 luxuries or a population 8 city if it has deemed that to be the right course of action. This means that war losses are augmented by your current military prowess and by your military presence in their territory (It shouldn't be willing to offer too much if you're halfway around the world).
If score difference is negative (IE you're stronger than an AI, but the AI has inflicted more damage), then the AI will instead deduct its advantage in score from the value of 200 + 50x number of units in their lands. So an AI outgunned but beating you by a score of 150 while you have no units in their lands will still offer 50 gold, while moving-in a unit would up the tribute they'd offer to 100 gold, and so on.
If an AI has determined it should be asking for tribute and not you, it will then use this same algorithm to determine how much tribute it wants from you. If you can't give it what it wants because you're broke, then odds are it's winning the war anyway and won't be suing for peace (Unlike when a human asks for peace only to see the AI offer its 8 gold). If you're just that broke and you can't offer the AI enough to meet its demands, then it will settle for every penny you have instead so long as you are able to offer at least 75% of what it wants. If you can't manage that, yet somehow still "winning" the war to the point the AI wants peace, (Like if you're in an OCC situation and killing many waves of units), then it will keep the war going anyway until you present it with loot or kill-off its attack forces.
------------------------------------
I'm just throwing ideas out there bc the AI decision tree seems to be way to simple at the moment and I think it could be improved just by looking at more stuff. Thoughts, suggestions, comments?
Should I Continue?
The first question is how to make the AI sue for peace. I think the solution is to have the AI keep track of "score" in the war and determine whether continuing is worth it. Give cities taken a value, say 300 points base +25 per population (Capitals are worth triple), and units get a value of whatever a unit's cost in hammers is. Gold lost from pillaging and plundering cities is worth 5 each. Each side gets points based on what they've lost in the war.
Whichever side is outgunned militarily at any point sees their score inflated by 500 in the AI's eyes. Each turn spent at war increases the score by 10 no matter what. The count starts when the war begins and continues to build-up until peace is made.
Give AI three score threshholds to look at. Maybe 500, 1500 and 3000. This could be scaled to era and increased as units get more expensive and cities bigger. The first threshhold represents the point at which it will even consider peace (So it will always be willing to negotiate peace if no damage has been done and you're just stronger than them), but this check is done in net points (So it will consider peace if you have 900 points to their 1450, but not if it's 200 to 550). This is so the AI will always contiue a war if its causing more damage than you and stronger than you, but that high damages by defenders or long periods of combat will dissuade them from continuing the war.
The second number represents the treshhold where they have taken massive losses and will seek peace if their own score exceeds it and it is also any bit higher than yours. So if you have 1499 and they have 1501, they'll consider the war worthy of stopping simply because it is not doing enough damage to make-up for its lost units and hasn't been making enough gains to justify its losses thus far. If trying to take a population 10 city has cost you 550 hammers worth of units and you still haven't done so, then you likely will not be doing so any time soon.
The third threshhold represents the point where, if they exceed it, they begin to consider offering-up not just gold and luxuries, but also cities as tribute. This is so that no matter how strong you are, an AI must take major losses before it secedes territory. 3,000 points represents losing a city of population 108 or a capital of population 28 so losing one city by itself will almost never cause them to surrender cities willingly. Also, just because it has crossed that threshhold does not mean it will give-up cities, only that it is open to it in the event it deems the situation to be tribute-worthy.
Giving it a decision system where it's also keeping track of war losses ensures that the AI isn't wasting too many hammers on a war if it hasn't been weakening its opponent to a similar degree and gives it an effective cutoff point where the war is considered pointless. The AI tends to weaken itself against players at times by spending hammers that could be used on civilian improvements or wonders on fruitless campaigns against other AI. This would reduce that as well as make for more reasonable deals with players. The +10 per turn means that in any war where you've done a little bit better than them that has dragged on for 150 turns will be peaceworthy, because even if they're stronger, they clearly haven't been able to leverage that strength well, as you've inflicted more damage than them. Simply being at war for 150 turns will not deter the AI, as your score is also going-up by +10 each turn... you'll need to one-up them to get a peace offer.
Two possible ammendments would be to scale it so that if your score is higher than an opponent's at the end of a turn, your score goes-up by +15 or +20 instead of +10. The other is to give a civ who has determined his victory path to be domination an innate score of less than 0 (Maybe like -200) going into a war so that warmongers will be less apt to want peace.
That's how I think we could fix that issue of knowing whether a war is a good investment.
Who's Winning?
The other issue is how to determine what an AI wants to do with a peace deal once it has determined peace is viable. If the war continues, will I destroy my opponent, be destroyed or is it uncertain? Right now it just looks at military strength, but that doesn't tell the whole story, as a well-defended empire with walls and castles you can't tear down is not going to capitulate to tribute demands.
Prehaps give each civ an "offensive" and "defensive" value for the AI to look at.
Offensive would be primarily unit-based (Basically what it is now), and defensive would include both units (To a lesser degree) and city strengths. The offensive value would be weighted... perhaps 2x total combined unit strength + 15x the number of normal units + 20x the number of siege weapons (Inc. bombers) + 20x the number of highly-promoted (At least 3 promos) units. This ensures that armies with lots of units mean more in earlier eras, as combat strength is low, and are less significant in later eras compared to their combat strength, and also accounts for the offensive punch of siege units.
Defensive value could then be determined based-on city strength as well as unit strength/count. The defensive value is an unweighted version of the offensive algorithm (So siege units are no longer 20x their number, but 15x) and the sum of all city combat strengths, with those values being multiplied by city HP (So a 50-strength city with 117 HP at the moment would be 58.5; a city with strength 200 but only 5 hp left would just be 10).
The other thing is to multiply bonuses based-on what buffs and strategic considerations there are. For example, maybe augment empire defense by 10% if they're far away from you and by 10% if their empire has a lot of rough terrain blocking unit movement, by 15% if opponent has Himejii Castle, +25% if they have Great Wall, +10% if they're Ethiopia and you're a larger civ. Add bonuses to attack strength as well, like +5% if you have Statue of Zeus, etc. These are things a player would consider that can't be quantified easily, but must be considered at least slightly in AI decision-making.
The values are added-up and the AI is then given a decision tree to work-with in peace negotiations.
Your defense < Their offense: They seek tribute and will not take and even deal.
Your defense > Their offense or Their defense > Your offense: They ask for even terms.
Your offense > Their defense: They will offer some sort of tribute.
Since defense is based in-part on offense, there will almost never be a scenario in which both sides have offenses stronger than the opponent's defenses (This will only be possible if both sides spam siege units). If such a thing happens, then the AI then temporarily looks at unweighted unit scores when calculating offensive numbers.
How Much of a Payout?
The last question is that if the AI has determined to end a war and knows whether it wants to take or give away, just how much? I think the scores in part 1 will help make the decision a bit easier. If you've both taken huge casualties and you only are slightly stronger than an opponent, then you shouldn't be demanding everything in the treasury.
Give the AI an algorithm like this (Just an example):
Tribute points = 200 + Score Difference x O-D ratio + 50x number of units in their lands
If you have netted 700 points of war score on someone and have twice the offense that they have defense while 5 units are in their territory, then they will be willing to give you goodies worth up to 1,850 tribute points.
City value in tribute points is 1000 base + 100 per citizen, while everything else has a value of its gold value in normal trades. In the example above, the AI would be willing to give 1800 gold or 7 luxuries or a population 8 city if it has deemed that to be the right course of action. This means that war losses are augmented by your current military prowess and by your military presence in their territory (It shouldn't be willing to offer too much if you're halfway around the world).
If score difference is negative (IE you're stronger than an AI, but the AI has inflicted more damage), then the AI will instead deduct its advantage in score from the value of 200 + 50x number of units in their lands. So an AI outgunned but beating you by a score of 150 while you have no units in their lands will still offer 50 gold, while moving-in a unit would up the tribute they'd offer to 100 gold, and so on.
If an AI has determined it should be asking for tribute and not you, it will then use this same algorithm to determine how much tribute it wants from you. If you can't give it what it wants because you're broke, then odds are it's winning the war anyway and won't be suing for peace (Unlike when a human asks for peace only to see the AI offer its 8 gold). If you're just that broke and you can't offer the AI enough to meet its demands, then it will settle for every penny you have instead so long as you are able to offer at least 75% of what it wants. If you can't manage that, yet somehow still "winning" the war to the point the AI wants peace, (Like if you're in an OCC situation and killing many waves of units), then it will keep the war going anyway until you present it with loot or kill-off its attack forces.
------------------------------------
I'm just throwing ideas out there bc the AI decision tree seems to be way to simple at the moment and I think it could be improved just by looking at more stuff. Thoughts, suggestions, comments?