Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Sample logfile of the UWAI (Utility-Based War AI) mod component

The AI-controlled Team 1, consisting of Charlemagne, reviews its war plans. This
includes both ongoing wars and wars still in preparation. In this example, there is just
one war plan to be reviewed, namely an ongoing war against me (Team 0, Zara
Yaqob). Charlemagne can either continue the war or try to make peace. In this case,
he can’t exactly make peace because a bug outside the SDK prevents the AI from
offering peace to a human player, but the same computation would happen if I
contacted Charlemagne suing for peace.
The war plan is evaluated by comparing two scenarios: one in which the war is
continued for a foreseeable future of 25 turns, and one in which the war is
immediately ended.

Year 1000, T1:


Charlemagne

T1 reviews its war plans


Evaluating limited war between T1 and T0 (Zara Yaqob, human)

Current actual war plan: limited


(considering peace)
Preparation time vs. target: 0

A single possible course of the war is simulated in a simplified model of Civ 4


combat. Multiple simulations, perhaps a best-case and worst-case scenario, would
be more informative, but a single trajectory should be enough for a decision that is at
least somehow rationalizable.
Apart from Charlemagne and me, there is one other war party: Ramesses is also at
war with me. The model assumes that each war party will focus its attacks on a
single target. Based on geographical distance, Charlemagne believes that me and
Ramesses are targeting each other, while Charlemagne also targets me. (This
happens to be true; I’m not trying to conquer Charlemagne’s cities for the time being.)

War scenario

Military analysis from the pov of Charlema

Too few missions to determine target of Zara Yaq


Charlema assumes Ramesses to be the target of Zara Yaq.
Too few missions to determine target of Charlema
Charlema assumes Zara Yaq to be the target of Charlema.
Too few missions to determine target of Ramesses
Charlema assumes Zara Yaq to be the target of Ramesses.

The military power of the war parties is broken down into several branches: A (home)
guard that is assumed to be available only for defense; an (invasion) army that can
be used both offensively and defensively; a fleet of warships to accompany or fend
off a naval invasion or for bombarding city defenses; “logistics” is the total cargo
capacity for naval landings – not relevant here because everyone is on the same
landmass.
I’m assumed to have a relatively small guard because the AI is aware that humans
tend to leave few units at home. Charlemagne’s army is a small one by AI standards;
he hadn’t taken much time to prepare for this war. Ramesses has just Heliopolis left,
but it’s a large city filled with units. Most of his units are cavalry because he has lost
his metal sources.

Present power of Zara Yaq


Guard 98, Army 159, Fleet 2, Logistics 3

Present power of Charlema


Guard 218, Army 156, Fleet 39

Present power of Ramesses


Guard 82, Army 98, Fleet 2, Logistics 3, Cavalry 102

The model assumes that more units are trained during the simulated 25-turn period,
but not all of these units will be deployed in time to make a difference; military build-
up is projected for 13 turns. This projection works much like in K-Mod. One main
factor is the amount of available production (see below), the other the available
military technology, which determines how production translates into power.
Archers are the typical defensive units of all war parties. Both Zara and Charlemagne
can train Swordsmen, but Ramesses only Horse Archers, which are assumed to be a
tiny bit less efficient (power 25 for 50 production) than Swordsmen (21 for 40).

Simulating initial build-up (13 turns)

Typical unit ratings of Zara Yaq (by military branch):

Guard: 6 (Archer, cost: 25)


Army: 21 (Swordsma, cost: 40)
Fleet: 4 (Trireme, cost: 50)
Logistics: 3 (Galley, cost: 50)
Cavalry: 25 (Horse Ar, cost: 50)

Typical unit ratings of Charlema (by military branch):

Guard: 6 (Archer, cost: 25)


Army: 21 (Swordsma, cost: 40)
Fleet: 4 (Trireme, cost: 50)
Logistics: 3 (Galley, cost: 50)

Typical unit ratings of Ramesses (by military branch):

Guard: 6 (Archer, cost: 25)


Army: 25 (Horse Ar, cost: 50)
Fleet: 4 (Trireme, cost: 50)
Logistics: 3 (Galley, cost: 50)
Cavalry: 25 (Horse Ar, cost: 50)

Charlemagne estimates my total per-turn production based on the “goods produced”


graph. By upgrading the Warriors that guard my cities, I could also use gold to
increase my military power. For simplicity, the potential for upgrades is converted into
an additional 90 production.
To determine which portion of my production will be used for military build-up,
Charlemagne looks at the gradient of my power curve. I haven’t trained any units
recently because I figured the units I had would be enough to finish off Ramesses.
Charlemagne concludes from this that I’m doing normal, peacetime build-up, and that
I split the production 2:1 between army and guard. No naval build-up because my
target city is reachable without ships.

