Path finding method and device, computer program product and electronic equipment

By initializing and updating the pass size in the navigation grid, the target navigation grid is automatically generated, which solves the problem of increasing memory footprint in NavMesh technology, and flexible navigation of pass units of different sizes is achieved, reducing memory footprint and enhancing the scalability of pathfinding.

CN119587981APending Publication Date: 2025-03-11NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411830136.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

When the existing NavMesh technology supports the wayfinding function of pass units of different sizes, it needs to store multiple levels of navigation mesh, resulting in inconvenient configuration and increased memory footprint.

Method used

By obtaining the navigation grid corresponding to the virtual scene, initializing its pass size, determining obstacles and updating the cell pass size in the navigation grid, based on the pass size comparison results of adjacent cells, increasing the pass size of the target cell, generating the target navigation grid, and using the preset pathfinding algorithm for pathfinding.

Benefits of technology

It realizes the storage of pass sizes through navigation grids, meets the navigation needs of pass units of different sizes, avoids the need to store multi-layer NavMesh, reduces memory footprint, and enhances the flexibility and scalability of pathfinding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119587981A_ABST
    Figure CN119587981A_ABST
Patent Text Reader

Abstract

The invention relates to a way finding method and device, a computer program product and electronic equipment, and relates to the technical field of computers.The method comprises the steps that a navigation grid corresponding to a virtual scene is obtained, and the traffic size of the navigation grid is initialized; determining an obstacle included in the virtual scene, determining a first cell in the navigation grid based on the obstacle, and updating the traffic size of the first cell; determining a target cell from the second cells based on a passage size comparison result of the second cells and adjacent cells of the second cells, and performing passage size self-increasing on the target cell to obtain a target navigation grid; and based on a preset way-finding algorithm, carrying out way-finding on the passage unit in the target navigation grid to obtain a way-finding result. According to the invention, memory occupation in a path finding process is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] In real life or games, different sizes of traffic units usually require navigation meshes of different widths. NavMesh is used in related technologies to solve the pathfinding problem.

[0003] NavMesh is a technology widely used in 3D game development, mainly used to implement path planning and movement control of characters or objects in the game. By calculating the walkable areas in the game environment, NavMesh helps AI characters navigate intelligently in these areas while avoiding obstacles and unwalkable terrain.

[0004] However, in order to fully support the pathfinding function of different-sized traffic units, NavMesh needs to store multiple levels of navigation meshes, which is not only inconvenient to configure and use, but also significantly increases memory usage.

[0005] Therefore, a new pathfinding method needs to be provided.

[0006] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present invention, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the invention

[0007] The present disclosure provides a path-finding method, a path-finding device, a computer program product, and an electronic device, thereby overcoming, at least to a certain extent, the problem of increased memory usage caused by path-finding technology in related technologies due to limitations and defects of related technologies.

[0008] According to one aspect of the present disclosure, a pathfinding method is provided, comprising:

[0009] Acquire a navigation grid corresponding to the virtual scene, and initialize the pass size of the navigation grid;

[0010] Determining an obstacle included in the virtual scene, determining a first cell in the navigation grid based on the obstacle, and updating a passage size of the first cell;

[0011] Based on the comparison result of the passage size between the second cell and the adjacent cells of the second cell, a target cell is determined from the second cell, and the passage size of the target cell is incremented to obtain a target navigation grid;

[0012] Based on a preset pathfinding algorithm, pathfinding is performed for the pass unit in the target navigation grid to obtain a pathfinding result.

[0013] In an exemplary embodiment of the present disclosure, the acquiring a navigation grid corresponding to the virtual scene and initializing a pass size of the navigation grid includes:

[0014] Acquire a terrain corresponding to the virtual scene, and determine the navigation grid based on the terrain;

[0015] The passage sizes of cells included in the navigation grid are initialized, and the passage size of each cell in the navigation grid is set to a first preset size, wherein the first preset size is used to represent the maximum size of the cell allowed to pass.

[0016] In an exemplary embodiment of the present disclosure, determining an obstacle included in the virtual scene, determining a first cell in the navigation grid based on the obstacle, and updating a passage size of the first cell includes:

[0017] Determine a position of the obstacle in the virtual scene, and determine a first cell corresponding to the obstacle in the navigation grid according to the position;

[0018] The pass size of the first cell is updated to a second preset size, wherein the second preset size is smaller than the first preset size.

[0019] In an exemplary embodiment of the present disclosure, the determining of a target cell from the second cell based on a comparison result of the passage sizes of the second cell and the adjacent cells of the second cell, and performing self-increment of the passage size of the target cell to obtain a target navigation grid includes:

[0020] Traversing the navigation grid, acquiring a second cell in the navigation grid and an adjacent cell of the second cell, where the second cell is a cell in the navigation grid except the first cell;

[0021] Comparing the passage size of the second cell with the passage size of the adjacent cells of the second cell to obtain a comparison result, and determining a target cell in the second cell according to the comparison result;

