Complete.Org: Mailing Lists: Archives: freeciv-ai: September 2004:
[freeciv-ai] (PR#9917) AI never agrees on cease fire
Home

[freeciv-ai] (PR#9917) AI never agrees on cease fire

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [freeciv-ai] (PR#9917) AI never agrees on cease fire
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Sat, 4 Sep 2004 04:10:42 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9917 >

> [mstefek - Sat Sep 04 10:48:24 2004]:
> Try attached patch.
And the missing patch
--
mateusz
Index: advdiplomacy.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdiplomacy.c,v
retrieving revision 1.36
diff -u -r1.36 advdiplomacy.c
--- advdiplomacy.c      4 Sep 2004 07:46:03 -0000       1.36
+++ advdiplomacy.c      4 Sep 2004 10:46:16 -0000
@@ -164,6 +164,23 @@
 }
 
 /********************************************************************** 
+  Checks if player1 can agree on ceasefire with player2
+  This function should only be used for ai players
+**********************************************************************/
+static bool ai_players_can_agree_on_ceasefire(struct player* player1,
+                                              struct player* player2)
+{
+  struct ai_data *ai1;
+  ai1 = ai_data_get(player1);
+  return (ai1->diplomacy.target != player2 && 
+          (player1 == ai1->diplomacy.alliance_leader ||
+           !pplayers_at_war(player2, ai1->diplomacy.alliance_leader)) &&
+         player1->ai.love[player2->player_no] > -40 &&
+         (ai1->diplomacy.target == NULL || 
+          !pplayers_allied(ai1->diplomacy.target, player2)));
+}
+
+/********************************************************************** 
   Evaluate gold worth of a single clause in a treaty. Note that it
   sometimes matter a great deal who is giving what to whom, and
   sometimes (such as with treaties) it does not matter at all.
@@ -329,8 +346,13 @@
                       - ai->diplomacy.req_love_for_alliance);
       }
     } else {
-      worth = greed(pplayer->ai.love[aplayer->player_no]
-                    - ai->diplomacy.req_love_for_ceasefire);
+      if (pplayer->ai.control && aplayer->ai.control &&
+         ai_players_can_agree_on_ceasefire(pplayer, aplayer)) {
+        worth = 0;
+      } else {
+        worth = greed(pplayer->ai.love[aplayer->player_no]
+                      - ai->diplomacy.req_love_for_ceasefire);
+      }
     }
   break;
 

[Prev in Thread] Current Thread [Next in Thread]