Arqade Asked on November 7, 2021
In the common interest of preventing global warming and nuclear winters, I sometimes send my engineers into enemy territory to help my enemies clean up pollution and nuclear fallout. However, enemy AI attitude seems to worsen when I do things to their land. Is this the case when I clean up pollution and nuclear fallout? Does the worsening of attitude also apply when I clean up the land of an AI player that is allied to me?
A bit of background: The AI's opinion of the player is tracked by a hidden love
variable. It ranges from -MAX_AI_LOVE = -1000
to MAX_AI_LOVE = +1000
.
For the bit of game code relevant to the question: See lines no 1077-1087 of the file /ai/default/daidiplomacy.c
:
/* Reduce love due to units in our territory.
* AI is so naive, that we have to count it even if players are allied */
amount -= MIN(player_in_territory(pplayer, aplayer) * (MAX_AI_LOVE / 200),
ai->diplomacy.love_incr
* ((adip->is_allied_with_enemy != NULL) + 1));
pplayer->ai_common.love[player_index(aplayer)] += amount;
if (amount != 0) {
DIPLO_LOG(ait, LOG_DEBUG, pplayer, aplayer, "%d love lost due to units inside "
"our borders", amount);
}
The function player_in_territory
counts the number of your units in the AI's territory. Each such unit inside such will each turn reduce the hidden love
variable by 5. This effect is capped at 30 if you are considered Neutral or Allied, but capped at 60 if you are considered an Enemy (at war or allied with someone at war with the AI in question).
To clarify: Being an 'enemy' as considered by this code is thus independent of being displayed as allied in-game: you can be both friend and foe at the same time by allying with two AI's who have declared to be at a state of war with eachother.
It is completely irrelevant what these units are doing or what the type of unit is. The AI hates all units but its own equally.
In other words, it takes a total of 67 turns to go from maximum opinion to minimum with the maximum of 6 player units that the AI will count.
This is because the value love_incr
is defined as a constant MAX_LOVE * 3 / 100 = 30
and does not appear to be an lvalue in any expression in the codebase.
Hidden units don't count
One more little detail: the player_in_territory
function won't cheat. Thus units that are hidden (spies and so forth) will not upset the AI, nor will any unit hidden in the fog of war. Until our AI realizes their existence, that is.
Answered by aphid on November 7, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP