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: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Cache win_chance in get_defender(attacker) (PR#1269)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 22 Feb 2002 20:16:37 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Fri, Feb 22, 2002 at 10:00:31AM -0800, Gregory Berkolaiko wrote:
>  --- Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx> wrote: 
> >  --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: 
> > > On Fri, Feb 22, 2002 at 03:34:10PM +0100, Petr Baudis wrote:
> > > 
> > > > +             get_total_attack_power(patt, punit) *
> > > > +             get_total_attack_power(punit, pdef)
> > > 
> > > Can't this test be replaced with win_chance?
> > 
> > Mmmm, I got so carried away with the idea that win_chance takes too much
> > CPU,
> > that I didn't notice that here it won't be more costly...
> > 
> > If, that is, we modify get_attacker and get_defender slightly to cache the
> > value of the winchance.  Because all win probabilities were already computed
> > in there.
> 
> And a patch to enable this.
> 
> This will pave a road for a very simple patch which will make autoattack
> _significantly_ better.
> 
> Of course we don't have to cache the win_chance but it is a big fat function
> to call (and we would need to call it if we want to get the attack profit
> equation absolutely right).

How will this be used? I don't see this from the patch.

If I would do such thing I would do it different from this.

I would make a cache indexed by the arguments of win_chance and place
the cache (using a hash) manage code in win_chance. This would provide
a transparent benefit for all. First and foremost however some
profiling has to be made. I haven't done profiling in a long time.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "I haven't lost my mind - it's backed up on tape somewhere."


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