Bug #2483
openAI player can decide to target its own cities
0%
Description
POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, aplayer) in ai/default/daiunit.h is `WAR || NEVER_MET() || countdown >= 0`.
A player's diplstate with itself is DS_NO_CONTACT, and NEVER_MET() reads exactly that, so the macro is TRUE when aplayer == pplayer.
find_something_to_kill() uses it to filter the cities and units a virtual attacker may target when the AI rates what attacker to build, so the AI's own cities are rated as targets alongside the enemy's, and one can come out best. (The ability to attack the own city is then evaluated, and is false, so the desire to build an attacker goes away. In my tests, something like 95% of the earlygame an own-city wins, and 2/3rds of the time there was a foreign city that should win.) dai_gothere_bodyguard() likewise asks for an escort when a unit heads for an own city.
The other callers (invasion_funct(), kill_something_with(), daidiplomat.c) are about other players' cities and units and thus the AI never targets itself for actually attacking or invading.
NEVER_MET() went into the macro in 2014. I think it's right to special-case self in POTENTIALLY_HOSTILE_PLAYER()? But could see an argument for making NEVER_MET(self) false instead.
Files
Updated by Marko Lindqvist 13 days ago
- Status changed from New to In Review
- Assignee set to Marko Lindqvist