[0022] The passage size of the target cell is incremented to obtain the target navigation grid.

[0023] In an exemplary embodiment of the present disclosure, the comparing the passage size of the second cell with the passage size of a cell adjacent to the second cell to obtain a comparison result, and determining a target cell in the second cell according to the comparison result, includes:

[0024] When the pass sizes of the adjacent cells of the second cell are all larger than the pass size of the second cell, the second cell is determined as the target cell; wherein the adjacent cells of the second cell are cells adjacent to the second cell above, below, left and right.

[0025] In an exemplary embodiment of the present disclosure, the passage size of the target cell is incremented to obtain the target navigation grid, including:

[0026] Acquire the preset self-increment size, and increment the pass size of the target cell based on the preset self-increment size;

[0027] Based on the incremented cell, the target navigation grid is obtained.

[0028] In an exemplary embodiment of the present disclosure, the method further includes:

[0029] When the second cell does not have at least one cell adjacent to the second cell above, below, left, or right, the pass size of the second cell is not incremented.

[0030] In an exemplary embodiment of the present disclosure, the method further includes:

[0031] The passage size of the second cell is cyclically incremented until a preset number of increments is reached or the passage size of the second cell reaches a preset maximum passage size.

[0032] In an exemplary embodiment of the present disclosure, the performing pathfinding for the pass unit in the target navigation grid based on a preset pathfinding algorithm to obtain a pathfinding result includes:

[0033] Acquire the size of the passable unit, compare the size of the passable unit with the passable size of the second cell in the target navigation grid, and obtain a third cell through which the passable unit can pass;

[0034] Pathfinding is performed in the third cell based on the preset pathfinding algorithm to obtain a passing path of the passing unit.

[0035] According to one aspect of the present disclosure, there is provided a path-finding device, comprising:

[0036] According to one aspect of the present disclosure, a computer storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the path-finding method described in any of the above exemplary embodiments is implemented.

[0037] According to one aspect of the present disclosure, there is provided an electronic device, including:

[0038] A processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the path-finding method described in any of the above exemplary embodiments by executing the executable instructions.

[0039] According to one aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the path-finding method described in any of the above exemplary embodiments is implemented.

[0040] A pathfinding method provided by an embodiment of the present disclosure obtains a navigation grid corresponding to a virtual scene, and initializes the passage size of the navigation grid; determines obstacles included in the virtual scene, determines a first cell in the navigation grid based on the obstacles, and updates the passage size of the first cell; determines a target cell from the second cell based on a result of comparing the passage sizes of a second cell with cells adjacent to the second cell, and increments the passage size of the target cell to obtain a target navigation grid; and performs pathfinding for the passage cells in the target navigation grid based on a preset pathfinding algorithm to obtain a pathfinding result. On the one hand, the navigation grid corresponding to the virtual scene is obtained, the passage size of the navigation grid is initialized, obstacles in the virtual scene are determined, and the passage size of the first cell included in the navigation grid is updated based on the obstacles. For the second cell in the virtual scene, the target cell in the second cell can be determined based on the comparison result of the passage size of the second cell and the adjacent cells of the second cell, and the passage size of the target cell is incremented to obtain the target navigation grid, which realizes the storage of the passage size through the navigation grid, can meet the needs of different sizes of passage units to select appropriate channels for navigation, does not need to store multiple layers of NavMesh, and reduces memory usage. On the other hand, the above-mentioned pathfinding method is applicable to maps of any size, which enhances the flexibility and scalability of pathfinding.

[0041] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present invention, and together with the specification are used to explain the principles of the present invention. Obviously, the accompanying drawings described below are only some embodiments of the present invention, and for those of ordinary skill in the art, other accompanying drawings can be obtained based on these accompanying drawings without creative work.

[0043] Figure 1 The following schematically shows a flow chart of a path-finding method according to an exemplary embodiment of the present disclosure.

[0044] Figure 2 A flowchart of a method for acquiring a navigation grid corresponding to a virtual scene and initializing a pass size of the navigation grid according to an exemplary embodiment of the present disclosure is schematically shown.

[0045] Figure 3 A flowchart schematically illustrates a method for determining obstacles included in the virtual scene, determining a first cell in the navigation grid based on the obstacles, and updating a passage size of the first cell according to an exemplary embodiment of the present disclosure.

[0046] Figure 4 A flowchart of a method for determining a target cell from a second cell based on a comparison result of the passage sizes of a second cell and adjacent cells of the second cell, and incrementing the passage size of the target cell to obtain a target navigation grid according to an example embodiment of the present disclosure is schematically shown.

[0047] Figure 5 A flowchart of a method for automatically increasing the passage size of the target cell to obtain the target navigation grid according to an exemplary embodiment of the present disclosure is schematically shown.

[0048] Figure 6 A schematic diagram schematically illustrates a navigation grid according to an exemplary embodiment of the present disclosure.

