Complete.Org: Mailing Lists: Archives: freeciv-ai: August 2004:
[freeciv-ai] (PR#1340) [Bug][RFC] Stupid attack behaviour by AI
Home

[freeciv-ai] (PR#1340) [Bug][RFC] Stupid attack behaviour by AI

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [freeciv-ai] (PR#1340) [Bug][RFC] Stupid attack behaviour by AI
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxxx>
Date: Thu, 5 Aug 2004 06:39:14 -0700
Reply-to: rt@xxxxxxxxxxx

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

> [glip - Sat Mar 23 20:04:19 2002]:
> 
> Raahul Kumar drew my attention to this phenomenon: if you park your,
> say,
> phalanx on a wee mountain outside an AI city then from time to time
> the
> city's gates will burst open and AI will attack you with few phalanxes
> or
> similarly inefficient units.  Seemingly without any real desire to
> kill you...

[..]

> The problem lies in the lines:
> ==================================================
> 910         int vuln = unit_vulnerability(punit, pdef);
> 911         int attack = reinforcements_value(punit, pdef->x, pdef->y)
>                          + unit_belligerence_primitive(punit);
> 912         int benefit = unit_type(pdef)->build_cost;
> 913         int loss = unit_type(punit)->build_cost;
> ==================================================
> because reinforcements are counted in the attack but _not_ counted in
> the loss.

Upon some thought I decided that rampaging should not include any
reinforcements considerations at all.  Such considerations are made in
find_something_to_kill, where the loss is calculated correctly.

In the attached patch I remove reinforcements_value altogether.

G.
? log.txt
? log1.txt
? ttt.gz
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.323
diff -u -r1.323 aiunit.c
--- ai/aiunit.c 5 Aug 2004 10:41:33 -0000       1.323
+++ ai/aiunit.c 5 Aug 2004 13:11:56 -0000
@@ -847,19 +847,6 @@
   } square_iterate_end;
 }
 
-/**************************************************************************
-  Calculates the value and cost of nearby units to see if we can expect 
-  any help in our attack. Note that is includes the units of allied players
-  in this calculation.
-**************************************************************************/
-static int reinforcements_value(struct unit *punit, int x, int y)
-{
-  int val, cost;
-
-  reinforcements_cost_and_value(punit, x, y, &val, &cost);
-  return val;
-}
-
 /*************************************************************************
   Is there another unit which really should be doing this attack? Checks
   all adjacent tiles and the tile we stand on for such units.
@@ -895,7 +882,9 @@
 }
 
 /*************************************************************************
-  This function appraises the location (x, y) for a quick hit-n-run operation.
+  This function appraises the location (x, y) for a quick hit-n-run 
+  operation.  We do not take into account reinforcements: rampage is for
+  loners.
 
   Returns value as follows:
     -RAMPAGE_FREE_CITY_OR_BETTER    
@@ -923,9 +912,8 @@
     
     {
       /* See description of kill_desire() about these variables. */
-      int att_rating = unit_att_rating_now(punit);
+      int attack = unit_att_rating_now(punit);
       int vuln = unit_def_rating_sq(punit, pdef);
-      int attack = reinforcements_value(punit, pdef->x, pdef->y) + att_rating;
       int benefit = stack_cost(pdef);
       int loss = unit_build_shield_cost(punit->type);
       
@@ -942,7 +930,7 @@
       }
       
       /* If we have non-zero attack rating... */
-      if (att_rating > 0 && is_my_turn(punit, pdef)) {
+      if (attack > 0 && is_my_turn(punit, pdef)) {
         /* No need to amortize, our operation takes one turn. */
         return kill_desire(benefit, attack, loss, vuln, 1);
       }

[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-ai] (PR#1340) [Bug][RFC] Stupid attack behaviour by AI, Gregory Berkolaiko <=