11/04/2011

A* path planning Algorithm / C++ source code










Created Date : 2010.8
Language : C/C++
Tool : Microsoft Visual C++ 6.0
Library & Utilized : STL
Reference : A* internet reference
etc. : map(.txt file)




It is A* algorithm. A* is known as good path plan algorithm in the Game and other fields.
I made the A* algorithm program. I have refered a lot of reference in the internet. You also can get materials easily in the internet.

I made the algorithm to class type. So we can use the A* Class like this;

CAstar Astar;
Astar.MapCopy(xSize, ySize, &map);
Astar.SetSEpoint(sX, sY, eX, eY);
vector< pair<int, int > > path = Astar.FindPath();

map variable type is 'int ** map'.
sX, Sy is start coordinate. eX, ey is  end coordinate.
The path coordinate is saved in the path variable(vector type).

You can download this <source code>.
And I wish to leave your valueable comment.

Thank you.

1 comment:

  1. Anonymous4/5/14 08:41

    Thanks for the example, but it is underlining this sentence "if( fin == NULL)", the error message as follow: "Error 3 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::ifstream' (or there is no acceptable conversion) c:\users\My_PC\downloads\a_star\main.cpp 74 1 A_Star"

    ReplyDelete