[0049] Figure 7 A schematic diagram of a navigation grid after updating the pass size of cells in the navigation grid according to an exemplary embodiment of the present disclosure is schematically shown.

[0050] Figure 8 A schematic diagram schematically illustrates a target navigation grid according to an exemplary embodiment of the present disclosure.

[0051] Fig. 9 A flowchart of a method for performing pathfinding for a pass unit in the target navigation grid based on a preset pathfinding algorithm and obtaining a pathfinding result according to an exemplary embodiment of the present disclosure is schematically shown.

[0052] Fig.10 A schematic diagram schematically illustrates a target navigation grid according to an exemplary embodiment of the present disclosure.

[0053] Fig.11 A schematic diagram schematically illustrates the distances from each cell to a fourth cell in a target navigation grid according to an exemplary embodiment of the present disclosure.

[0054] Fig.12 A schematic diagram schematically illustrates a path finding result obtained by performing path finding based on the Dijkstra algorithm according to an exemplary embodiment of the present disclosure.

[0055] Fig.13A block diagram schematically shows a path-finding device according to an exemplary embodiment of the present disclosure.

[0056] Fig.14 An electronic device for implementing a path-finding method according to an exemplary embodiment of the present invention is schematically shown. DETAILED DESCRIPTION

[0057] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present invention will be more comprehensive and complete, and the concept of the example embodiments will be fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present invention. However, those skilled in the art will appreciate that the technical solutions of the present invention may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present invention.

[0058] In addition, the accompanying drawings are only schematic illustrations of the present invention and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.

[0059] In real life or games, mobile units of different sizes usually require navigation meshes of different widths. Traditional solutions, such as NavMesh, usually create separate navigation meshes for each size of mobile unit to solve the pathfinding problem.

[0060] NavMesh is a technology widely used in 3D game development, mainly used to implement path planning and movement control of characters or objects in the game. By calculating the walkable areas in the game environment, NavMesh helps AI characters navigate intelligently in these areas while avoiding obstacles and unwalkable terrain.

[0061] However, in order to fully support the pathfinding of traffic units of different sizes, the above-mentioned NavMesh technology needs to store multiple levels of navigation meshes, which is not only inconvenient to configure and use, but also increases memory usage, resulting in unnecessary memory overhead.

[0062] Based on one or more of the above problems, this example implementation first provides a path finding method, referring to Figure 1 As shown, the path finding method may include the following steps:

[0063] Step S110: Acquire a navigation grid corresponding to the virtual scene, and initialize the passage size of the navigation grid;

[0064] Step S120: determining obstacles included in the virtual scene, determining a first cell in the navigation grid based on the obstacles, and updating the passage size of the first cell;

[0065] Step S130. Based on the comparison result of the passage size between the second cell and the adjacent cells of the second cell, determine the target cell from the second cell, and increment the passage size of the target cell to obtain the target navigation grid;

[0066] Step S140: performing pathfinding for the passable unit in the target navigation grid based on a preset pathfinding algorithm to obtain a pathfinding result.

[0067] The above-mentioned pathfinding method obtains a navigation grid corresponding to a virtual scene and initializes the passage size of the navigation grid; determines obstacles included in the virtual scene, determines a first cell in the navigation grid based on the obstacles, and updates the passage size of the first cell; determines a target cell from the second cell based on a comparison result of the passage sizes of a second cell and an adjacent cell of the second cell, and increments the passage size of the target cell to obtain a target navigation grid; and performs pathfinding for passage cells in the target navigation grid based on a preset pathfinding algorithm to obtain a pathfinding result. On the one hand, the navigation grid corresponding to the virtual scene is obtained, the passage size of the navigation grid is initialized, obstacles in the virtual scene are determined, and the passage size of the first cell included in the navigation grid is updated based on the obstacles. For the second cell in the virtual scene, the target cell in the second cell can be determined based on the comparison result of the passage size of the second cell and the adjacent cells of the second cell, and the passage size of the target cell is incremented to obtain the target navigation grid, which realizes the storage of the passage size through the navigation grid, can meet the needs of different sizes of passage units to select appropriate channels for navigation, does not need to store multiple layers of NavMesh, and reduces memory usage. On the other hand, the above-mentioned pathfinding method is applicable to maps of any size, which enhances the flexibility and scalability of pathfinding.

[0068] In the following, each step involved in the path-finding method of the exemplary embodiment of the present disclosure is explained and illustrated in detail.

[0069] In step S110, a navigation grid corresponding to the virtual scene is obtained, and a passage size of the navigation grid is initialized.

[0070] In this example embodiment, a Grid grid can be used and the Grid grid can be determined as a navigation grid. Unlike NavMesh, which uses polygons to divide the walkable area, the Grid grid divides the space into a regular grid system consisting of N*M cells. Each cell has a fixed size, position, and neighbor grid, and each cell stores the necessary information for implementing the pathfinding algorithm. The necessary information may include: the cell's own position, size, and the current cell's pass size.

