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: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: Raahul Kumar <raahul_da_man@xxxxxxxxx>, 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 20:49:26 +0100

Dear diary, on Wed, Feb 20, 2002 at 08:12:06PM CET, I got a letter,
where Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> told me, that...
> On Wed, Feb 20, 2002 at 04:09:42PM +0100, Petr Baudis wrote:
> > Typo fixed in attached patch.
> 
> >  /*************************************************************************
> > -This looks at tiles neighbouring the unit to find something to kill or
> > -explore. It prefers tiles in the following order:
> > +This function looks at tiles directly neighbouring the unit in order to 
> > find
> > +something to kill or explore.  It prefers tiles in the following order:
> > +
> >  1. Undefended cities
> >  2. Huts
> >  3. Enemy units weaker than the unit
> >  4. Land barbarians also like unfrastructure tiles (for later pillage)
> > -If none of the following is there, nothing is chosen.
> >  
> > -work of Syela - mostly to fix the ZOC/goto strangeness
> 
> > +If none of the following is there, nothing is chosen.
> 
> How can the caller distinguish this? What does the function return?

best <= 0 and {dest_x, dest_y} == {punit->x, punit->y}

Good idea, I extended the comment.

> > -  if (get_transporter_capacity(punit)) {
> > -    unit_list_iterate(map_get_tile(x, y)->units, aunit)
> > -      if (!is_sailing_unit(aunit)) return(0);
> > -    unit_list_iterate_end;
> > -  } /* ferryboats do not attack.  no. -- Syela */
> > +  
> 
> > +  /* Ferryboats with passengers do not attack. -- Syela */
> > +  if (punit->ai.passenger > 0) {
> > +    return 0;
> > +  }
> 
> Are you sure that these are equivalent?

Not 100%, still didn't manage to run that promised tests :-).

> > +          benefit = (benefit + 40) * punit->hp / unit_type(punit)->hp;
> 
> What is that 40?

Just magic value of city. It's used as this very frequently (I'm not sure that
equal value for city walls is absolute coincidence ;).

This would be nice to have as some #define or at least mentioned in README_AI.
Someone promised to extend it. Who was it? Raahul?

> > +        SET_BEST(99999);
> ...
> > +      if (map_has_special(x1, y1, S_HUT) && best < 99999
> > +          && could_unit_move_to_tile(punit, punit->x, punit->y, x1, y1) != > > 0
> > +          && !is_barbarian(unit_owner(punit))
> > +          && punit->ai.ai_role != AIUNIT_ESCORT
> > +          && punit->ai.charge == 0 /* Above line doesn't seem to work. :( 
> > */
> > +          && punit->ai.ai_role != AIUNIT_DEFEND_HOME) {
> > +        SET_BEST(99998);
> > +      }
> 
> These 9999* are ugly.

And what shall we do with them..?

Improved patch attached.

-- 

                                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]