Complete.Org: Mailing Lists: Archives: freeciv-ai: May 2003:
[freeciv-ai] Re: (PR#4026) Advanced rampage.
Home

[freeciv-ai] Re: (PR#4026) Advanced rampage.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [freeciv-ai] Re: (PR#4026) Advanced rampage.
From: "Olivier DAVY" <olivier.davy@xxxxxxx>
Date: Fri, 9 May 2003 00:32:55 -0700
Reply-to: rt@xxxxxxxxxxxxxx

En réponse à "jorneg@xxxxxxxxxxx" <jorneg@xxxxxxxxxxx>:

> En/na Gregory Berkolaiko ha escrit:
> 
> >
> /*************************************************************************
> >-This function looks at tiles adjacent to the unit in order to find
> something
> >-to kill or explore.  It prefers tiles in the following order:
> >-
> >-Returns value of the victim which has been chosen:
> >-
> >-99999    means empty (undefended) city
> >-99998    means hut
> >-2..99997 means value of enemy unit weaker than our unit
> >-1        means barbarians wanting to pillage
> >-0        means nothing found or error
> >--2*MORT*TRADE_WEIGHTING
> >-         means nothing found and punit causing unhappiness
> >+  This function appraises the location (x, y) for a quick hit-n-run
> operation.
> > 
> >-If value <= 0 is returned, (dest_x, dest_y) is set to actual punit's
> position.
> >+  Returns value as follows:
> >+    -RAMPAGE_ONLY_FREE_CITY    
> >+             means undefended enemy city
> >+    -RAMPAGE_HUT_OR_BETTER    
> >+             means hut
> >+    RAMPAGE_BETTER_THAN_PILLAGE ... RAMPAGE_HUT_OR_BETTER - 1  
> >+             is value of enemy unit weaker than our unit
> >+    -(RAMPAGE_BETTER_THAN_PILLAGE - 1)        
> >+             means barbarians wanting to pillage
> >+    0        means nothing found or error
> >+  Here the minus indicates that you need to enter the target tile (as
> 
> >+  opposed to attacking it, which leaves you where you are).
> >
> **************************************************************************/
> >-static int ai_military_findvictim(struct unit *punit, int *dest_x, int
> *dest_y)
> >+static int ai_rampage_want(struct unit *punit, int x, int y)
> > {
> >   struct player *pplayer = unit_owner(punit);
> >-  int attack_power = unit_att_rating_now(punit);
> >-  int x = punit->x, y = punit->y;
> >-  int best = 0;
> >-  int stack_size = unit_list_size(&(map_get_tile(punit->x,
> punit->y)->units));
> >+  struct unit *pdef = get_defender(punit, x, y);
> > 
> >   CHECK_UNIT(punit);
> >+  
> >+  if (pdef) {
> >+    
> >+    if (!can_unit_attack_tile(punit, x, y)) {
> >+      return 0;
> >+    }
> >+    
> >+    {
> >+      /* See description of kill_desire() about these variables. */
> >+      int att_rating = unit_att_rating_now(punit);
> >+      int vuln = unit_vulnerability(punit, pdef);
> >+      int attack = reinforcements_value(punit, pdef->x, pdef->y) +
> att_rating;
> >+      int benefit = stack_cost(pdef);
> >+      int loss = unit_type(punit)->build_cost;
> >+      
> >+      attack *= attack;
> >+      
> >+      /* If the victim is in the city, we increase the benefit and
> correct
> >+       * it with our health because there may be more units in the
> city
> >+       * stacked, and we won't destroy them all at once, so in the
> next
> >+       * turn they may attack us. So we shouldn't send already
> injured
> >+       * units to useless suicide. */
> >+      if (map_get_city(x, y)) {
> >+        /* A WAG for the city value */
> >+        benefit += unit_value(get_role_unit(F_CITIES, 0));
> >+        benefit = (benefit * punit->hp) / unit_type(punit)->hp;
> >+      }
> >
>     Why not check here if there is a fortress?
> 
 OR an airbase ? (is_stack_vulnerable of common/combat.c) ?



---------------------------------------
 Olivier DAVY
 ENSIMAG engineer - HEC alumnus
 E-mail : olivier.davy@xxxxxxx
 Phone  : +33/(0)1.42.67.19.85
---------------------------------------



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