(PR#14053) naive AI and ceasefire
"Mateusz Stefek" <mstefek-IjDXvh/[email protected]> Tue, 20 Sep 2005 11:10:54 -0700
| Newsgroups | gmane.games.freeciv.ai |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format... ------------=_1127239854-9949-6 Content-Type: text/plain; charset="utf-8" <URL: http://bugs.freeciv.org/Ticket/Display.html?id=14053 > > [[email protected] - Tue Sep 20 17:01:37 2005]: > > Il giorno 20/set/05, alle 15:15, Mateusz Stefek ha scritto: > > > (Of course leaving empty cities is also a bug) > > i was able to conquer in one single turn 5-6 AI empty cities: he was > leaving them empty with my horsemen nearby, just because we were > allies. As I have just noticed, is_player_dangerous trusts neutral players. Here's my proposed change. Now I cannot take few warriors on the earth map and kill few players in the beginning - they protect their cities. -- mateusz ------------=_1127239854-9949-6 Content-Type: text/x-patch; charset="ascii"; name="is_player_dangerous.diff" Content-Disposition: inline; filename="is_player_dangerous.diff" Content-Transfer-Encoding: 7bit Index: ai/aitools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aitools.c,v retrieving revision 1.161 diff -u -r1.161 aitools.c --- ai/aitools.c 26 Aug 2005 19:27:40 -0000 1.161 +++ ai/aitools.c 20 Sep 2005 17:58:31 -0000 @@ -112,20 +112,49 @@ /********************************************************************** There are some signs that a player might be dangerous: We are at war with him, he has done lots of ignoble things to us, he is an - ally of one of our enemies (a ticking bomb to be sure), or he is - our war target. + ally of one of our enemies (a ticking bomb to be sure), he is + our war target, we don't like him, diplomatic state is neutral + or we have case fire. + This function is used for example to check if pplayer can leave + his city undefended when aplayer's units are near it. ***********************************************************************/ bool is_player_dangerous(struct player *pplayer, struct player *aplayer) { - struct ai_data *ai = ai_data_get(pplayer); - struct ai_dip_intel *adip = &ai->diplomacy.player_intel[aplayer->player_no]; - int reason = pplayer->diplstates[aplayer->player_no].has_reason_to_cancel; + struct ai_dip_intel *adip; + struct ai_data *ai; + enum diplstate_type ds; + + if (pplayer == aplayer) { + /* We always trust ourself */ + return FALSE; + } + + ds = pplayer_get_diplstate(pplayer, aplayer)->type; + + if (ds == DS_WAR || ds == DS_CEASEFIRE || ds == DS_NEUTRAL) { + /* It's already a war or aplayer can declare it soon */ + return TRUE; + } - return (pplayer != aplayer - && (pplayers_at_war(pplayer, aplayer) - || adip->countdown >= 0 - || reason != 0 - || adip->is_allied_with_enemy)); + ai = ai_data_get(pplayer); + adip = &(ai->diplomacy.player_intel[aplayer->player_no]); + + if (adip->countdown >= 0 || adip->is_allied_with_enemy) { + /* Don't trust our war target or someone who will declare war on us soon */ + return TRUE; + } + + if (pplayer->diplstates[aplayer->player_no].has_reason_to_cancel > 0) { + return TRUE; + } + + if (pplayer->ai.love[aplayer->player_no] < MAX_AI_LOVE / 10) { + /* We don't trust players who we don't like. Note that + * aplayer's units inside pplayer's borders decreases AI's love */ + return TRUE; + } + + return FALSE; } /************************************************************************* ------------=_1127239854-9949-6--