[0071] In this example embodiment, reference Figure 2 As shown, the obtaining of the navigation grid corresponding to the virtual scene and initializing the pass size of the navigation grid includes:

[0072] Step S210. Acquire the terrain corresponding to the virtual scene, and determine the navigation grid based on the game scene terrain;

[0073] Step S220. Initialize the passage size of the cells included in the navigation grid, and set the passage size of each cell in the navigation grid to a first preset size, wherein the first preset size is used to represent the maximum size allowed for passage of the cell.

[0074] In the following, step S210 and step S220 will be further explained and illustrated. Specifically, first, the terrain corresponding to the virtual scene is obtained, and the navigation grid is determined based on the terrain. Specifically, the number of navigation grids can be determined according to the terrain corresponding to the virtual scene, and this is not specifically limited in this example embodiment. After obtaining the navigation grid, the cells included in the navigation grid can be initialized, that is, the passage size of each cell in the navigation grid is set to a first preset size, wherein the first preset size is used to represent the maximum size of the cell that allows the passage unit to pass through, and the first preset secondary size can be 1, and this first preset size is not specifically limited in this example embodiment.

[0075] In step S120, obstacles included in the virtual scene are determined, a first cell in the navigation grid is determined based on the obstacles, and a passage size of the first cell is updated.

[0076] After the navigation grid is initialized, the obstacles included in the virtual scene can be obtained. In the virtual scene, the passable units and obstacles are placed on the terrain, and the cells where the obstacles are located are blocked cells.

[0077] In this example embodiment, reference Figure 3 As shown, determining an obstacle included in the virtual scene, determining a first cell in the navigation grid based on the obstacle, and updating the passage size of the first cell includes:

[0078] Step S310: determining a position of the obstacle in the virtual scene, and determining a first cell corresponding to the obstacle in the navigation grid according to the position;

[0079] Step S320: Update the pass size of the first cell to a second preset size, wherein the second preset size is smaller than the first preset size.

[0080] In the following, step S310 and step S320 will be further explained and illustrated. Specifically, the position of the obstacle in the virtual scene is determined, and according to the position of the obstacle in the virtual scene, the first cell corresponding to the obstacle in the navigation grid is determined. Since the first cell corresponds to the obstacle in the scene, the passage size of the first cell in the navigation grid can be set to a second preset size, and the second preset size is smaller than the first preset size. Specifically, the second preset size can be set to 0.

[0081] In step S130, based on the comparison result of the passage sizes of the second cell and the adjacent cells of the second cell, a target cell is determined from the second cell, and the passage size of the target cell is incremented to obtain a target navigation grid.

[0082] In this exemplary embodiment, after the blocking condition of obstacles is updated in the navigation grid, the pass size of the remaining second cells in the navigation grid may be incremented to obtain the target navigation grid.

[0083] In this example embodiment, reference Figure 4 As shown, based on the comparison result of the passage size between the second cell and the adjacent cell of the second cell, a target cell is determined from the second cell, and the passage size of the target cell is incremented to obtain a target navigation grid, including:

[0084] Step S410: traverse the navigation grid to obtain a second cell in the navigation grid and an adjacent cell of the second cell, where the second cell is a cell in the navigation grid except the first cell;

[0085] Step S420: Compare the passage size of the second cell with the passage size of the adjacent cells of the second cell to obtain a comparison result, and determine the target cell in the second cell according to the comparison result;

[0086] Step S430: Increment the passage size of the target cell to obtain the target navigation grid.

[0087] In the following, step S410-step S430 will be further explained and illustrated. Specifically, the cells included in the navigation grid are traversed to obtain the second cell and the adjacent cells of the second cell included in the navigation grid, wherein the second cell is the cell in the navigation grid except the first cell corresponding to the obstacle. After obtaining the second cell and the adjacent cells of the second cell, the passage size of the second cell and the adjacent cells of the second cell are compared to obtain a comparison result, and the target cell in the second cell is determined according to the comparison result. After determining the target cell, the passage size of the target cell can be incremented to obtain the target navigation grid.

[0088] Further, in this exemplary embodiment, the comparing the passage size of the second cell with the passage size of a cell adjacent to the second cell to obtain a comparison result, and determining a target cell in the second cell according to the comparison result, includes:

[0089] When the pass sizes of the adjacent cells of the second cell are all larger than the pass size of the second cell, the second cell is determined as the target cell; wherein the adjacent cells of the second cell are cells adjacent to the second cell above, below, left and right.

[0090] Specifically, when comparing the pass size of the second cell with the pass sizes of the adjacent cells of the second cell, when the pass sizes of the adjacent cells of the second cell are all larger than the pass size of the second cell, the second cell is determined as the target cell, wherein the adjacent cells of the second cell are four cells adjacent to the second cell above, below, left and right.

[0091] refer to Figure 5 As shown, the passage size of the target cell is incremented to obtain the target navigation grid, including:

