[freeciv-ai] AI Diplomacy 10 - AI attacks me because I haven't met his a
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Firstly, thank you for implementing AI diplomacy, Per.
While testing the patch, one of the AIs declared war on me the turn after
making contact, claiming I had attacked his allies. I wasn't at war with anyone
at the time.
I believe I've tracked down the cause.
The message the AI sent me is in advdiplomacy.c:
/*** Declare war - against enemies of allies ***/
players_iterate(aplayer) {
struct ai_dip_intel *adip = &ai->diplomacy.player_intel[aplayer->player_no];
if (aplayer->is_alive
&& adip->at_war_with_ally
&& !adip->is_allied_with_ally
&& !pplayers_at_war(pplayer, aplayer)) {
notify(aplayer, _(TALK(%s) "Your aggression against my allies was your "
"last mistake!"), pplayer->name);
ai_go_to_war(pplayer, ai, aplayer);
}
} players_iterate_end;
So the AIs at_war_with_ally flag for me must have been set even though I wasn't
at war with anyone.
at_war_with_ally is set in ai_data_turn_init() in aidata.c.
It depends on the result of pplayers_at_war()
players_iterate(check_pl) {
[snip]
if (pplayers_allied(pplayer, check_pl)
&& pplayers_at_war(aplayer, check_pl)) {
ai->diplomacy.player_intel[i].at_war_with_ally = check_pl;
}
[snip]
} players_iterate_end;
But the pplayers_at_war function in player.c returns true
for players who haven't met:
/***************************************************************
Returns true iff players can attack each other.
***************************************************************/
bool pplayers_at_war(const struct player *pplayer,
const struct player *pplayer2)
{
enum diplstate_type ds = pplayer_get_diplstate(pplayer, pplayer2)->type;
if (pplayer == pplayer2) {
return FALSE;
}
if (is_barbarian(pplayer) || is_barbarian(pplayer2)) {
return TRUE;
}
return ds == DS_WAR || ds == DS_NO_CONTACT;
}
So having no contact with an AI's ally is considered grounds for war.
David
____________________________________________________________
Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail!
http://login.mail.lycos.com/r/referral?aid=27005
- [freeciv-ai] AI Diplomacy 10 - AI attacks me because I haven't met his allies,
david M stewart <=
|
|