Silverlight realizes A * search algorithm

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.