[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pathfinding



Complex distance evaluation isn't necessary, but the sprite never getting stuck is.

--- On Mon, 1/26/09, Joe Strout <joe@xxxxxxxxxx> wrote:

From: Joe Strout <joe@xxxxxxxxxx>
Subject: Re: [pygame] Pathfinding
To: pygame-users@xxxxxxxx
Date: Monday, January 26, 2009, 6:11 PM

Yanom Mobis wrote:

> it seems to me that A* only works on tile-based games.
> What if my game isn't tile-based?

I'm not sure you think that.  A* (or any other pathfinding algorithm) will work for any search tree.  You do need some sort of heuristic, though, that estimates how far any given position is from the goal. That's usually pretty easy though if "position" really corresponds in some way to a position in space -- just use the Euclidian distance to the goal as your heuristic.

Best,
- Joe