[0092] Step S510. Obtain the preset self-increment size, and increment the pass size of the target cell based on the preset self-increment size;

[0093] Step S520: Based on the incremented cell, obtain the target navigation grid.

[0094] In the following, step S510 and step S520 will be further explained and illustrated. Specifically, when the target cell is incremented in size, a preset increment size can be first obtained, and the preset increment size is added to the passage size of the target cell to obtain the passage size of the target cell after the increment, and the target navigation grid is obtained according to the passage size after the increment. The preset increment size is 2.

[0095] For example, the passage size of the second cell is compared with the passage sizes of the adjacent cells of the second cell. When the passage sizes of the adjacent cells of the second cell are all greater than or equal to the passage size of the second cell, the second cell is determined as the target cell, and the passage size of the target cell is incremented, wherein the increment size is 2. That is, when the passage sizes of the adjacent cells of the second cell are all greater than or equal to the passage size of the current cell, the passage size of the second cell is increased by 2. If the passage size of the second cell is 1, after the increment, the passage size of the second cell is 3, that is, the passage cells with a size less than or equal to 3 can pass through the second cell.

[0096] In this example embodiment, the path finding method further includes:

[0097] When the second cell does not have at least one cell adjacent to the second cell above, below, left, or right, the pass size of the second cell is not incremented.

[0098] Specifically, in the navigation grid, when the number of adjacent cells of the second cell is less than 4, that is, the second cell does not have at least one cell adjacent to the upper, lower, left or right of the second cell, the passage size of the adjacent cells of the second cell can be regarded as the second preset size, that is, the passage size of the adjacent cells of the second cell is set to 0. Since the passage size of the adjacent cells of the second cell is smaller than the current cell, the passage size of the second cell is not incremented.

[0099] For example, refer to Figure 6 The navigation grid shown in the figure, in which the shaded cell is the second cell, the passage size of the second cell is 1, and in the navigation grid, the adjacent cells of the second cell are only the left adjacent cells and the bottom adjacent cells, that is, the number of adjacent cells of the second cell is less than 4. At this time, the passage size of the adjacent cells of the second cell can be regarded as the default passage size of 0, the passage size of the current cell is larger than the passage size of the adjacent cells of the current cell, and the passage size of the current cell is not incremented.

[0100] In this example embodiment, the passage size of the second cell included in the navigation grid may be incremented multiple times. The path finding method may also include:

[0101] The passage size of the second cell is cyclically incremented until a preset number of increments is reached or the passage size of the second cell reaches a preset maximum passage size.

[0102] Specifically, the second cells included in the navigation grid may be traversed multiple times, that is, the passage sizes of the second cells included in the navigation grid may be cyclically incremented until the number of cycles reaches a preset number of increments or the passage size of any second cell in the navigation grid reaches a preset maximum passage size. The preset number of increments may be 3 or 5, and the preset number of increments is not specifically limited in this example embodiment; the preset maximum passage size may be 5 or 7, and the preset maximum passage size is not specifically limited in this example embodiment.

[0103] For example, after updating the navigation grid cell size based on obstacles, the resulting navigation grid is as follows Figure 7 As shown, in Figure 7 Based on the navigation grid shown in FIG. 1 , the passage size of the second cell is incremented. When the preset maximum passage size is 7, the target navigation grid is as follows: Figure 8 shown.

[0104] In step S140, a path is found for a passable unit in the target navigation grid based on a preset path finding algorithm to obtain a path finding result.

[0105] In this example embodiment, after obtaining the target navigation grid, the preset pathfinding algorithm can be run to find a suitable path for the passable unit. During the pathfinding process, the passability of each cell is determined by comparing the size of the passable unit and the passable size of each cell in the navigation grid. When the size of the passable unit is larger than the passable size of the cell, the preset pathfinding algorithm regards the cell as a blocked state. When the size of the passable unit is less than or equal to the passable size of the cell, the preset pathfinding algorithm regards the cell as a passable state. Each passable unit has a corresponding size. For example, an infantryman with a size of 1 can occupy at least 1 cell and at most 4 cells; an engineering machine with a size of 5 occupies at least 25 cells. During the pathfinding process, each cell is abstracted as a circle, and the size of the passable unit is the diameter of the circle. Only when the passable size of the cell in the navigation grid is greater than or equal to the diameter of the circle can the passable unit pass through the cell.

[0106] refer to Fig. 9As shown, the method of performing pathfinding for a pass unit in the target navigation grid based on a preset pathfinding algorithm to obtain a pathfinding result includes:

[0107] Step S910: Acquire the size of the passable unit, compare the size of the passable unit with the passable size of the second cell in the target navigation grid, and obtain a third cell that the passable unit can pass;

[0108] Step S920: Perform pathfinding in the third cell based on the preset pathfinding algorithm to obtain a pass path of the pass unit.

