A Path Search Method Based on AStar Algorithm

By using the Prime algorithm and Grid map conversion in the maze scene, the path search of the AStar algorithm is optimized, which solves the problems of low efficiency and many dead ends of the traditional AStar algorithm in maze path finding, and achieves more efficient path search.

CN113532458BActive Publication Date: 2024-09-13XIAMEN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110698514.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-23
Publication Date
2024-09-13
Estimated Expiration
2041-06-23

AI Technical Summary

Technical Problem

The traditional AStar algorithm has problems with low search efficiency and many dead ends in maze pathfinding scenarios, which results in excessive node searches and repeated traversals, affecting path search efficiency.

Method used

Use the Prime algorithm to randomly plan paths and convert them into Grid maps, search for dead ends and eliminate them, search for adjacent points only in the four directions of up, down, left, and right, use the small root heap algorithm to store and sort adjacent points, and optimize the path search of the AStar algorithm .

Benefits of technology

It greatly reduces the number of search nodes, avoids dead-end traversal, and improves the efficiency of path search.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113532458B
    Figure CN113532458B
Patent Text Reader

Abstract

The present invention provides a path search method based on the AStar algorithm in the field of map path planning technology, comprising the following steps: step S10, using the Prime algorithm to randomly plan a path, and generating a maze scene based on the path; step S20, converting the maze scene into a Grid map; step S30, searching for dead ends in the Grid map and eliminating them; step S40, searching for adjacent points of each map node in the Grid map; step S50, calculating the f(n) value of each adjacent point, and sorting each adjacent point based on the f(n) value; step S60, storing each adjacent point after sorting in an Open list based on a small root heap algorithm; step S70, using the AStar algorithm, performing path search based on each adjacent point stored in the Open list. The advantages of the present invention are: greatly improving the efficiency of path search.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of map path planning, and in particular to a path searching method based on an AStar algorithm. Background Art

[0002] Path search is to search for a path to reach the destination under a set scenario. It is widely used in scenarios such as autonomous driving and maze path finding. Path search generally uses the AStar algorithm (heuristic search algorithm). However, taking the maze path finding scenario as an example, the traditional AStar algorithm has the following disadvantages:

[0003] 1. When looking for the adjacent points of the current node, it is necessary to search the nodes in 8 directions (8*45°) around the node each time. The farther the starting node and the target node are from each other and the more walls there are, the more nodes need to be searched, resulting in low search efficiency. 2. Each time, it is necessary to select the node with the smallest f(n) value as the next search node, and it is necessary to repeatedly traverse the Open list. The Open list stores a large amount of node information that has been generated but not yet visited. Repeated traversal leads to inefficient selection of the node with the smallest f(n) value. Among them, f(n) represents the evaluation function of node n, f(n) = g(n) + h(n), g(n) represents the actual cost from the initial node to the n node in the state space, and h(n) represents the estimated cost of the best path from node n to the target node. 3. There are many dead ends in the maze pathfinding scene, which makes the AStar algorithm easily go to dead ends during the pathfinding process, thereby traversing a large number of redundant nodes.

[0004] Therefore, how to provide a path search method based on the AStar algorithm to improve the efficiency of path search has become an urgent problem to be solved. Summary of the invention

[0005] The technical problem to be solved by the present invention is to provide a path search method based on the AStar algorithm to improve the efficiency of path search.

[0006] The present invention is implemented as follows: a path search method based on the AStar algorithm comprises the following steps:

[0007] Step S10, using the Prime algorithm to randomly plan a path, and generating a maze scene based on the path;

[0008] Step S20, converting the maze scene into a Grid map;

[0009] Step S30, searching for dead ends in the Grid map and eliminating them;

[0010] Step S40: searching for adjacent points of each map node in the Grid map;

[0011] Step S50, calculating the f(n) value of each adjacent point, and sorting the adjacent points based on the f(n) value;

[0012] Step S60, storing the sorted adjacent points into an Open list based on a Root Heap algorithm;

[0013] Step S70: Use the AStar algorithm to perform a path search based on each adjacent point stored in the Open list.

[0014] Furthermore, the step S10 specifically includes:

[0015] Step S11, using the Prime algorithm to randomly plan a path, wherein the path consists of a number of square path nodes;

[0016] Step S12, randomly selecting one of the path nodes in turn and adding it into the wall queue;

[0017] Step S13, determining whether there are only three path nodes in the upper, lower, left, and right directions adjacent to the path nodes in the wall queue, if so, adding the three path nodes into the wall queue; if not, deleting the path nodes in the wall queue;

[0018] Step S14: Initialize the path nodes in the wall queue as walls to generate a maze scene.

