(PR#10146) new handicap: H_DIPLOMACY

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

Also make novice AI player less agressive against human players.
--
mateusz
h_diplomacy2.diff (text/x-patch, 3.3 KB)
? freeciv.spec
? ai/test
? client/civgame-3950.sav.gz
? server/civgame-3700.sav.gz
? server/civgame-3900.sav.gz
? server/civgame-3950.sav.gz
? server/freeciv_user_database
Index: ai/advdiplomacy.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdiplomacy.c,v
retrieving revision 1.42
diff -u -r1.42 advdiplomacy.c
--- ai/advdiplomacy.c	17 Sep 2004 08:35:14 -0000	1.42
+++ ai/advdiplomacy.c	17 Sep 2004 17:32:59 -0000
@@ -372,7 +372,12 @@
       /* Very silly algorithm 1: Sea map more worth if enemy has more
          cities. Reasoning is he has more use of seamap for settling
          new areas the more cities he has already. */
-      worth -= 25 * city_list_size(&aplayer->cities);
+      worth -= 15 * city_list_size(&aplayer->cities);
+
+      /* Make maps from novice player cheap */
+      if (ai_handicap(pplayer, H_DIPLOMACY)) {
+        worth /= 2;
+      }
     }
     break;
 
@@ -383,10 +388,14 @@
     } else {
       /* Very silly algorithm 2: Land map more worth the more cities
          we have, since we expose all of these to the enemy. */
-      worth -= 75 * MAX(city_list_size(&pplayer->cities), 3);
+      worth -= 50 * MAX(city_list_size(&pplayer->cities), 3);
       /* Inflate numbers if not peace */
       if (!pplayers_in_peace(pplayer, aplayer)) {
-        worth *= 3;
+        worth *= 4;
+      }
+      /* Make maps from novice player cheap */
+      if (ai_handicap(pplayer, H_DIPLOMACY)) {
+        worth /= 6;
       }
     }
     break;
@@ -654,6 +663,11 @@
                         * pplayer->ai.love[aplayer->player_no] 
                         / 2000);
 
+  /* Make novice AI more peaceful for human players */
+  if (ai_handicap(pplayer, H_DIPLOMACY) && !aplayer->ai.control) {
+    kill_desire = kill_desire / 2 - 10;
+  }
+
   /* Amortize by distance */
   return amortize(kill_desire, adip->distance);
 }
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.126
diff -u -r1.126 player.h
--- common/player.h	17 Sep 2004 08:35:14 -0000	1.126
+++ common/player.h	17 Sep 2004 17:33:01 -0000
@@ -53,7 +53,8 @@
   H_HUTS = 128,       /* Doesn't know which unseen tiles have huts on them */
   H_FOG = 256,        /* Can't see through fog of war */
   H_NOPLANES = 512,   /* Doesn't build air units */
-  H_MAP = 1024        /* Only knows map_is_known tiles */
+  H_MAP = 1024,       /* Only knows map_is_known tiles */
+  H_DIPLOMACY = 2048  /* Not very good at diplomacy */
 };
 
 struct player_economic {
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.350
diff -u -r1.350 stdinhand.c
--- server/stdinhand.c	17 Sep 2004 03:37:10 -0000	1.350
+++ server/stdinhand.c	17 Sep 2004 17:35:35 -0000
@@ -620,7 +620,8 @@
   int h[11] = { -1,
 		H_AWAY,
  /* novice */   H_RATES | H_TARGETS | H_HUTS | H_NOPLANES 
-                        | H_DIPLOMAT | H_LIMITEDHUTS | H_DEFENSIVE,
+                        | H_DIPLOMAT | H_LIMITEDHUTS | H_DEFENSIVE
+			| H_DIPLOMACY,
  /* easy */	H_RATES | H_TARGETS | H_HUTS | H_NOPLANES 
                         | H_DIPLOMAT | H_LIMITEDHUTS | H_DEFENSIVE,
 		H_NONE,
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.