[0109] In the following, step S910 and step S920 will be further explained and illustrated. Specifically, the pass size of the second cell in the navigation grid and the size of the pass unit are obtained, and the size of the pass unit is compared with the pass size of each second cell in the navigation grid, and a third cell that can pass through the pass unit is obtained in the second cell, that is, the third cell is a part of the second cell, and its pass size is greater than or equal to the size of the pass unit. In other words, the pass unit can pass through any cell included in the third cell, but in order to improve the mobility efficiency of the pass unit, pathfinding can be performed in the third cell based on a preset pathfinding algorithm to obtain the optimal path of the pass unit. Among them, the preset pathfinding algorithm can be the Dijkstra algorithm or the A* algorithm, which is not specifically limited in this example embodiment.

[0110] by Fig.10 Taking the target navigation grid shown in FIG. 1 as an example, if the size of the traffic unit is 3, the path finding method disclosed in the present invention is further explained and illustrated using the Dijkstra algorithm. Fig.10In the example, the starting cell marked with a circle is the path finding starting point, and the ending cell marked with a star is the path finding ending point. First, the distance from each cell in the target navigation grid to the ending cell is set to infinity, which can be represented by 00 and is located in the upper left corner of each cell. Secondly, set the distance of the end cell to 0, and add the end cell to the first list, take the end cell from the first list, and traverse the adjacent cells of the end cell. When the pass size of the adjacent cells of the end cell is less than 3, skip the adjacent cell. When the pass size of the adjacent cells of the end cell is greater than or equal to 3, add 1 to the distance from the current taken cell to the end cell to obtain the distance from the adjacent cell of the taken cell to the end cell, and add the adjacent cell to the first list. Take out the cells included in the first list in turn. For the taken cell, traverse the adjacent cells of the taken cell and judge the pass size of the adjacent cell. When the pass size of the adjacent cell is greater than or equal to 3, add 1 to the distance from the taken cell to the end cell to obtain the distance from the adjacent cell of the taken cell to the end cell, and add the adjacent cell to the first list. Repeat the above process until the first list is empty or the first list contains the starting cell. The distances of each cell to the end cell are obtained as follows: Fig.11 As shown. Fig.11 In the process of finding a path from the starting cell, if it is determined that there are multiple next cells with the same distance to the end cell and less than the distance from the current cell to the end cell, and the multiple next cells are adjacent cells of the current cell, any cell can be selected from the multiple next cells as the next cell of the current cell. Fig.11 Taking the target navigation grid shown as an example, when the pass unit is located at the cell in the 2nd row and 7th column (the distance from the cell to the end cell is 11, and the pass size is 3), there are two cells in the next cell of the cell, one is the cell in the 2nd row and 8th column, and the other is the cell in the 3rd row and 7th column. In these two cells, the distance to the end cell is 10, so any cell can be selected as the next cell. Fig.12 One of the possible paths obtained by pathfinding according to the Dijkstra algorithm is shown.

[0111] The pathfinding method provided by the exemplary embodiment of the present disclosure has at least the following advantages: on the one hand, a navigation grid corresponding to a virtual scene is obtained, the passage size of the navigation grid is initialized, obstacles in the virtual scene are determined, and the passage size of the first cell included in the navigation grid is updated based on the obstacles. For the second cell in the virtual scene, the target cell in the second cell can be determined based on the comparison result of the passage size of the second cell and the adjacent cells of the second cell, and the passage size of the target cell is incremented to obtain the target navigation grid, which realizes the storage of the passage size through the navigation grid, can meet the selection of appropriate channels for navigation of passage units of different sizes, does not need to store multiple layers of NavMesh, and reduces memory usage. On the other hand, the above-mentioned pathfinding method is applicable to maps of any size, which enhances the flexibility and scalability of pathfinding.

[0112] The exemplary embodiment of the present disclosure also provides a path finding device, referring to Fig.13 As shown, it may include: a navigation grid initialization module 1310, a grid size update module 1320, a target navigation grid generation module 1330 and a path finding module 13410. Among them:

[0113] A navigation grid initialization module 1310 is used to obtain a navigation grid corresponding to the virtual scene and initialize the pass size of the navigation grid;

[0114] A grid size updating module 1320, configured to determine obstacles included in the virtual scene, determine a first cell in the navigation grid based on the obstacles, and update a passage size of the first cell;

[0115] A target navigation grid generation module 1330 is used to determine a target cell from the second cell based on a comparison result of the passage sizes of the second cell and the adjacent cells of the second cell, and to increment the passage size of the target cell to obtain a target navigation grid;

[0116] The path finding module 1340 is used to find paths for the passable units in the target navigation grid based on a preset path finding algorithm to obtain path finding results.

[0117] The specific details of each module in the above-mentioned path-finding device have been described in detail in the corresponding path-finding method, so they will not be repeated here.

[0118] In an exemplary embodiment of the present disclosure, the navigation grid initialization module includes:

[0119] A navigation grid determination module, used to obtain a terrain corresponding to the virtual scene, and determine the navigation grid based on the terrain;

