From - Fri Apr  9 13:21:52 1999
Path: news.theplanet.net!diablo.theplanet.net!newspeer.monmouth.com!cyclone.bc.net!torn!newshost.uwo.ca!usenet
From: Aquamarine Dragon <jdrexler@julian.uwo.canada>
Newsgroups: rec.games.computer.ultima.dragons
Subject: Re: Pathfinding like in U7
Date: 8 Apr 1999 18:00:30 GMT
Organization: -= UDIC =-
Lines: 37
Sender: drexler@barney.physics.uwo.ca
Message-ID: <7eiqru$5bc@falcon.ccs.uwo.ca>
References: <370CD7A4.29C8EB61@usa.net>
NNTP-Posting-Host: barney.physics.uwo.ca
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Newsreader: knews 0.9.7
Xref: news.theplanet.net rec.games.computer.ultima.dragons:96752

In article "Pathfinding like in U7", Joseph 'DOUG' Morris writes: 
>  
> In Ultima 7, if you double-right click on a position, the Avatar will 
> automatically find a route to this point avoiding all obstacles. 
> 
> Even if you use hackmover to rearrange the walls he always finds the
> optimum route. 
> 
> Does anyone have an algorithm to do this as efficiently as U7? 

I'm not sure if this is the most efficient algorithm, but it is pretty fast
and rather easy too implement as well.
You just have to use the "running water" implementation to solve a
labyrinth. You start pouring water at the starting position, and every
iteration it moves in every possible direction. You just have to memorize
the path of every drop, and as soon as one drop hits the target, you know
the shortest path.

I don't know much about IRE, but if you have a fixed step size as in U7 (as
opposed to maybe U9), the number of "drops" you need it rather small, and
you can do this even without recursion. Just remember that when a drop hits
a point where another drop has been before, you can let it die, which limits
the maximum number of dots to basically 2*pi*r/r0, where r is the distance
between the points, and r0 is the step size. The history of each drop can
get quite large, though.

I once had an implementation of this in Pascal, maybe if you're interested I
can check if I still have it somewhere.

-- 
Josef Drexler, Aquamarine Dragon (UDIC) | http://publish.uwo.ca/~jdrexler 
--------------------------------------------------------------------------
d++ e- N++ T-- Om++ U1234!56!7'!S'!8!KA!L!WM! u++ uC++ uF++ uG++++ uLB+ uA 
nC+ nH+ nP++ nI nPT nS++ nT+ y+ a24
--------------------------------------------------------------------------
  Conscience is what hurts when   |  In order to email me, please replace
  everything else feels so good.  |  .canada with .ca - Death to Spammers!