Armament forecast for Zara Yaq


Production per turn: 87
Total gold needed for upgrades: 400
Upgrades bounded by income (66 gpt)
Production from upgrades: 90
Target city: Heliopolis
War plans: 2; assuming 2 wars, 1 total wars
Checking AreaAI
Build-up intensity based on power curve: 0
Using estimated intensity for forecast
Forecast for the next 13 turns
Defensive: yes, naval: no, intensity: normal
Branch portions for Guard, Army: 33, 67
Total production for build-up: 316 hammers
Predicted power increase in Guard by 27
Predicted power increase in Army by 111

Charlemagne does a similar projection for himself and Ramesses, and, after factoring
in the typical units, arrives at the following power ratings for the military analysis. As
he’s assuming wartime build-up for himself and peacetime build-up for me, he’s
outnumbering me. (Once I start training more units, he’ll adjust his projection.)

Predicted power of Zara Yaq

Guard 125, Army 270, Fleet 2, Logistics 3

Predicted power of Charlema

Guard 218, Army 530, Fleet 39

Predicted power of Ramesses

Guard 101, Army 117, Fleet 2, Logistics 3, Cavalry 121

In more complicated wars, three or more civs can target each other in a cycle. Here
it’s just a cycle between me and Ramesses. The cycle is broken by assuming that
our armies clash into each other. Since Charlemagne also targets me, and because
his army is far larger than Ramesses’s, 72% of my army is assumed to be busy
fending off Charlemagne, and thus unavailable for the clash with Ramesses.
Simulating graph component starting at Charlema
Cycle
Zara Yaq --> Ramesses -->

Breaking a cycle of length 2


Assessing threat of Charlema’s army to Zara Yaq’s garrisons
(ignoring army of Zara Yaq)
Threat set to 275/275 percent (base/modified by willingness)
Assessing threat of Ramesses’s army to Zara Yaq’s garrisons
(ignoring army of Zara Yaq)
Threat set to 81/81 percent (base/modified by willingness)
Assessing threat of Zara Yaq’s army to Ramesses’s garrisons
(ignoring army of Ramesses)
Threat set to 67/67 percent (base/modified by willingness)
Clash of Ramesses and Zara Yaq
Employing 100 (Ramesses) and 28 (Zara Yaq) percent of armies
Deployment distances (Ramesses/Zara Yaq): 2/2
Army clash with modified power (A/D): 111/74
Losses in branch Army: 20 (Ramesses), 37 (Zara Yaq)
Losses in branch Cavalry: 21 (Ramesses), 0 (Zara Yaq)
Temporary army losses (damaged): 16
Zara Yaq no longer targets Ramesses

Both clashing armies take some losses. I lose the clash, meaning that I won’t get to
attack Heliopolis, while the armies of Ramesses and Charlemagne proceed to attack
my cities. Ramesses is the first to reach a city, and his target is Thebes, his former
capital. However, the surviving portion of his army isn’t enough (45%) to defeat my
garrisons. Ramesses gets to make no further attacks.

Resolving lost cities of Zara Yaq


Assessing invasion priority (att. duration) of Charlema
Duration at least 7
Assessing invasion priority (att. duration) of Ramesses
Duration at least 6
Attack on Thebes by Ramesses
Employing 100 (Ramesses) and 17 (Zara Yaq) percent of armies
Attacker power: 81
Defending army’s power: 39
Deployment distances (Ramesses/Zara Yaq): 3/0
Deployment duration: 1
City defender power: 170 (113 from local garrisons, 23 from
rallied garrisons, 34 from retreated army (75 percent))
Besieger power: 76
Power ratio (A/D): 45 percent
Bombardment assumed to take 3 turns
Losses in branch Guard: 0 (Ramesses), 13 (Zara Yaq)
Losses in branch Army: 15 (Ramesses), 0 (Zara Yaq)
Losses in branch Cavalry: 16 (Ramesses), 0 (Zara Yaq)
Ramesses no longer targets Zara Yaq
Now simulated 6 invasion turns of Ramesses
Charlemagne also attacks Thebes. Due to poor war success so far, he has reduced
confidence in his army, and his personality gives him low confidence in his ally
Ramesses and the distraction that he poses. All the same, Charlemagne thinks that
his army’s power is enough (124% of the defenders) to take Thebes and,
subsequently, also Gondar (140% power ratio). Any further conquests would be
outside the time limit of the simulation.

Assessing invasion priority (att. duration) of Charlema


