[Unity Algorithm] A Star pathfinding (i): Basic version

Source: Internet
Author: User

Reference Links:

Https://www.cnblogs.com/yangyxd/articles/5447889.html

I. Principle

1. Simplify the scene and divide it into square squares called nodes, and the distance from one node to another is called cost. The cost of a node and a horizontal/vertical adjacent node is 1, and the cost of the diagonal node is 1.4. Here the reference formula F = g + H,f represents the total cost of the node, G represents the cost of the node and the previous path node, h represents the cost of the node and the target node.

2. Requires two lists, open list (openlist) and close list (closelist). The open list is used to record the grids that need to be considered, and the closed list is used to record squares that are no longer considered.

3. Add the current position in the close list and add the accessible grid adjacent to the current position to the open list

[Unity Algorithm] A Star pathfinding (i): Basic version

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.