Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] Re: (PR#9887) AI defense code
Home

[Freeciv-Dev] Re: (PR#9887) AI defense code

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#9887) AI defense code
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Tue, 31 Aug 2004 11:38:10 -0700
Reply-to: rt@xxxxxxxxxxx

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

Here is another AI defense fix. If we are outside a city, a minimum of 10%
win chance is needed for rampage, if we are in one, we need a minimum of
20%. This stops the worst excesses of rampage to show itself, but rampage
is IMHO fundamentally broken in this regard, and the patch only stops the
worst excesses.

Thanks to Genevieve for providing savegames.

  - Per

Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.332
diff -u -r1.332 aiunit.c
--- ai/aiunit.c 31 Aug 2004 18:21:09 -0000      1.332
+++ ai/aiunit.c 31 Aug 2004 18:34:42 -0000
@@ -596,9 +596,12 @@
       int benefit = stack_cost(pdef);
       int loss = unit_build_shield_cost(punit->type);
       double chance = unit_win_chance(punit, pdef);
+      struct city *pcity = map_get_city(punit->x, punit->y);
 
-      if (chance < 0.005) {
-        /* Forget it! At least a tiny chance is needed here... */
+      if ((!pcity && chance < 0.1) || (pcity && chance < 0.2)) {
+        /* Forget it! At least a tiny chance is needed here... 
+         * This is a kludge to make up for some real braindamage 
+         * in the code below, that makes us go kamikaze. - Per */
         UNIT_LOG(LOG_DEBUG, punit, "Rampage: No chance against %s(%d,%d)!",
                  unit_name(pdef->type), pdef->x, pdef->y);
         return 0;

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