Newsgroups: comp.ai.games
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!godot.cc.duq.edu!newsgate.duke.edu!agate!sunsite.doc.ic.ac.uk!lyra.csx.cam.ac.uk!warwick!bsmail!zeus!biigb
From: biigb@zeus.bris.ac.uk (I.G.Badcoe)
Subject: Re: More shortest pathing
Message-ID: <Ds25tL.H6x@uns.bris.ac.uk>
Sender: usenet@uns.bris.ac.uk (Usenet news owner)
Nntp-Posting-Host: zeus.bris.ac.uk
Organization: University of Bristol, England
X-Newsreader: TIN [version 1.2 PL2]
References: <4o5kom$sf3@laurel.stud.phil.ruu.nl> <4o5vgr$f2e@tribune.concentric.net> <4o62r7$sjo@laurel.stud.phil.ruu.nl> <4o7bqb$4p5@tribune.concentric.net>
Date: Mon, 27 May 1996 09:46:33 GMT
Lines: 66

Hi guys,

Steven Woodcock (Swoodcoc@cris.com) wrote:
: Martijn Faassen (faassen@phil.ruu.nl) opined thusly:

:   You've hit upong the big bugaboo in pathing, the Evil U-Shaped Obstacle.
: It can really hose you.

:   One very clean heuristic is to weight your ants so that you examine
: the ones closest to the destination first.  That is, use a heuristic
: function h where

:     h(currow, curcol, destrow, destcol) {
:        return max(abs(currow - destrow), abs(curcol - destcol));
:     }

This begins to look like the A* search that so many folk have already
told us about.  If you were to put it in the ants algorithm it would
overcome another limitation that I think you (martijn) have which is
that you can only (at present) treat terrain as open or blocked.  You
cannot, for example, have a partially blocked type (say swamp) because
an ant is either on the list or it is not.  If the list were sorted,
however, you could include the cost of the terran crossed so far as well
as estimated distance from the goal in the sort criterion.  In which case
I think you would have a pure A* algorith (I think).

:     This way, ants farther away from the destination get saddled with
: a huge "weight" and thus get a lower priority for solution finding.
: Ants closer have a lighter "weight" and hence you'll look at them first.
: If there aren't any impassable obstacles, that means you tend to examine
: ants towards the destination first and find the solution faster.

:     But, of course, there's the Evil U.  Using this heuristic, you
: could cheerfully run down the map into the U and then "thrash" a bit as
: the algorithm examines nearly every single point around the area to try
: to get around it.  It will eventually exhaust all of those possibilities
: and fall back to more circumspect routes, and find the solution, but it
: will take longer in that case.

:     There are several ways around this.  You could build a secondary
: heuristic to try to track if you're stuck.

Or you could only sort the list in a 'probabilistic manner' so that the
closest ants get some priority but not a total monopoly.  This way if there
was a reasonably easy way around you'd have a good chance of evaluating one
of the ants near to it and letting it take over the head of the list.

On a different note, isn't all this talk of optimal and fastest path-finding
algorithms a little bit besides the point ?  Two reasons:

	Real beings don't use them !  They use simpler approaches like
assessing the locality and picking the direction that is most 'down hill' or
heading in the right direction until they get stuck and then trying to go
around the obstacle.

	However good your algorithm it will always be possible to construct
a terrain that it finds 'difficult'.  As an absolute proof visit Hampton-Court
Maze and try out your on-board software.

	Thus it might be 'more realistic' to accept that some terrains are hard
to cross and construct the game such that units getting stuck (or going the long
way around when it wasn't strictly necessary) is an expected occurence.

	Badders