[0120] The passage size initialization module is used to initialize the passage size of the cells included in the navigation grid, and set the passage size of each cell in the navigation grid to a first preset size, wherein the first preset size is used to represent the maximum size allowed for passage of the cell.

[0121] In an exemplary embodiment of the present disclosure, the grid size updating module includes:

[0122] An obstacle determination module, used to determine a position of the obstacle in the virtual scene, and determine a first cell corresponding to the obstacle in the navigation grid according to the position;

[0123] The first cell size updating module is used to update the pass size of the first cell to a second preset size, wherein the second preset size is smaller than the first preset size.

[0124] In an exemplary embodiment of the present disclosure, the target navigation grid generation module includes:

[0125] a second cell determining module, configured to traverse the navigation grid and obtain a second cell in the navigation grid and an adjacent cell of the second cell, wherein the second cell is a cell in the navigation grid except the first cell;

[0126] A passage size comparison module, used for comparing the passage size of the second cell with the passage size of the adjacent cells of the second cell to obtain a comparison result, and determining a target cell in the second cell according to the comparison result;

[0127] The navigation grid determination module is used to automatically increase the passage size of the target cell to obtain the target navigation grid.

[0128] In an exemplary embodiment of the present disclosure, the pass size comparison module includes:

[0129] When the pass sizes of the adjacent cells of the second cell are all larger than the pass size of the second cell, the second cell is determined as the target cell; wherein the adjacent cells of the second cell are cells adjacent to the second cell above, below, left and right.

[0130] In an exemplary embodiment of the present disclosure, the target navigation grid generation module includes:

[0131] A passing size auto-increment module, used to obtain the preset auto-increment size, and auto-increment the passing size of the target cell based on the preset auto-increment size;

[0132] The navigation grid generation module is used to obtain the target navigation grid based on the self-incremented cells.

[0133] In an exemplary embodiment of the present disclosure, the device further includes:

[0134] The adjacent cell determination module is used for not increasing the pass size of the second cell when there is no at least one cell adjacent to the second cell above, below, left, or right.

[0135] In an exemplary embodiment of the present disclosure, the device further includes:

[0136] A cyclic self-incrementing module is used to cyclically increase the passage size of the second cell until a preset number of self-increment times is reached or the passage size of the second cell reaches a preset maximum passage size.

[0137] In an exemplary embodiment of the present disclosure, the path finding module includes:

[0138] A third cell determination module is used to obtain the size of the passable unit, compare the size of the passable unit with the passable size of the second cell in the target navigation grid, and obtain a third cell that the passable unit can pass;

[0139] A path finding result acquisition module is used to perform path finding in the third cell based on the preset path finding algorithm to obtain the pass path of the pass unit.

[0140] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0141] In addition, although the steps of the method of the present invention are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0142] In an exemplary embodiment of the present invention, an electronic device capable of implementing the above method is also provided.

[0143] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".

[0144] Refer to the following Fig.14 14 to 15. The electronic device 1400 according to this embodiment of the present invention is described. Fig.14 The electronic device 1400 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0145] like Fig.14 As shown, the electronic device 1400 is in the form of a general computing device. The components of the electronic device 1400 may include, but are not limited to: the at least one processing unit 1410, the at least one storage unit 1420, a bus 1430 connecting different system components (including the storage unit 1420 and the processing unit 1410), and a display unit 1440.

[0146] The storage unit stores program codes, which can be executed by the processing unit 1410, so that the processing unit 1410 performs the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification. For example, the processing unit 1410 can perform the following steps: Figure 1 The steps S110 shown in the figure are as follows: obtaining a navigation grid corresponding to a virtual scene, and initializing a passage size of the navigation grid; S120: determining obstacles included in the virtual scene, determining a first cell in the navigation grid based on the obstacles, and updating the passage size of the first cell; S130: determining a target cell from the second cell based on a passage size comparison result between a second cell and an adjacent cell of the second cell, and incrementing the passage size of the target cell to obtain a target navigation grid; S140: performing pathfinding for the passage unit in the target navigation grid based on a preset pathfinding algorithm to obtain a pathfinding result.

[0147] The storage unit 420 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 14201 and / or a cache storage unit 14202 , and may further include a read-only storage unit (ROM) 14203 .

[0148] The storage unit 1420 may also include a program / utility 14204 having a set (at least one) of program modules 14205, such program modules 14205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0149] Bus 1430 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0150] The electronic device 1400 may also communicate with one or more external devices 1500 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1400, and / or communicate with any device that enables the electronic device 1400 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1450. Furthermore, the electronic device 1400 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 1360. As shown, the network adapter 1460 communicates with other modules of the electronic device 1400 via a bus 1430. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID (Redundant Arrays of Independent Disks, independent redundant disk array) systems, tape drives, and data backup storage systems.

[0151] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present invention.

[0152] In an exemplary embodiment of the present invention, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of this specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to perform the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of this specification.

