1
SFML projects / AStar Pathfinding with Compass
« on: November 03, 2014, 03:22:01 pm »
Hello all,
I was developing a little game when I was faced with the problem of pathfinding. So I share my experience for this kind of problems with a small lib that I created. I implemented a function that uses the algorithm AStar.
https://github.com/smagras/Compass
Here a little tutorial, but in french^^" (More explained than on github)
http://idevlog.atspace.eu/magrasSteve/a-pathfinding-avec-compass/
And here you can see how to use the lib (we have 2d map, start point and a end point):
I hope, it could help some peoples =)
(There is no many test for the moment, performances problems could exist )
I was developing a little game when I was faced with the problem of pathfinding. So I share my experience for this kind of problems with a small lib that I created. I implemented a function that uses the algorithm AStar.
https://github.com/smagras/Compass
Here a little tutorial, but in french^^" (More explained than on github)
http://idevlog.atspace.eu/magrasSteve/a-pathfinding-avec-compass/
And here you can see how to use the lib (we have 2d map, start point and a end point):
Quote
// Load map from file
Compass::PCore::Matrix<int> mapi = getMapFromFile("mapInput.txt"); // Just to init matrix, do your own code here
// Config parameters for the algorithm
Compass::PPathfinding::AStar astar;
astar.smoothPath(true); //To have smooth path
astar.init(&mapi);
// Find the path from pend to pstart
Compass::PCore::Point pend(2,2);
Compass::PCore::Point pstart(8,8);
std::list<Compass::PCore::Point> res = astar.run(pstart,pend);
// Save result in file
savePathInFile("outFile.txt",mapi,res); // just show the result
I hope, it could help some peoples =)
(There is no many test for the moment, performances problems could exist )