Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: [PATCH] aiunit.c ai_military_findvictim() cleanup (PR#
Home

[Freeciv-Dev] Re: [PATCH] aiunit.c ai_military_findvictim() cleanup (PR#

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Cc: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] aiunit.c ai_military_findvictim() cleanup (PR#1264)
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Wed, 20 Feb 2002 16:09:42 +0100

Dear diary, on Wed, Feb 20, 2002 at 03:51:47PM CET, I got a letter, where
Raahul Kumar <raahul_da_man@xxxxxxxxx> told me, that...
> > /me looks around in his mailbox..  /me sees nothing :(
> > 
> 
> Great explanation of the attack/defending formulas. You've really done some
> work on this.

I just stared at the code.. (Greg: and thought about it ;)

> > +        /* The possible loss when we would loose this unit. */
> > +        /* TODO: Possibly remove this when moving the desire equiation to
> > +         * separate function? */
> 
> Equation instead of equiation.

Thanks.

> > +        if (map_get_city(x1, y1)) {
> > +          benefit = (benefit + 40) * punit->hp / unit_type(punit)->hp;
> >          }
> > -      }
> > -    } else { /* no pdef */
> > -      pcity = map_get_city(x1, y1);
> > -      if (pcity && is_ground_unit(punit) &&
> > -          map_get_terrain(punit->x, punit->y) != T_OCEAN) {
> > -        if (pcity->owner != pplayer->player_no) { /* free goodies */
> > -          best = 99999; *dest_y = y1; *dest_x = x1;
> > +        
> > +        /* If we have non-zero belligerence... */
> > +        if (attack > 0 && is_my_turn(punit, pdef)) {
> > +          int desire;
> > +          
> > +          /* TODO: This equation is simplified version of much worse ones 
> > in
> > +           * that long fat routines, but it's still a common pattern, so we
> > +           * will can this equation to one separate readable function. */
> > +         
> > +          /*         attractiveness     danger */ 
> > +          desire = ((benefit * attack - loss * vuln) * SHIELD_WEIGHTING
> > +                    / (attack + vuln) - move_cost * SHIELD_WEIGHTING);
> > + 
> 
> The usage of move_cost. I do not see how the penalty for attacking with less
> than one movepoint left is represented in this formula.

There's really no usage of move_cost here. As few lines above mentioned,
move_cost is always zero here because we're always dealing only with adjectent
victims here (so we also have at least one movepoint left as well).

Typo fixed in attached patch.

-- 

                                Petr "Pasky" Baudis

* elinks maintainer                * IPv6 guy (XS26 co-coordinator)
* IRCnet operator                  * FreeCiv AI hacker
.
No one can feel as helpless as the owner of a sick goldfish.
.
Public PGP key && geekcode && homepage: http://pasky.ji.cz/~pasky/

Attachment: findvictim-cleanup.patch
Description: Text document


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