Duration at least 7
Attack on Thebes by Charlema
Employing 100 (Charlema) and 90 (Zara Yaq) percent of armies
Confidence in allies of Charlema: 63 percent
Learned confidence (Charlema/Zara Yaq): 86/100 percent
Attacker power: 530
Defending army’s power: 210
Deployment distances (Charlema/Zara Yaq): 9/0
Deployment duration: 4
City defender power: 301 (101 from local garrisons, 20 from
rallied garrisons, 180 from retreated army (75 percent))
Besieger power: 374
Power ratio (A/D): 124 percent
Bombardment assumed to take 2 turns
Losses in branch Guard: 0 (Charlema), 31 (Zara Yaq)
Losses in branch Army: 136 (Charlema), 142 (Zara Yaq)
Thebes (Zara Yaq) assumed to be conquered by Charlema
84 army power assumed to be left behind for defense
Emergency defender power for Zara Yaq: 17
Now simulated 8 invasion turns of Charlema

Assessing invasion priority (att. duration) of Charlema


Duration at least 10
Attack on Gondar by Charlema
Employing 100 (Charlema) and 100 (Zara Yaq) percent of armies
Learned confidence (Charlema/Zara Yaq): 86/100 percent
Attacker power: 311
Defending army’s power: 91
Deployment distance reduced b/c of prior conquest
Deployment distances (Charlema/Zara Yaq): 4/0
Deployment duration: 4
City defender power: 175 (57 from local garrisons, 24 from
rallied garrisons, 94 from retreated army (60 percent))
Besieger power: 245
Power ratio (A/D): 140 percent
Bombardment assumed to take 4 turns
Losses in branch Guard: 0 (Charlema), 19 (Zara Yaq)
Losses in branch Army: 88 (Charlema), 55 (Zara Yaq)
Gondar (Zara Yaq) assumed to be conquered by Charlema
84 army power assumed to be left behind for defense
Emergency defender power for Zara Yaq: 30
Now simulated 20 invasion turns of Charlema

Assessing invasion priority (att. duration) of Charlema


Duration at least 14

All steps exceed the time limit; none executed

Build-up is assumed to happen during the entire 25 turns, although only units trained
in the first half are assumed to fight. The other units still cost production.

Simulating concurrent build-up (12 turns)

In summary, the results of the military analysis: Charlemagne hopes to conquer two
cities. Is this worth more than 1000 production invested in military build-up? There
are some other aspects to consider as well …

Results about Zara Yaq

Cities lost:
Gondar
Thebes
Lost power from casualties: Guard 64, Army 234
Net power gain (build-up minus losses): Guard 75, Army -164
Invested production: 477
Wars continued:
Charlema
Ramesses

Results about Charlema

Cities conquered:
Gondar
Thebes
Lost power from casualties: Army 223
Net power gain (build-up minus losses): Guard 218, Army 280
Invested production: 1063
Wars continued:
Zara Yaq

Results about Ramesses

Lost power from casualties: Army 35, Cavalry 37


Net power gain (build-up minus losses): Guard 119, Army -81,
Cavalry -1
Invested production: 170
Wars continued:
Zara Yaq

Let’s start by evaluating the conquered cities as economical assets. The per-city
asset scores are updated once per turn and cached; this isn’t shown in the log. Most
of the score probably comes from Thebes, which is home to two shrines. The utility
value of 59 results from a division by the total score of Charlemagne’s present cities.

Computing utility of Charlemagne


2 cities conquered from Zara Yaq
Total asset score: 55
Asset score reduced to 41 due to culture pressure
Score for present assets: 204
Base utility from assets: 61
Rel. maint. = 21 / 74 = 28 percent
Cost modifiers: 3 percent for overextension, 0 for
defensibility
Greed for assets from Zara Yaqob: 59

Since Charlemagne expects to win the war, he’s counting on being paid for peace in
some form at some point.

Adding utility for future reparations


Greed for cash from Zara Yaqob: 4

Charlemagne also likes that he’s taking cities away from me because he hates my
guts (worst enemy and furious attitude).

Their lost assets: 67; their present assets: 248; our present
assets: 204; asset ratio: 33 percent
Difference in lost power (adjusted): 122; their projected
power: 328; our projected power: 915; military ratio: 13
percent
Loss rating for Zara Yaq: 24
Our vengefulness: 2
Divisor from number of rivals (7): 2
Loathing from Zara Yaqob: 17

Additionally, he’s afraid that I might attack him in the long run, and by taking my
cities, he’s reducing that threat.

Long-term threat rating for Zara Yaq: 20 percent


