Advertisement

will 32X32's tileset pathfinding cost two much cpu time?

Started by June 29, 2006 08:11 PM
6 comments, last by SmokingMan 18 years, 4 months ago
I am going to use A* pathfinding in my game, and divide the map into 32X32 tiles. I wonder if I should set the dividing more or less?
If a granularity of 32x32 is enough for you, go for it. If later on you find out you're wasting too much time on your pathfinding, then I'd advise using another structure, either group tiles into a quad tree or even use a POV algo to reduce the amount of nodes you have.

Anyway, 32x32 shouldn't be too much.

Cheers
Advertisement
32x32 is nothing in modern terms. You can probably path through that with a simple BFS and not notice any slow down.
I'm not sure whether it uses map tiles as pathing nodes, but in Warcraft 3 a map 32*32 is around 1.5 screens worth of pixels (one screen plus approx 1/4 a screen of unwalkable border) at it's default camera distance. The largest size it supports without complaining or having problems is 256*256 map tiles.
Actually, iirc, the pathing system has a resolution of 4 nodes per map tile, so the pathing map would max out at 1024*1024 (and iirc the reason it doesn't support more than that is that it uses a 2-byte integer for indexing map tiles or something like that).
I don't think it uses A*, though, because the pathing can be horrible at times (and I'm fairly certain it doesn't use a worse algorithm when more units are involved because if many units become active, there can be an 10+ delay before they obey move orders).
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
If not using A*, what else algorithms could I choose? could provide any link?
http://ai-depot.com/Tutorial/PathFinding.html
http://www.gamespp.com/algorithms/pathfinding/
http://www-cs-students.stanford.edu/~amitp/gameprog.html
http://en.wikipedia.org/wiki/Pathfinding
Advertisement

.

Quote: Original post by Kada2k6
If you manage to get this working, I'd be VERY interrested in seeing the source code! I am currently struggling with pathfinding myself, but I can't even do a simple 2D-map Pacman-type of pathfinding (i.e. move only in squares). I guess I understand the theory but I have no idea how to express it in C-code. Thanks. :)


You may use micropather, only need to implement three functions and then you can easily use A* algorithm :)

Hi, Kada2k6...

If you want, I'll love to help you to implement yor A* path finding, A* is most an abstract definition, you must apply it, to your problem, it works with a graph... nodes, could be anything, exactly like the paths between them. Then the data structure must be selected according to your needs... for a simple game, you can use just a matrix... and then you must run your A* algorithm with a simple heuristic, like Manhattan distance...

I hope this help...
with Smoke...
SmokingMan
"The best way to predict the future, is to invent it"

This topic is closed to new replies.

Advertisement