Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2002:
[Freeciv-Dev] Re: [RFC] Path finding interface
Home

[Freeciv-Dev] Re: [RFC] Path finding interface

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [RFC] Path finding interface
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 10 Apr 2002 15:24:47 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Wed, Apr 10, 2002 at 12:14:44PM +0100, Gregory Berkolaiko wrote:
> Read your latest path_finding3.h
> Still not sure how get_next_path is supposed to be used?

You have the source and the destination. You pass the source to
pf_get_map and the destination to pf_get_path_from_map. From
pf_get_path_from_map you will get the path. After this you destroy the
map.

> Is it just very expensive version of my get_next_location?

It will calculate the complete path from source to destination. This
is usually more expensive than a call the iterator function
pf_get_next_path_from_map.

> Is the map supposed to be ready by the time you call it?

The map is constructed lazy. This means that pf_get_map will do no
calculation and only setup the internal structs. Lets call one loop
iteration of "while (get_from_mapqueue(&x, &y)) {" in
really_generate_warmap an step. Than pf_get_path_from_map will execute
as many steps as nessary to reach the
destination. pf_get_next_path_from_map will do one step.

You can do multiple calls of pf_get_path_from_map against the same
map. This will be faster (if they share sub-paths).

You can do multiple calls of pf_get_next_path_from_map against the
same map. After this you may also call pf_get_path_from_map multiple
times against the same map.

really_generate_warmap will calculate everything if it is called. This
is necessary since you later just access the data and there is no way
to intercept access to data which isn't calculated yet. Bad global
variables. You and also the original author came to the conclusion
that this is overkill and an iterator approach would be nice. I
provide provide iterators not only for one step but also for multiple
targets. Just thing of this example: you have a settler which want
itself to add to some city. You have the start position and multiple
destinations on the same continent. You don't have to calculate all
costs to reach all tiles of the continent. You may use the simple
iterator but pf_get_path_from_map will do this for you.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  The trick is to keep breathing.


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