Our cities (now/predicted) and theirs: 7/7, 8/6
Their gain in power: -25 percent
Change in threat: -50 percent
Our distrust: 120 percent
Pre-emptive War from Zara Yaqob: 6

More importantly, only him and I and two other civs (not Ramesses) look like they
might win the game, and Charlemagne definitely does not want me to win.

135 base utility for change in asset ratio


Winning civs: 4 (3 rivals)
Attitude multiplier: 103 percent, competition multiplier: 50
percent
Kingmaking from Zara Yaqob: 52

There are eight more pro-war aspects, none of which apply here. Most of the anti-war
aspects don’t apply either.
For evaluating the war effort, opportunity cost is taken into account. Charlemagne
has barbarians to fight and cities to found (not shown in the log), which is why he
values his production highly at 3.21 gold. He also considers whether his military will
be unnecessarily large after the war (rather not; invested production reduced to
33%). The gold for unit supply is, as usually, negligible.

Cost for wartime economy and ravages: 7


1 production valued as 3.21 gold
Production value of lost units: 329, invested production:
1063, multiplier for future use of trained units: 33 percent,
adjusted production value of build-up and losses: 818
Estimated gold for supply: 133 (25 turns simulated, 11 units
lost)
Gold value of build-up and war effort: 2762
Effort (from no one in particular): -48

The AI can’t evaluate the tactical situation nearly as well as a human player,
therefore, it is always reluctant to make peace when opposing units are near each
other. In this case there is very little entanglement though, just a single Holy Roman
Archer blocking a gemstone mine next to Thebes.

Their exposed units: 0, ours: 0; entanglement: 1; their


evacuating population: 0, ours: 0; our missions: 0; our total
milit. units: 27; our population: 37; recently lost
population: 0 (0 percent)
Tactical situation from Zara Yaqob: 4

While the conquered assets alone are barely worth the effort, the Kingmaking aspect
leads to a high utility of the war scenario on the bottom line. And some build-up is
also undertaken in the peace scenario …


Total utility for Charlemagne: 94
Greed for assets total: 59
Greed for cash total: 4
Loathing total: 17
Pre-emptive War total: 6
Kingmaking total: 52
Effort total: -48
Tactical situation total: 4
Bottom line: 94

Peace scenario

In the peace scenario, a military analysis is still worthwhile because it tells


Charlemagne how the war between me and Ramesses might develop.

Military analysis from the pov of Charlema

Present power of Zara Yaq

Guard 98, Army 159, Fleet 2, Logistics 3


Present power of Charlema

Guard 218, Army 156, Fleet 39

Present power of Ramesses

Guard 82, Army 98, Fleet 2, Logistics 3, Cavalry 102

Too few missions to determine target of Zara Yaq


Charlema assumes Ramesses to be the target of Zara Yaq.
Too few missions to determine target of Charlema
Charlema assumes Zara Yaq to be the target of Charlema.
Too few missions to determine target of Ramesses
Charlema assumes Zara Yaq to be the target of Ramesses.

Done removing war parties


War parties (may) have changed; reassigning targets
Too few missions to determine target of Zara Yaq
Charlema assumes Ramesses to be the target of Zara Yaq.
Charlema has no war opponents.
(no longer targeting Zara Yaq)
Too few missions to determine target of Ramesses
Charlema assumes Zara Yaq to be the target of Ramesses.

Simulating initial build-up (13 turns)

The armament forecast differs a lot from the one in the war scenario. Since it’s a
fictional scenario, Charlemagne doesn’t trust the trend of the power curves, and
rather assumes that I’m doing what Charlemagne would do, which is full military
build-up. Now, it doesn’t make sense for military spending to increase after making
peace – perhaps something I should fix somehow. That said, it’s a minor artifact in
the big picture.

Predicted power of Zara Yaq

Guard 98, Army 593, Fleet 2, Logistics 3

Predicted power of Charlema

Guard 249, Army 281, Fleet 39

Predicted power of Ramesses

Guard 101, Army 117, Fleet 2, Logistics 3, Cavalry 121

Simulating graph component starting at Charlema


Isolated node; nothing to do for this component

Simulating graph component starting at Zara Yaq


Cycle
Zara Yaq --> Ramesses -->
This time, I win the clash, and proceed to conquer Heliopolis.

Breaking a cycle of length 2


