Does anyone know where to download AStar source code (C++)?
I know there are lots of them. But what I really need is a bare minimal one.
I need it because I've got a library that I need to apply the AStar part to that program.
The basic things I need, make a start point, end point, push things onto open list
pop them out, and push them into closed list etc
Just very simple is enough. I don't want to write it myself, I don't want to re-invent the wheel.
Thanks
Jack
What about http://www.grinninglizard.com/MicroPather/ ?
As the documentation is quite scarse... Only 2 files, does what you want, basic usage:
first you need a graph class
class MyMap : public micropather::Graph
{
public:
float LeastCostEstimate (void *stateStart, void *stateEnd); // heurestic, eucludian distance might be sufficient
void AdjacentCost (void *state, std::vector< micropather::StateCost > *adjacent); // // movement cost from nfrom to neighbours, results are put into adjacent
};
usage:
float totalCost = -1;
std::vector<void*> path;
int res = m_mp->Solve(ConvertPositionToVoid(start), ConvertPositionToVoid(end), &path, &totalCost); // see below about ConvertPositionToVoid
if (path)
{
// convert void back to coordinates
}
if (res == (int)micropather::MicroPather::SOLVED || res == (int)micropather::MicroPather::START_END_SAME)
return totalCost;
If your map is represented as a graph you can just pass its nodes to micropather (converting from nodes class to void* and vice versa). If your map is represented in a fashion like int map[][], then you can encode x,y coordinates into void pointer (like void *start = (void*)(y << 0xFF | x))
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement