<URL: http://bugs.freeciv.org/Ticket/Display.html?id=34073 >

 This adds new AI handicap, H_DANGER. It causes AI to always cosider
all it cities to be in grave danger. This causes it to spend some
resources to unnecessary defense instead of expansion. Handicap is
given to novice level AI. Maybe it should go in for easy AI as well?
 Plan is to commit this also to S2_1.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/advmilitary.c freeciv/ai/advmilitary.c
--- freeciv/ai/advmilitary.c	2007-01-13 18:55:20.000000000 +0200
+++ freeciv/ai/advmilitary.c	2007-01-19 15:09:14.000000000 +0200
@@ -467,7 +467,12 @@
 
   generate_warmap(pcity, NULL);	/* generates both land and sea maps */
 
-  pcity->ai.grave_danger = 0;
+  if (ai_handicap(pplayer, H_DANGER)) {
+    /* Always thinks that city is in grave danger */
+    pcity->ai.grave_danger = 1;
+  } else {
+    pcity->ai.grave_danger = 0;
+  }
   pcity->ai.diplomat_threat = FALSE;
   pcity->ai.has_diplomat = FALSE;
 
@@ -594,7 +599,14 @@
 	urgency, danger[1], assess_defense_igwall(pcity));
   }
 
-  pcity->ai.danger = danger[0];
+  if (ai_handicap(pplayer, H_DANGER)
+      && danger[0] == 0) {
+    /* Has to have some danger
+     * Otherwise grave_danger will be ignored. */
+    pcity->ai.danger = 1;
+  } else {
+    pcity->ai.danger = danger[0];
+  }
   pcity->ai.urgency = urgency;
 
   TIMING_LOG(AIT_DANGER, TIMER_STOP);
diff -Nurd -X.diff_ignore freeciv/common/player.h freeciv/common/player.h
--- freeciv/common/player.h	2006-07-17 23:56:46.000000000 +0300
+++ freeciv/common/player.h	2007-01-19 14:51:44.000000000 +0200
@@ -55,7 +55,8 @@
   H_MAP = 1024,       /* Only knows map_is_known tiles */
   H_DIPLOMACY = 2048, /* Not very good at diplomacy */
   H_REVOLUTION = 4096, /* Cannot skip anarchy */
-  H_EXPANSION = 8192 /* Don't like being much larger than human */
+  H_EXPANSION = 8192, /* Don't like being much larger than human */
+  H_DANGER = 16384    /* Always thinks its city is in danger */
 };
 
 BV_DEFINE(bv_player, MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS);
diff -Nurd -X.diff_ignore freeciv/server/stdinhand.c freeciv/server/stdinhand.c
--- freeciv/server/stdinhand.c	2007-01-17 13:38:21.000000000 +0200
+++ freeciv/server/stdinhand.c	2007-01-19 14:53:15.000000000 +0200
@@ -682,7 +682,8 @@
                         | H_REVOLUTION,
  /* novice */   H_RATES | H_TARGETS | H_HUTS | H_NOPLANES 
                         | H_DIPLOMAT | H_LIMITEDHUTS | H_DEFENSIVE
-			| H_DIPLOMACY | H_REVOLUTION | H_EXPANSION,
+			| H_DIPLOMACY | H_REVOLUTION | H_EXPANSION
+                        | H_DANGER,
  /* easy */	H_RATES | H_TARGETS | H_HUTS | H_NOPLANES 
                         | H_DIPLOMAT | H_LIMITEDHUTS | H_DEFENSIVE
                         | H_REVOLUTION | H_EXPANSION,
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to