Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: Cache win_chance in get_defender(attacker) (PR#1269)
Home

[Freeciv-Dev] Re: Cache win_chance in get_defender(attacker) (PR#1269)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Cache win_chance in get_defender(attacker) (PR#1269)
From: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Date: Fri, 22 Feb 2002 21:22:45 +0000 (GMT)

 --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: 
> On Fri, Feb 22, 2002 at 08:33:18PM +0000, Gregory Berkolaiko wrote:
> >  --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: 
> > 
[...]
> > you asked whether win_chance can be used in findvictim
> > the answer is yes and it should be used but you can call win_chance or
> > get it from get_attacker or get_defender which would've computed it by
> now.
> 
> I just want that we thing about a good interface before we add some
> non-straightforward way to get an intermediate result for speed.
> 
> What about a function 
>   double win_chance_against_stack_at_tile(punit, target_x, target_y)
> ? This function would built on top of win_chance. This is IMHO also
> what we try here to approximate: unit against stack.

well, this would either repeat most of get_defender
or indeed call get_defender and then call win_chance which is precisely what I
am trying to avoid.

> > think about it a bit more
> > in my patch you are just passing back (optionally) a value that is already
> > there and can be used further, and discarding everything that is useless. 
> 
> > you are going to save result of every computation and then what, search
> > them?
> > you would index it by what?  pointers to units?  but units move and loose
> > health and get upgraded...
> 
> > altogether there are 6 parameters to real win_chance: (firepower, hp,
> > power)*2
> > some of them don't vary much, but some do.
> 
> But these 6 ints can form a key for a hash.

I am not too familiar with these things, but I think it would be hard on
memory or/and CPU when searching

> > in findvictim it would be used like this:
> > 
> > /* chances of our successful attack/defence */
> > int, att_chance;
> > 
> > patt = get_attacker(punit, , , &def_chance);
> > pdef = get_defender(punit, , , &att_chance);
> > 
> > ....
> > 
> > /* Consider defending */
> > if (map_get_city(x, y) && 
> >     def_chance > att_chance
> >     unit_list_size(&(map_get_tile(punit->x, punit->y)->units)) < 2 && 
> >     get_total_attack_power(patt, punit)) { 
> > 
> > Much nicer than the big inequality, isn't it.
> 
> Ack. But the way you got these values is ugly. For example you don't
> need the patt anymore.

true, true.
how about
        get_defender_and_chance(punit, x, y, &chance)
and 2 wrappers
        unit *get_defender(punit, x, y)
        double win_chance_against_stack_at_tile(punit, target_x, target_y)
?

but I do not think it's any good.  for once, you might still want the patt for
some other reasons (like it's build_cost)

So sorry, I still think my version is most flexible and short.

G.

__________________________________________________
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]