Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: [Patch] Cleanup of attack power calculations
Home

[Freeciv-Dev] Re: [Patch] Cleanup of attack power calculations

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [Patch] Cleanup of attack power calculations
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 Feb 2002 15:30:53 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Tue, Feb 26, 2002 at 06:10:04AM -0800, Raahul Kumar wrote:
> --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> > On Tue, Feb 26, 2002 at 04:57:23AM -0800, Raahul Kumar wrote:
> > > <snip>
> > > > results: with -O2
> > > > 
> > > > integer (f1): 1.1s
> > > > float (f2):   6.6s
> > > >
> > > 
> > > Much bigger difference than I expected.
> > 
> > > If you want to continue on your floating point jehad.
> > 
> > I'm not on one.
> > 
> > > ai/advmilitary.c, line 728 -- if (do_make_unit_veteran(acity, n)) m *= 
> > > 1.5;
> > > ai/aicity.c, line 298 -- if (do_make_unit_veteran(pcity, d_type)) m *= 1.5
> > > ai/aiunit.c, line 1337 -- (do_make_unit_veteran(acity, n) ? 1.5 : 1) / 30;
> > > 
> > > There are some other 1.5's in the code.
> > 
> > We will see how many are left if the defence power calculation patch
> > is applied.
> 
> If? 

s/if/at the time/

> > > Moves_left keeps track of how many moves are left. If it declines from
> > > 3(SINGLE_MOVE) to 2, this function will calculate the haste penalty
> > correctly.
> > 
> > Ack.
> > 
> > > I don't see any code guaranteeing it will never go below SINGLE_MOVE.
> > 
> > I still not understand.
> 
> if (!unit_type_flag(type, F_IGTIRED) && moves_left < SINGLE_MOVE)
> {
>     power = (power * moves_left) / SINGLE_MOVE;
> }
> 
> The previous comment that you removed said that if moves_left == 1 or 2 that
> the result would be wrong. That isn't the case with the current code(maybe the
> comment was wrong before as well).
> 
> moves_left = 2
> 
> power =(power * moves_left)/ SINGLE_MOVE
> 
> That is the correct 2/3 penalty for attack power if the unit has only
> fractional move points left.  There is no issue here. The code is behaving
> correctly.

-  ptype = unit_type(punit);

-/* get_attack_power will be wrong if moves_left == 1 || == 2 */

This means for me: we can't use get_attack_power here because the
result will be wrong if moves_left<SINGLE_MOVE.

-  v = ptype->attack_strength * 10 * punit->hp * ptype->firepower;
-  if (punit->veteran) v += v/2;

+  v = unit_belligerence_basic(punit);

base_get_attack_power is called by base_unit_belligerence_primitive is
called by unit_belligerence_basic with moves_left=SINGLE_MOVE. This
means that in base_get_attack_power the reduction isn't made.

> > > > > >      v = myunit->type;
> > > v is hardly used. myunit->type can do the job.
> > 
> > I bet that someone has a cleanup (renaming/removing of variables,...) 
> > of this function which does this. If not you may start one.
> >
> 
> Petr has renamed a lot of variables. Any comments?

In kill_something_with?

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  "Windows is the one true OS. MS invented the GUI. MS invented 
   the 32 bit OS. MS is open and standard. MS loves you. We have 
   always been at war with Oceana."


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