Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2003:
[Freeciv-Dev] Re: (PR#2370) Path finding
Home

[Freeciv-Dev] Re: (PR#2370) Path finding

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>
Cc: Freeciv Development List <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: (PR#2370) Path finding
From: Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
Date: Wed, 19 Feb 2003 22:29:53 +0100

> > > > About the known-management: if we remove it from the core code:
> > > >  - it will reduce the number of parameters
> > > >  - it will reduce the size of the cell/node
> > > 
> > > true.  Less memory -- faster.
> > > 
> > > >  - it will increase run-time because of extra function calls to
> > > >  map_get_known by the user functions.
> > 
> > > mind you, caching can still be done through void *data parameter.
> > > We can pass pointer to caching map.
> > 
> > Can you explain more?
> 
> we make
> struct cached_values {
>       int is_initialized;
>       int known;
>       int zoc_number;
>       int behavior;
> }
> 
> then 
> struct last_arg {
>       struct player *owner;
>       struct cached_values *vals;
> } cache;
> 
> and then do (at fill_parameter time)
> 
> cache.vals = fc_calloc(...)
> 
> get_BMC_data = &cache;
> get_ECOT_data = &cache;
> 
> then inside, say, get_BMC, we do 
> 
> if (!data->vals[index].is_init) {
>       data->vals[index].known = is_known_tile(x, y, owner);
>       // .....
> }
> 
> if (data->vals[index].known == TILE_UNKNOW) {
>       return 0;
> }
> 
> Almost the same as we have now, just done in callbacks themselves.

And what if a user want to cache the is-coastal state? If we limit
this to the above mentioned fields we can do in common code.

        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]