An efficient pathfinding algorithm-b* algorithm for searching the path

Source: Internet
Author: User

This algorithm is called the b* pathfinding algorithm (Branch Star branch pathfinding algorithm, and A * corresponding), the algorithm is suitable for the game monster Automatic pathfinding, its efficiency far more than a * algorithm, after testing, efficiency is the average * algorithm of dozens of times.


Through the introduction of this algorithm, to some extent, the game server can not carry out the conventional pathfinding efficiency problem, unless the server side has a separate AI processing thread, otherwise on the server side can not allow a lot of time to search, even the industry generally recognized the best A *, So the general tradeoff is that the server only does close-up pathfinding, or shortens the range of a * by navigating the site.


algorithm principle
This algorithm is inspired by the real animal's pathfinding process in nature and improved to solve various blocking problems.
Predecessor definition:
1, explore the node: In order to facilitate the narrative, we define the path in the process of exploring the nodes (map lattice) called the Exploration node, the beginning of the exploration node is the Origin point. (The discovery node can correspond to an open node in a *)
2, the Freedom of exploration node: the exploration node toward the target, if the front is not blocked, the exploration node can continue to move forward into the next map lattice, this exploration node we call the free exploration node;
3, the exploration node around the crawl: Explore the node toward the target, if the front is blocking, the exploration node will try to bypass the blocking, the exploration node in the detour we become the exploration node around the crawl;


algorithm Process
1, the beginning, the exploration node for the free node, starting from the origin, to the target forward;
2, the free node forward in the process of judging whether the front is a barrier,
A, not a barrier, a step forward to the goal, is still a free node;
b, is the obstacle, with the front obstacle as the boundary, divides the left and right two branches, respectively attempts to circumvent the obstacle, these two branch nodes become two to crawl the exploration node;
3, the exploration node around the crawl to bypass the barrier, and become a free node, back to 2);
4, after the exploration of the node forward, to determine whether the current map lattice is the target lattice, if it is to find a successful road, according to the process of constructing a complete path;
5, in the process of seeking the road, if the exploration node is not, then find the end of the road, indicating that no target lattice unreachable;


The demo is as follows:


  


Performance comparison of b* and A * algorithm
Number of pathfinding comparisons (5 second pathfinding)
    
B* and A * performance comparison example
1. Barrier-free situation
In this case, according to the above test data, the b* algorithm efficiency is 44 times times the average * (left is a *, right is b*)

2. Linear disorder
In this case, according to the above test data, the b* algorithm efficiency is 28 times times the average * (left is a *, right is b*)

3. Ring Barrier
In this case, according to the above test data, the b* algorithm efficiency is 132 times times the average * (left is a *, right is b*)

4. Blocking barriers (target unreachable)
In this case, according to the above test data, the b* algorithm efficiency is 581 times times the average * (left is a *, right is b*)

derivative algorithm
Through the above blocking barriers, it can be seen that this method in determining whether two points on the map can be reached, is also very efficient, in the case of unreachable, the time complexity and the perimeter of the closure barrier, rather than the entire map area.

An efficient pathfinding algorithm-b* algorithm for searching the 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.