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 18:17:24 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Wed, Apr 10, 2002 at 04:47:46PM +0100, Gregory Berkolaiko wrote:
> On Wed, 10 Apr 2002, Raimar Falke wrote:
> 
> > 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.
> 
> Raimar, it would really help if you occasionally read the questions before 
> writing the answer.  Please answer the original question.

Sorry I misread it. The example I posted makes it quite clear:

  map = pf_get_map(parameter);
  do {
     struct pf_path path;

     pf_get_next_path_from_map(map, &path);

     if(!path.found_a_valid) {
       break;
     }

     check_position_xy_for_something(LAST_POSITION(&path));
  } while (position_is_relevant(path));

  pf_destroy_map(map);

> > > Is it just very expensive version of my get_next_location?
> 
> And this one.  I mean: does get_next_path actually returns a path?

It does the same as get_next_location AFAI can say this at this
point. Yes it returns the path from the start to the current
position. So in essence:
 get_next_location == LAST_POSITION(pf_get_next_path_from_map)

> > 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.
> 
> how will get_path do it?

pf_get_path_from_map is an optimized version of:

  forever:
    path=pf_get_next_path_from_map
    if !path.is_valid: 
      return path
    if LAST_POS(path) == destination:
      return path
    
        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 Windows: Where do you want to go today?
 Linux: Where do you want to go tomorrow?
 BSD: Are you guys coming or what?


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