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?
Freeciv – AI Attitude Changes with Pollution and Nuclear Fallout Cleanup: Analysis
freeciv
Best Answer
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
toMAX_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
: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 hiddenlove
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 constantMAX_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.