Generic A*
I''m looking for a set of A* code that very clearly takes in the Start X,Y and Goal X,Y, and needs only two functions written for it : a straightforward GetValidity and GetCost, and when the path has been generated, has a clear implementation of reading the path. This is for use with a 2d map with 8-directional movement.
All I want is the core, basic principle, unnapplied to any specific game or program. I''ve read through four or five implementations of the algorithm, including all the ones I found linked from the main Gamedev.net site and the hexagonal pathfinder that seems to be frequently linked to here, and the closest I''ve gotten to what I wanted is Matthew''s implementation of it in AI Game Programming Wisdom.
Unfortunately, he uses coding techniques that are a little too complex, leaving me with a simultaneous AI and C++ learning curve. I don''t need something THAT open to expansion immediately. I''d rather have something a bit more boiled down first so that I can get a working structure in place in my game, and then I can devote more time to the more complex iterations of the algorithm.
I''m perfectly willing to believe that this doesn''t exist: the code that I''ve seen so far has either been basic, but not generic, or generic, but not basic. But I thought I''d ask around.
A* is simple - I just finished implementing it myself. I''d give you the code, but it''s a mess and yet unoptimized. Besides, it''s unidirectional (don''t really see the advantage in bidirectionalism, speedwise).
My suggestion is to alot ~5 h to it and just code it yourself. Start here, then read this for optimizations and finally have a look around here.
My suggestion is to alot ~5 h to it and just code it yourself. Start here, then read this for optimizations and finally have a look around here.
"Finishing in second place, simply means you are the first loser." - PouyaCat
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
I got my A* implementation from here:
http://www.geocities.com/SiliconValley/Lakes/4929/astar.html
There is some nice example code that will fit pretty much anything since the A* engine is built as a template.
The actual Node class is what you will overhaul for your own purposes.
Also note that A* is just an algorithm and in itself is pretty generic. It''s the nodes that are particular. If you use a hex board, then you just change the GetChildren() (or whatever its called) function to get 6 instead of 4. The actual engine would remain untouched.
http://www.geocities.com/SiliconValley/Lakes/4929/astar.html
There is some nice example code that will fit pretty much anything since the A* engine is built as a template.
The actual Node class is what you will overhaul for your own purposes.
Also note that A* is just an algorithm and in itself is pretty generic. It''s the nodes that are particular. If you use a hex board, then you just change the GetChildren() (or whatever its called) function to get 6 instead of 4. The actual engine would remain untouched.
March 01, 2004 03:12 AM
or maybe this is worth a look (although it looks still pretty beta - like) :
http://www.lampel.net/johannes/joebotxp/JoeBOTXPDoc-beta.pdf
(EDITED to fix broken embedded URL)
[edited by - Timkin on March 1, 2004 7:48:15 PM]
http://www.lampel.net/johannes/joebotxp/JoeBOTXPDoc-beta.pdf
(EDITED to fix broken embedded URL)
[edited by - Timkin on March 1, 2004 7:48:15 PM]
quote:C++ doesn''t lend itself to a generic A* implementation that would be *fast* in all cases, though. Or at least I couldn''t make one, and the implementation in the link you gave is also very slow for "special" purposes like a grid map. Hmm, maybe I''ll try again..
Original post by leiavoia
Also note that A* is just an algorithm and in itself is pretty generic. It''s the nodes that are particular. If you use a hex board, then you just change the GetChildren() (or whatever its called) function to get 6 instead of 4. The actual engine would remain untouched.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement