Complete.Org: Mailing Lists: Archives: freeciv-dev: September 1999:
[Freeciv-Dev] Re: code optimization ideas
Home

[Freeciv-Dev] Re: code optimization ideas

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Peter Schaefer <schaefer@xxxxxx>
Cc: Freeciv Development <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: code optimization ideas
From: Tony Stuckey <stuckey@xxxxxxxxxxxxxxxxx>
Date: Wed, 22 Sep 1999 16:34:03 -0500

On Wed, Sep 22, 1999 at 10:02:26PM +0200, Peter Schaefer wrote:
> About the intention of the patch .. 
> I noticed there is a get_map_tile / adjust(x)*ymax+y cache ..
> Does it really help ? I'm more in favor of caching the information in the 
> functions
> that call get_map_tile, or even caching the value of adjust(x)*ymax+y in the 
> unit itself -
> having both the tile cache in get_map_tile and in the unit is no good idea 
> IMHO .
> 
> I'm also not sure caching everything everywhere is a good idea ?!
> Like the tile in the unit, and the x y in the tile .. .
> 
> Also do not most of the calls to get_map_tile come from pathfinding ?
> How about putting the terrain into an array all by itself,
> and putting the stuff not needed by pathfind elsewhere ?
> This would increase cache hits by only accesing the memory needed by the 
> pathfind .. maybe .. .

        One problem is that a lot of the code is just stupid.
        It will go to 13,27 and look at all 8 surrounding tiles.  Then it
will go to 13,28 and look at all 8 surrounding tiles, many of which were
just looked at.  Sometimes this happens multiple times.  This definitely
happens in the pathfinding stuff, where calls to "is_enemy_unit_tile" and
similar stuff *have* to be done to check ZOC issues when trying to move
around.

        It's not clear to me that caching this data provides a real win,
though, without making the code massively more convoluted.  Some of it is
already convoluted enough to be scary.

        The real-time nature of the game doesn't help.  If Freeciv were
strictly turn-based as all other Civs were, most of these issues would only
change when you successfully attacked and killed an enemy.  As it is, a lot
of calculations must be performed for each unit, because the world might
have changed unexpectedly around you.

        More efficient high-level algorithms are appreciated.  But they're
not going to be easy to come up with.
-- 
Anthony J. Stuckey                              stuckey@xxxxxxxxxxxxxxxxx
"When I was young, the sky was filled with stars.
 I watched them burn out one by one."  -Warren Zevon

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