A * Algorithm (introduction)

Source: Internet
Author: User

Manhattan Distance

Manhattan distance also known as the MA Distance (Manhattan distance), but also seen more image, called Taxi distance. See Yellow Line, you should be able to understand.

The simplest way to calculate distances is the Manhattan distance. Assuming that the first two-dimensional case is considered, only two bands X and Y, User A is rated (X1,Y1), and User B is rated as (X2,y2), then the Manhattan distance between them is

A * Algorithm summary (Summary of the * method)

Ok, now that you have read the whole introduction, now we put all the steps together:

1. Add the starting point to the open list.

2. Repeat the following procedure:

A. Traverse the open list to find the node with the lowest F value, and use it as the node that is currently being processed.

B. Move the node to the close list.

C. For each square of the 8 adjacent squares of the current square?

If it is not reachable or it is in the close list, ignore it. Otherwise, do the following.

If it is not in the open list, add it to the open list and set the current square as its father, recording the square's F, G, and H values.

If it is already in the open list, it is better to check the path (that is, to reach it through the current square) and use the G value for reference. A smaller G-value indicates that this is a better path. If so, set its father to the current square and recalculate its G and F values. If your open list is sorted by the F value, you may need to reorder it after the change.

D. Stop, when you

The end is added to the open list, where the path has been found, or

The find endpoint failed, and the open list is empty and there is no path at this time.

3. Save the path. From the end point, each square moves along the parent node until it starts, and that's your path.

References:

http://blog.csdn.net/hitwhylz/article/details/23089415

A * Algorithm (introduction)

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.