[0153] The program product for implementing the above method according to an embodiment of the present invention may adopt a portable compact disk read-only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.

[0154] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0155] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0156] The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF (Radio Frequency), etc., or any suitable combination of the above.

[0157] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).

[0158] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0159] Other embodiments of the invention will readily occur to those skilled in the art after considering the specification and practicing the invention invented herein. This application is intended to cover any variations, uses or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art that are not invented by the present invention. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the claims.

Claims

1. A path-finding method, characterized in that: include: Acquire a navigation grid corresponding to the virtual scene, and initialize the pass size of the navigation grid; Determining an obstacle included in the virtual scene, determining a first cell in the navigation grid based on the obstacle, and updating a passage size of the first cell; Based on the comparison result of the passage size between the second cell and the adjacent cells of the second cell, determining the target cell from the second cell, and increasing the passage size of the target cell to obtain the target navigation grid; Based on a preset pathfinding algorithm, pathfinding is performed for the pass unit in the target navigation grid to obtain a pathfinding result.

2. The path-finding method according to claim 1, characterized in that: The obtaining of the navigation grid corresponding to the virtual scene and initializing the pass size of the navigation grid includes: Acquire a terrain corresponding to the virtual scene, and determine the navigation grid based on the terrain; The passage sizes of cells included in the navigation grid are initialized, and the passage size of each cell in the navigation grid is set to a first preset size, wherein the first preset size is used to represent the maximum size of the cell allowed to pass.

3. The method according to claim 2, characterized in that Determining an obstacle included in the virtual scene, determining a first cell in the navigation grid based on the obstacle, and updating a passage size of the first cell, including: Determine a position of the obstacle in the virtual scene, and determine a first cell corresponding to the obstacle in the navigation grid according to the position; The pass size of the first cell is updated to a second preset size, wherein the second preset size is smaller than the first preset size.

4. The method according to claim 1, characterized in that: The step of determining a target cell from the second cell based on a comparison result of the passage sizes of the second cell and the adjacent cells of the second cell, and incrementing the passage size of the target cell to obtain a target navigation grid includes: Traversing the navigation grid, acquiring a second cell in the navigation grid and an adjacent cell of the second cell, where the second cell is a cell in the navigation grid except the first cell; Comparing the passage size of the second cell with the passage size of the adjacent cells of the second cell to obtain a comparison result, and determining a target cell in the second cell according to the comparison result; The passage size of the target cell is incremented to obtain the target navigation grid.

5. The method according to claim 4, characterized in that The comparing the passage size of the second cell with the passage size of the adjacent cell of the second cell to obtain a comparison result, and determining the target cell in the second cell according to the comparison result, comprises: When the pass sizes of the adjacent cells of the second cell are all larger than the pass size of the second cell, the second cell is determined as the target cell; wherein the adjacent cells of the second cell are cells adjacent to the second cell above, below, left and right.

6. The method according to claim 4, characterized in that The target navigation grid is obtained by increasing the pass size of the target cell, including: Acquire the preset self-increment size, and increment the pass size of the target cell based on the preset self-increment size; Based on the incremented cell, the target navigation grid is obtained.

7. The method according to claim 4, characterized in that The method further comprises: When the second cell does not have at least one cell adjacent to the second cell above, below, left, or right, the pass size of the second cell is not incremented.

8. The method according to claim 4, characterized in that The method further comprises: The passage size of the second cell is cyclically incremented until a preset number of increments is reached or the passage size of the second cell reaches a preset maximum passage size.

9. The method according to claim 1, characterized in that: The performing pathfinding for the pass unit in the target navigation grid based on the preset pathfinding algorithm to obtain a pathfinding result includes: Acquire the size of the passable unit, compare the size of the passable unit with the passable size of the second cell in the target navigation grid, and obtain a third cell through which the passable unit can pass; Pathfinding is performed in the third cell based on the preset pathfinding algorithm to obtain a passing path of the passing unit.

10. A path-finding device, characterized in that: include: A navigation grid initialization module, used to obtain a navigation grid corresponding to a virtual scene and initialize the pass size of the navigation grid; A grid size updating module, configured to determine obstacles included in the virtual scene, determine a first cell in the navigation grid based on the obstacles, and update a passage size of the first cell; a target navigation grid generation module, configured to determine a target cell from the second cell based on a comparison result of the passage sizes of the second cell and the adjacent cells of the second cell, and to increment the passage size of the target cell to obtain a target navigation grid; The pathfinding module is used to perform pathfinding for the pass unit in the target navigation grid based on a preset pathfinding algorithm to obtain a pathfinding result.

11. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing unit, the path-finding method according to any one of claims 1 to 9 is implemented.

12. An electronic device, characterized in that: include: Processing unit; as well as A storage unit, used to store executable instructions of the processing unit; Wherein, the processing unit is configured to execute the path-finding method described in any one of claims 1-9 by executing the executable instructions.

13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the path-finding method according to any one of claims 1 to 9 is implemented.