Suggest viewing in a new window:
Http://www.dotnet.pp.ru/silverlight/SilverlightAStar.html
It took a few days to study A * algorithm, and finally got it out. Put it up for the guys to see.
Click "StartPoint" to specify the starting point and click "EndPoint" to specify the target point. Click "Impediment" to specify the unreachable area.
GridSize Set the node size, the smaller the node, the more nodes in the container, fill in the point set save settings.
Clear clears all.
Startfindpath began to seek the path
Completed Tim shows how long it takes to find the path.
Whether the diagonals setting can be tilted away.
I feel good about myself.
Here's a rough flow of algorithms.
First define two lists
private List<PathNote> openedList = new List<PathNote>(); //开启列表
private List<PathNote> colsedList = new List<PathNote>(); //关闭列表
Open the list to store the node to be detected. Close the list to store the detected node.
Starting at the start point, get the nodes in the 4 or 8 directions around the start point and add them to the open list.
G equals the parent node of the current node plus 10 or 14, the horizontal or vertical direction plus 10, the diagonal direction plus 14
H equals the difference between the X of the current node and the x of the target, and the absolute value of the difference between Y and the target point y.
F = G + H.
Deletes the current node from the Open list. and add it to the close list. Take "F" as the basis from small to large sorting, the F-value of the smallest node out, repeat the above process.
The approximate process is this. The details have been written in a very detailed article, there is no need to repeat.
Transmission door: http://data.gameres.com/message.asp?TopicID=25439