A * Algorithm seeking path

Source: Internet
Author: User

Reprint: Http://www.cppblog.com/mythit/archive/2009/04/19/80492.aspx

A * algorithm step:

1. Add the start grid to the open list.

2, repeat the following work:

A) Look for the grid with the lowest F value in the Open list. We call it the current lattice.

b) switch it to the off list.

c) to each of the adjacent lattices?

* If it is not available or is already in the close list, skip it. The reverse is as follows.

* If it is not in the open list, add it. Use the current grid as the parent node for this grid. Record the f,g, and H values for this grid.

* If it is already in the open list, it is better to check the new path with the G value for reference. A lower G-value means a better path. If so, change the parent node of the grid to the current grid and recalculate the G and F values of the grid. If you keep your open list sorted by F-value, you may need to re-order the open list after the change.

d) Stop, when you

* Add the target to the close list (note), when the path is found, or

* No target grid found, open list is empty. At this time, the path does not exist.

3. Save the path. Starting from the target, move along the parent node of each cell until you return to the start grid. This is your path.

A * Algorithm seeking path

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.