[0019] Furthermore, in step S10, the path is provided with a starting path node and a target path node.

[0020] Furthermore, the step S20 is specifically as follows:

[0021] The maze scene is divided into equal-sized squares based on the size of the path nodes to obtain a number of map nodes. The wall properties of each map node are set based on the maze scene to complete the conversion of the Grid map.

[0022] Furthermore, the wall attribute is used to identify whether the map node is a wall.

[0023] Furthermore, the step S30 is specifically as follows:

[0024] Determine each map node in the Grid map in turn to see whether there are three adjacent map nodes that are all walls. If so, it means it is a dead end, and the map node is set as a wall, and the process goes to step S40; if not, it means it is not a dead end, and the process goes to step S40.

[0025] Furthermore, the step S40 is specifically as follows:

[0026] The adjacent points of each map node in the Grid map are searched based on four directions: up, down, left, and right.

[0027] The advantages of the present invention are:

[0028] By searching for the adjacent points of each map node in the Grid map, only the four directions of up, down, left and right are searched, which greatly reduces the number of nodes that need to be searched compared to the traditional search in eight directions; the adjacent points are stored in the Open list through the Root Heap algorithm, and the adjacent point at the top of the heap is the adjacent point with the smallest f(n) value, so there is no need to repeatedly traverse the Open list; by searching for dead ends in the Grid map and setting the map nodes corresponding to the dead ends as walls, the AStar algorithm can avoid traversing unnecessary map nodes due to dead ends during the path finding process, which ultimately greatly improves the efficiency of path search. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The present invention will be further described below in conjunction with embodiments with reference to the accompanying drawings.

[0030] Figure 1 It is a flow chart of a path search method based on the AStar algorithm of the present invention. DETAILED DESCRIPTION

[0031] The technical solution in the embodiments of the present application has the following overall ideas: simplify the search direction of the adjacent points of each map node in the Grid map; store the adjacent points in the Open list through the Root Heap algorithm, and the adjacent point at the top of the heap is the adjacent point with the smallest f(n) value, and there is no need to repeatedly traverse the Open list; search for dead ends in the Grid map and eliminate them to improve the efficiency of path search.

[0032] Please refer to Figure 1 As shown, a preferred embodiment of a path search method based on the AStar algorithm of the present invention comprises the following steps:

[0033] Step S10, using the Prime algorithm (Randomized Prime's Algorithm) to randomly plan a path, and generating a maze scene based on the path;

[0034] Step S20, converting the maze scene into a Grid map;

[0035] Step S30, searching for dead ends in the Grid map and eliminating them;

[0036] Step S40: searching for adjacent points of each map node in the Grid map;

[0037] Step S50, calculating the f(n) value of each adjacent point, and sorting the adjacent points based on the f(n) value;

[0038] Step S60, storing the sorted adjacent points into an Open list based on a small root heap algorithm; that is, optimizing the storage structure of the Open list using the small root heap algorithm;

[0039] A binary heap is a heap implemented with a complete binary tree. A heap with a small root is a binary heap whose non-terminal node value is less than or equal to the value of its left and right children. In the Open list, we hope to find the adjacent point with the smallest f(n) value each time. If we use a heap to store the Open list, the top element of the heap is the adjacent point with the smallest f(n) value.

[0040] When adding an adjacent point to the Open list, first insert the adjacent point into the last position of the binary tree, then sort upwards and find the parent node. If the f(n) value of the current adjacent point is smaller than that of the parent node, it is exchanged with the parent node until the insertion is completed. When taking the minimum value of f(n), remove the top element of the heap from the Open list, then put the last adjacent point of the binary tree at the root node, sort downwards, compare its left and right child nodes, and compare the adjacent point with the child node with the smaller f(n) value of its left and right child nodes. If the f(n) value of the child node is smaller, the adjacent point is exchanged with its child node.

[0041] Step S70: Use the AStar algorithm to perform a path search based on each adjacent point stored in the Open list.

[0042] The step S10 specifically includes:

[0043] Step S11, using the Prime algorithm to randomly plan a path, wherein the path consists of a number of square path nodes;

[0044] Step S12, randomly selecting one of the path nodes in turn and adding it into the wall queue;

[0045] Step S13, determining whether there are only three path nodes in the upper, lower, left, and right directions adjacent to the path nodes in the wall queue, if so, adding the three path nodes into the wall queue; if not, deleting the path nodes in the wall queue;

[0046] Step S14: Initialize the path nodes in the wall queue as walls to generate a maze scene.

[0047] In step S10, the path is provided with a starting path node and a target path node.

[0048] The step S20 is specifically as follows:

[0049] The maze scene is divided into equal-sized squares based on the size of the path nodes to obtain a number of map nodes, and the wall attributes of each map node are set based on the maze scene to complete the conversion of the Grid map. In specific implementation, the CellQueue queue can be used to store all the map nodes, and the CellList list can be used to store the found map nodes. The Grid map includes a starting map node and a target map node.

[0050] The wall attribute is used to identify whether a map node is a wall; if the wall attribute is not identified as a wall, the corresponding map node is a road; only one of the adjacent points in the four directions of the road, namely, the top, bottom, left, and right, is a road.

[0051] The step S30 is specifically as follows:

[0052] Determine each map node in the Grid map in turn to see whether there are three adjacent map nodes that are all walls. If so, it means it is a dead end, and the map node is set as a wall, and the process goes to step S40; if not, it means it is not a dead end, and the process goes to step S40.

[0053] The step S40 is specifically as follows:

[0054] The adjacent points of each map node in the Grid map are searched based on the four directions of up, down, left and right; by simplifying the search direction, the map nodes that need to be searched are greatly reduced, thereby improving the efficiency of the path search.

[0055] The pseudo code of the improved AStar algorithm is as follows:

[0056] Initialize the Grid map according to the maze scene and store the wall attributes into the Grid map;

[0057] Set the starting map node and target map node of the Grid map;

[0058] Optimize the search area and set the dead ends in the Grid map to walls;

[0059] Initialize the small root heap openSet according to the Grid map size;

[0060] Initialize a hash list closeSet;

[0061] Add the starting map node to openSet;

[0062]

[0063]

[0064] In summary, the advantages of the present invention are:

[0065] By searching for the adjacent points of each map node in the Grid map, only the four directions of up, down, left and right are searched, which greatly reduces the number of nodes that need to be searched compared to the traditional search in eight directions; the adjacent points are stored in the Open list through the Root Heap algorithm, and the adjacent point at the top of the heap is the adjacent point with the smallest f(n) value, so there is no need to repeatedly traverse the Open list; by searching for dead ends in the Grid map and setting the map nodes corresponding to the dead ends as walls, the AStar algorithm can avoid traversing unnecessary map nodes due to dead ends during the path finding process, which ultimately greatly improves the efficiency of path search.

[0066] Although the specific implementation modes of the present invention are described above, those skilled in the art should understand that the specific implementation modes described are only illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included in the scope of protection of the claims of the present invention.

Claims

1. A path search method based on the AStar algorithm, characterized in that: The steps include: Step S10, using the Prime algorithm to randomly plan a path, and generating a maze scene based on the path; Step S20, converting the maze scene into a Grid map; Step S30: Search for dead ends in the Grid map and eliminate them; specifically: Determine in turn whether there are three adjacent map nodes in the Grid map that are all walls. If so, it means it is a dead end, and the map node is set as a wall, and the process goes to step S40; if not, it means it is not a dead end, and the process goes to step S40; Step S40: searching for adjacent points of each map node in the Grid map; Step S50, calculating the f(n) value of each adjacent point, and sorting the adjacent points based on the f(n) value; Step S60, storing the sorted adjacent points into an Open list based on a Root Heap algorithm; Step S70: Use the AStar algorithm to perform a path search based on each adjacent point stored in the Open list.

2. A path search method based on the AStar algorithm as claimed in claim 1, characterized in that: The step S10 specifically includes: Step S11, using the Prime algorithm to randomly plan a path, wherein the path consists of a number of square path nodes; Step S12, randomly selecting one of the path nodes in turn and adding it into the wall queue; Step S13, determining whether there are only three path nodes in the upper, lower, left, and right directions adjacent to the path nodes in the wall queue, if so, adding the three path nodes into the wall queue; if not, deleting the path nodes in the wall queue; Step S14: Initialize the path nodes in the wall queue as walls to generate a maze scene.

3. A path search method based on the AStar algorithm as claimed in claim 1, characterized in that: In step S10, the path is provided with a starting path node and a target path node.

4. A path search method based on the AStar algorithm as claimed in claim 2, characterized in that: The step S20 is specifically as follows: The maze scene is divided into equal-sized squares based on the size of the path nodes to obtain a number of map nodes. The wall properties of each map node are set based on the maze scene to complete the conversion of the Grid map.

5. A path search method based on the AStar algorithm as claimed in claim 4, characterized in that: The wall attribute is used to identify whether a map node is a wall.

6. A path search method based on the AStar algorithm as claimed in claim 1, characterized in that: The step S40 is specifically as follows: The adjacent points of each map node in the Grid map are searched based on four directions: up, down, left, and right.