Clash of Ramesses and Zara Yaq
Employing 100 (Ramesses) and 100 (Zara Yaq) percent of armies
Deployment distances (Ramesses/Zara Yaq): 1/3
Army clash with modified power (A/D): 116/553
Losses in branch Army: 58 (Ramesses), 10 (Zara Yaq)
Losses in branch Cavalry: 59 (Ramesses), 0 (Zara Yaq)
Temporary army losses (damaged): 25
Ramesses no longer targets Zara Yaq
Resolving losses of Ramesses
Assessing invasion priority (att. duration) of Zara Yaq
Duration at least 5
Attack on Heliopolis by Zara Yaq
Employing 100 (Zara Yaq) and 100 (Ramesses) percent of armies
Attacker power: 558
Defending army’s power: 59
Deployment distances (Zara Yaq/Ramesses): 5/0
Deployment duration: 2
City defender power: 424 (365 from local garrisons, 0 from
rallied garrisons, 59 from retreated army (100 percent))
Besieger power: 502
Power ratio (A/D): 118 percent
Bombardment assumed to take 1 turns
Losses in branch Guard: 0 (Zara Yaq), 85 (Ramesses)
Losses in branch Army: 162 (Zara Yaq), 50 (Ramesses)
Losses in branch Cavalry: 0 (Zara Yaq), 50 (Ramesses)
Heliopolis (Ramesses) assumed to be conquered by Zara Yaq
51 army power assumed to be left behind for defense
Now simulated 5 invasion turns of Zara Yaq

Simulating concurrent build-up (12 turns)

Results about Zara Yaq

Cities conquered:
Heliopolis
Lost power from casualties: Army 172
Net power gain (build-up minus losses): Guard 98, Army 521
Invested production: 1504
Wars continued:
Ramesses

Charlemagne’s build-up is about half as much as in the war scenario.

Results about Charlema

Lost power from casualties: none


Net power gain (build-up minus losses): Guard 278, Army 22
Invested production: 531
Results about Ramesses

Eliminated
Cities lost:
Heliopolis
Lost power from casualties: Guard 85, Army 107, Cavalry 108
Net power gain (build-up minus losses): Guard 16, Army -171,
Cavalry -89
Invested production: 88
Wars continued:
Zara Yaq

Negative utility from Loathing, Pre-emptive War and Kingmaking because conquering
Heliopolis makes me a stronger adversary. Moreover, Ramesses is a trade partner of
Charlemagne. The only upside of peace is that my ill will toward Charlemagne is
reduced; we might, in the medium term, cooperate again.

Computing utility of Charlemagne

Difference in lost power (adjusted): 172; their projected


power: 952; our projected power: 435; military ratio: 40
percent
Loss rating for Zara Yaq: -5
Our vengefulness: 2
Divisor from number of rivals (7): 2
Loathing from Zara Yaqob: -8
Expecting them to lose 100 percent of their assets
Net gold value of resource and gold: 0
Per-turn trade route profit: 1
No utility from tech trade b/c progress too far apart
Utility for trade: 0, tech/military: 0, both weighted by saved
assets
Utility raised to 8 for strategic value of OB
Personality multiplier: 100 percent
Preservation of partners from Ramesses II: -8
Long-term threat rating for Zara Yaq: 20 percent
Our cities (now/predicted) and theirs: 7/7, 8/9
Their gain in power: 13 percent
Change in threat: 35 percent
Our distrust: 120 percent
Pre-emptive War from Zara Yaqob: -3
-20 base utility for change in asset ratio
Winning civs: 2 (1 rivals)
Attitude multiplier: 103 percent, competition multiplier: 100
percent
Kingmaking from Zara Yaqob: -21
1 production valued as 3.21 gold
Production value of lost units: 0, invested production: 531,
multiplier for future use of trained units: 71 percent,
adjusted production value of build-up and losses: 154
Gold value of build-up and war effort: 493
Effort (from no one in particular): -7
5 for the possibility of reconciliation
Ill Will from Zara Yaqob: 5

Total utility for Charlemagne: -42
Loathing total: -8
Preservation of partners total: -8
Pre-emptive War total: -3
Kingmaking total: -21
Effort total: -7
Ill Will total: 5
Bottom-line: -42

The total utility of the war plan is computed by subtracting the utility of peace from the
utility of war. Obviously, Charlemagne isn’t seeking peace, and I’d have to pay him so
much that no peace deal is even possible; he refuses to talk.

Utility war minus peace: 136

Reviewing war plan “limited” (age: 7 turns) against T0 (at


war; u=136)
Threshold for seeking peace: 0
No peace sought b/c war utility is above the peace threshold

While I did not actually come close to losing cities to Charlemagne, the war forced
me to train additional units and pay Ramesses 40 gold for a temporary peace. The
main misjudgment of the AI was that I’d continue to not train units. By now, I’ve made
a change to address this: The AI assumes increased human build-up while at war,
even if the power curve suggests otherwise.

You might also like