(PR#10083)

"Mateusz Stefek" <mstefek-IjDXvh/[email protected]>
Newsgroups gmane.games.freeciv.ai
Message-ID <[email protected]>
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10083 >

This patch changes the range of ai love to [-1000..1000]
The reason for that is that basically ai_diplomacy_calculate() changes
the love according to this formula:
love := (love + modifier) * 0.96
When modifier is -1, love should theoretically stabilize at -24, but
there are many others fixed points in current implementation (like -43)
because of integer rounding errors.
Changing the rounding direction doesn't help either.
--
mateusz
love_scale.diff (text/x-patch, 5.6 KB)
? server/civgame-3700.sav.gz
? server/civgame-3950.sav.gz
Index: ai/advdiplomacy.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdiplomacy.c,v
retrieving revision 1.37
diff -u -r1.37 advdiplomacy.c
--- ai/advdiplomacy.c	6 Sep 2004 09:00:32 -0000	1.37
+++ ai/advdiplomacy.c	13 Sep 2004 15:00:49 -0000
@@ -102,8 +102,8 @@
 static int greed(int missing_love)
 #define NUM_BANDS 5
 {
-  int band_incr[NUM_BANDS] = {5, 5, 10, 20, 30};
-  int band_rate[NUM_BANDS+1] = {10, 25, 50, 100, 250, 500};
+  int band_incr[NUM_BANDS] = {50, 50, 100, 200, 300};
+  int band_rate[NUM_BANDS+1] = {1, 3, 5, 10, 25, 50};
   int greed = 0;
   int i = 0;
   int n_love = -missing_love;
@@ -175,7 +175,7 @@
   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 &&
+	  player1->ai.love[player2->player_no] > -400 &&
 	  (ai1->diplomacy.target == NULL || 
 	   !pplayers_allied(ai1->diplomacy.target, player2)));
 }
@@ -569,7 +569,7 @@
   if (total_balance > 0 && gift) {
     int i = total_balance / ((city_list_size(&pplayer->cities) * 50) + 1);
 
-    i = MIN(i, ai->diplomacy.love_incr * 150);
+    i = MIN(i, ai->diplomacy.love_incr * 150) * 10;
     pplayer->ai.love[aplayer->player_no] += i;
     PLAYER_LOG(LOG_DIPL2, pplayer, ai, "%s's gift to %s increased love by %d",
             aplayer->name, pplayer->name, i);
@@ -652,7 +652,7 @@
   /* Modify by love. Increase the divisor to make ai go to war earlier */
   kill_desire -= MAX(0, kill_desire 
                         * pplayer->ai.love[aplayer->player_no] 
-                        / 200);
+                        / 2000);
 
   /* Amortize by distance */
   return amortize(kill_desire, adip->distance);
@@ -720,7 +720,7 @@
       if (ai->diplomacy.target != aplayer && 
           pplayer->ai.love[aplayer->player_no] < 0) {
         /* Give him a better chance for a cease fire */
-        pplayer->ai.love[aplayer->player_no] += 3;
+        pplayer->ai.love[aplayer->player_no] += 30;
       }
       PLAYER_LOG(LOG_DEBUG, pplayer, ai, "Reduced love for %s (now %d) ",
                  aplayer->name, pplayer->ai.love[aplayer->player_no]);
@@ -739,16 +739,16 @@
     pplayer->ai.love[aplayer->player_no] -=
       MIN(player_in_territory(pplayer, aplayer),
           pplayers_allied(aplayer, pplayer) ? 
-	    ai->diplomacy.love_incr - 1 : 50);
+	    ai->diplomacy.love_incr - 1 : 50) * 10;
 	  
     /* Massage our numbers to keep love and its opposite on the ground. 
      * Gravitate towards zero. */
     pplayer->ai.love[aplayer->player_no] -= 
        (pplayer->ai.love[aplayer->player_no] * ai->diplomacy.love_coeff / 100);
        
-    /* ai love should always be in range [-100..100] */
+    /* ai love should always be in range [-1000..1000] */
     pplayer->ai.love[aplayer->player_no] = 
-      MAX(-100, MIN(100, pplayer->ai.love[aplayer->player_no]));
+      MAX(-1000, MIN(1000, pplayer->ai.love[aplayer->player_no]));
   } players_iterate_end;
 
   /* Stop war against a dead player */
Index: ai/aidata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aidata.c,v
retrieving revision 1.37
diff -u -r1.37 aidata.c
--- ai/aidata.c	2 Sep 2004 20:51:48 -0000	1.37
+++ ai/aidata.c	13 Sep 2004 15:00:51 -0000
@@ -360,9 +360,9 @@
   ai->diplomacy.timer = 0;
   ai->diplomacy.countdown = 0;
   ai->diplomacy.love_coeff = 4; /* 4% */
-  ai->diplomacy.love_incr = 4;
-  ai->diplomacy.req_love_for_peace = 8;
-  ai->diplomacy.req_love_for_alliance = 16;
+  ai->diplomacy.love_incr = 40;
+  ai->diplomacy.req_love_for_peace = 80;
+  ai->diplomacy.req_love_for_alliance = 160;
   ai->diplomacy.req_love_for_ceasefire = 0;
   ai->diplomacy.alliance_leader = pplayer;
 
Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.150
diff -u -r1.150 player.c
--- common/player.c	29 Aug 2004 19:03:31 -0000	1.150
+++ common/player.c	13 Sep 2004 15:00:53 -0000
@@ -591,28 +591,28 @@
 **************************************************************************/
 const char *love_text(const int love)
 {
-  if (love <= -95) {
+  if (love <= -950) {
     return Q_("?attitude:Genocidal");
-  } else if (love >= -94 && love <= -71) {
+  } else if (love >= -949 && love <= -701) {
     return Q_("?attitude:Belligerent");
-  } else if (love >= -70 && love <= -51) {
+  } else if (love >= -700 && love <= -501) {
     return Q_("?attitude:Hostile");
-  } else if (love >= -50 && love <= -25) {
+  } else if (love >= -500 && love <= -251) {
     return Q_("?attitude:Uncooperative");
-  } else if (love >= -24 && love <= -11) {
+  } else if (love >= -250 && love <= -101) {
     return Q_("?attitude:Uneasy");
-  } else if (love >= -10 && love <= 10) {
+  } else if (love >= -100 && love <= 100) {
     return Q_("?attitude:Neutral");
-  } else if (love >= 11 && love <= 24) {
+  } else if (love >= 101 && love <= 250) {
     return Q_("?attitude:Respectful");
-  } else if (love >= 25 && love <= 50) {
+  } else if (love >= 251 && love <= 500) {
     return Q_("?attitude:Helpful");
-  } else if (love >= 51 && love <= 70) {
+  } else if (love >= 501 && love <= 700) {
     return Q_("?attitude:Enthusiastic");
-  } else if (love >= 71 && love <= 94) {
+  } else if (love >= 701 && love <= 949) {
     return Q_("?attitude:Admiring");
   } else {
-    assert(love >= 95);
+    assert(love >= 950);
     return Q_("?attitude:Worshipful");
   }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.