Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Review of Greg's firepower patch
Home

[Freeciv-Dev] Review of Greg's firepower patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>
Cc: kaufman@xxxxxxxxxxxxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Review of Greg's firepower patch
From: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Date: Tue, 12 Mar 2002 06:41:20 -0800 (PST)

--- Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx> wrote:
> On Tue, 12 Mar 2002, Raahul Kumar wrote:
> 
> > 
> > --- Mike Kaufman <kaufman@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> > > would you please review Markus Linnala's set of patches and Greg's 1293?
> > > 
> > 
> > I need that firepower patch Greg. 
> 
> http://arch.freeciv.org/freeciv-dev-200203/msg00107.html
> 
> 

I believe Greg is right about the original being bugged. I vote for inclusion.
I dissected and compared the original to the replacement below. It does not
make
any sense to ignore firepower for this calc. Possibly a leftover from Civ 1
rules.

RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.183
diff -u -r1.183 aiunit.c
--- ai/aiunit.c 2002/03/01 14:07:28     1.183
+++ ai/aiunit.c 2002/03/02 19:05:05
@@ -1097,13 +1097,14 @@
   if (!(dest_x == x && dest_y == y)) {
 
 /* do we require protection? */
-    d_val = stack_attack_value(dest_x, dest_y) * 30; 

That 30 turns up in POWER_DIVIDER, so that is fine.

+    d_val = stack_attack_value(dest_x, dest_y);
     if ((dcity = map_get_city(dest_x, dest_y))) {
       d_type = ai_choose_defender_versus(dcity, punit->type);

[Behaviour change]

-      d_val += base_get_attack_power(d_type,
-                                    do_make_unit_veteran(dcity, d_type),
-                                    SINGLE_MOVE) * unit_types[d_type].hp;

That is defined as.

Old version:

int base_get_attack_power(Unit_Type_id type, bool veteran, int moves_left)
 {
int power;
power = get_unit_type(type)->attack_strength * POWER_FACTOR;
if (veteran) {
/* Veterans get +50% bonus. */
power = (power * 3) / 2;
 }
if (!unit_type_flag(type, F_IGTIRED) && moves_left < SINGLE_MOVE) {
power = (power * moves_left) / SINGLE_MOVE;
 }
return power;
 }



Greg's version:

int base_unit_belligerence_primitive(Unit_Type_id type, bool veteran,
int moves_left, int hp)
{
return (base_get_attack_power(type, veteran, moves_left) * hp *
get_unit_type(type)->firepower / POWER_DIVIDER);
}

The only difference is that we end up taking into consideration the enemy units
firepower. Greg is correct. The old version was bugged. This is a behaviour
change, but for the better.


+      d_val += 
+       base_unit_belligerence_primitive(d_type, do_make_unit_veteran(dcity, 
d_type),

+                                        SINGLE_MOVE, unit_types[d_type].hp);
     }

[Behaviour change]

+    d_val *= POWER_DIVIDER;
     d_val /= (unit_type(punit)->move_rate / SINGLE_MOVE);
     if (unit_flag(punit, F_IGTER)) d_val /= 1.5; 

Should be (d_val * 3) /= 2. 
     

freelog(LOG_DEBUG,



__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Review of Greg's firepower patch, Raahul Kumar <=