Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: Cleaning up gotohand.c
Home

[Freeciv-Dev] Re: Cleaning up gotohand.c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Cleaning up gotohand.c
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 19 Sep 2001 13:52:31 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Wed, Sep 19, 2001 at 11:52:57AM +0100, Gregory Berkolaiko wrote:
>  --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: 
> > On Tue, Sep 18, 2001 at 10:49:39PM +0100, Gregory Berkolaiko wrote:
> > > 
> > > Very briefly (since I do not have the methods yet):
> > > warmap_next_position(&x, &y) returns locations in order of increasing
> > > distance from origin.  it's a wraper for get_from_queue actually.
> > 
> > I don't feel good to open such "internal" behavior/data structure. To
> 
> It is not much more open than it is now.  But far more flexible.
> Example: assume for trireme warmap you only want to consider tiles next
> to land.  Right now you cannot without changing generate_warmap routine
> and it takes awful time already, without having to check for weird
> trireme cases.
> 
> > me it looks like you have no plan what you in the surrounding
> > code. What is a certain tile is better even it is more far away?
> 
> If goodness of a tile depends on it's contents in a strong way, you would
> still generate the whole warmap.  But in routines like find_nearest_port,
> you would stop immediately after finding the nearest port, without having
> to waste CPU time.
> 
> > If I look at the structe of the SMA it is more like:
> >  - generate warmap
> >  - for every position reachable
> >    - compute a score/fitness based in the distance and the tile at the
> >      target position
> >  - choose best target position
> 
> It's good if you don't generate warmaps every 10 lines of code.
> 
> But the calculation like
> 
> generate_warmap
> whole_map_iterate{
>   evaluate_position(x,y); /* computes fitness */
> }
> 
> is ugly and unneccessary.  For an example see ai_manage_explorer.

It is an optimization. Correct? If this is done I want a nice
interface. You share some state over the function calls. This has to
be explicit IMHO. Another way is to give the generate_warmap a
callback which can return 1 to terminate the generating.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Just because you put a flag on the moon doesn't make it yours, it just
  puts a hole in the moon."


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