Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2003:
[Freeciv-Dev] (PR#6094) assert in path finding
Home

[Freeciv-Dev] (PR#6094) assert in path finding

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ue80@xxxxxxxxxxxxxxxxxxxxx, tomchance@xxxxxxx
Subject: [Freeciv-Dev] (PR#6094) assert in path finding
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 Sep 2003 20:11:37 -0700
Reply-to: rt@xxxxxxxxxxxxxx

[glip - Mon Sep 15 19:17:16 2003]:

> On Mon, 15 Sep 2003, Jason Short wrote:
> 
> > Per I. Mathisen wrote:
> > > On Mon, 15 Sep 2003, Gregory Berkolaiko wrote:
> > >
> > >>>2.You do calculations assuming a unit gets move_rate MP per turn,
> then
> > >>>finagle things at the end so less-than-zero values work out.I
> think
> > >>>the calculations should just account for the initial MP to begin
> with,
> > >>>although this does take more code changes.
> > >>
> > >>I don't see what you mean.With the changes the code correctly
> deals with
> > >>the case when initial MPs are bigger than move_rate.What else need
> to be
> > >>done?
> >
> > For the bulk of the calculations you assume that inital
> MP==move_rate.
> > Then at the end some extra calculations are done that fix any off-
> by-one
> > errors that may result.  This just doesn't seem right...
> 
> I still don't know what causes your unhappiness.  Can you point me to
> the
> places which you would like to see changed?  Alternatively, provide
> your
> own patch.

I do not know the PF code enough to make these changes.

But what I am saying is that when "negative cost" happens, that's not
because of bug in the calling code but a bug in the PF code.  The code
that generates the nodes assumes that the unit's moves_left <=
move_rate.  This is why we get negative costs, which must be accounted
for via off-by-one correction, rather than getting the correct costs.

I think with the correct cost get_turn would look something like:

  if (cost < pf_map->moves_left_initially)
    return 0;
  else
    return 1 + (cost - pf_map->moves_left_initially)
               / pf_map->params->move_rate;

Hmm, perhaps I should put it this way:

Under the current code having cost==0 means you arrive at the
destination this turn, with "full" MP.  Under my definition cost==0
means you arrive at the destination this turn, without expending any MP.

jason



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