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: Petr Baudis <pasky@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] aiunit.c ai_military_findvictim() cleanup (PR#1264)
From: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Date: Mon, 18 Feb 2002 12:53:57 +0000 (GMT)

 --- Petr Baudis <pasky@xxxxxxxxxxx> wrote: 
> Dear diary, on Sun, Feb 17, 2002 at 10:53:11PM CET, I got a letter, where
> > > 
> > > Perfectly valid point. Let's have a looook... <hours are passing ;>...
> > > Well, how are represented the passengers of a ferry? The actual code
> > > appears as buggy to me, as it produces wrong results when there're more
> > > boats at one tile, one loaded and one empty (and we're the empty one).
> > > [NOT FIXED]
> > 
> > sure, it is buggy.  maybe you can write a better one?
> 
> I was asking just for a hint how passengers are represented in struct unit
> (ai.passenger can contain only ONE unit_id) - I'm now too tired to run more
> research in this area. Ok, I'll try tommorow if I'll get a moment.

truth is, I don't know :(  I thought you do...

> > well, think about this: will a unit ever do pillage??  here we are
> > considering moving to a tile (x1,y1) to do pillage.  what happens when we
> > arrive there?  do you think it will remember what it wanted on this tile?
> 
> Pillage seems to be default activity for barbarians. See
> ai_military_findjob().

Ah, there you go, so consider_pillaging(x,y,punit) would be useful there too.


> > > +      /* If we are in the city, let's deeply consider defending it. See
> > > patt's
> > > +       * comment for details about the big unequality. */
> > 
> > You call that explanation????
> 
> I do. I really can't imagine what better you want. Can you please give me an
> example?
> 
> > This is just a statement of intent.  Explanation would explain _why_ these
> > particular values are compared!
> 
> Imagine multiple units on one tile as one big unit. Then its defense factor
> can be taken as defense factor of best defense unit there, and it attack
> factor as attack factor of best attack unit there.

Yep, that is clear.
But why this values are multiplied, why in such particular way, why firepower
is not taken into account, why health is not taken into account, why if the
inequality is satisfied we would better be defending?  A lot of question if
you think about it instead of just staring at it.

To put it another way: if you were asked this is your unit and these are two
enemy units, patt is bodyguarded by pdef.  Would you attack them or would you
defend?  How would you put this in code and why?

> > If you don't know, just say it (not in the code though ;).  I don't know.
> 
> I think it's relatively straightforward when you stare at it sufficiently
> enough.  Could be that I stared from a wrong angle, though.
> 
> > But I have strong suspicion that this inequality is _wrong_ :
> > 
> > get_total_defense_power(pdef, punit) * get_total_defense_power(punit,
> pdef) 
> > >= 
> > get_total_attack_power(patt, punit) * get_total_attack_power(punit, pdef)
> > 
> > It should have get_total_defense_power(patt, punit), not (pdef,punit).
> 
> Nope. BEST DEFENSE unit on the tile defends.

Mmm, you haven't looked at the argument list of get_total_defense_power, have
you?

> > > +      if (map_get_city(x, y)
> > > +          && get_total_defense_power(pdef, punit) *
> > > +             get_total_defense_power(punit, pdef) >= /* didn't like >
> --
> > > Syela */
> > > +             get_total_attack_power(patt, punit) *
> > > +             get_total_attack_power(punit, pdef)
> > > +          && unit_list_size(&(map_get_tile(punit->x, punit->y)->units))
> < 2
> > > +          && get_total_attack_power(patt, punit) > 0) {
> > > +        freelog(LOG_DEBUG, "%s defending %s from %s's %s",
> > > +                unit_type(punit)->name,
> > > +                map_get_city(x, y)->name,
> > > +                unit_owner(pdef)->name, unit_type(pdef)->name);
> > > +        
> > 
> > ugh, my head is killing me
> > time to go to sleep...
> 
> Good nite and sweet patt/pdef dreams.. ;)

I think I found the explanation for the formula :)
I will write it later today...

Best,
G.

P.S. Sorry if I am too unpolite at times...  I don't ever mean to offend.

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


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