Path generation method and device
By determining the start and terminate cells in the game map and generating the target path based on the cell marking strategy and path algorithm, the problem of A* algorithm being inefficient in large game scenarios is solved, and fast and accurate path generation is achieved, satisfying the Game performance requirements.
Patent Information
- Application Number
- CN202411243366.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2024-12-20
AI Technical Summary
In the prior art, the A* algorithm is inefficient in large game scenarios when used for game pathfinding, especially when the number of cells is large, which affects game performance.
By determining the starting cell and terminating cell in the game map, the target path is generated based on the cell marking strategy and path algorithm, the path cell data is pre-stored to improve data efficiency, and reference the starting cell and terminating when generating the path Data for cells.
Even when the cell size is large, the target path can be generated quickly and accurately, meeting the performance requirements of game pathfinding and improving the path generation efficiency.
Smart Images

Figure CN119158257A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a path generation method and device. Background Art
[0002] In large-scale game scenes, a cell map can be obtained by simplifying the top view of the game voxel scene. The voxel scene data pathfinding in the game usually uses the A* algorithm for game pathfinding. However, this real-time pathfinding method is not applicable to large-scale game scenes with a large number of cells. The large number of cells will directly affect the efficiency of path construction and will also have a negative impact on game performance. Therefore, a more effective path generation method is urgently needed to solve the above problems. Summary of the invention
[0003] In view of this, the embodiment of the present application provides a path generation method to solve the technical defects existing in the prior art. The embodiment of the present application also provides a path generation device, a computing device, a computer-readable storage medium, and a computer program product.
[0004] According to a first aspect of an embodiment of the present application, a path generation method is provided, including:
[0005] Determine a start cell and an end cell in a game map comprising a plurality of cells and path cells, wherein the path cells are determined in the plurality of cells according to a cell marking strategy;
[0006] Determining the starting cell data of the starting cell and the ending cell data of the ending cell based on the game map and the path cell data associated with the path cell;
[0007] A target path between the start cell and the end cell is generated based on a path algorithm, a plurality of cells, the path cells, the path cell data, the start cell data and the end cell data.
[0008] Optionally, the determination of the path cell includes:
[0009] Dividing the game map into an obstacle area and a non-obstacle area according to the terrain of the game map, and determining an obstacle cell corresponding to the obstacle area and a non-obstacle cell corresponding to the non-obstacle area from a plurality of cells;
[0010] Determine the obstacle marking spacing of the obstacle area and the non-obstacle marking spacing of the non-obstacle area according to the cell marking strategy;
[0011] Marking obstacle path cells in the obstacle cells according to the obstacle marking interval, and marking non-obstacle path cells in the non-obstacle cells according to the non-obstacle marking interval;
[0012] The obstacle path cells and the non-obstacle path cells are used as the path cells.
[0013] Optionally, the determining the starting cell data of the starting cell and the ending cell data of the ending cell based on the game map and the path cell data associated with the path cell comprises:
[0014] Determining a starting neighboring cell associated with the starting cell in the game map, and generating starting cell data based on the path cell data, the starting cell and the starting neighboring cells;
[0015] A termination adjacent cell associated with the termination cell is determined in the game map, and termination cell data is generated based on the path cell data, the termination cell and the termination adjacent cell.
[0016] Optionally, after determining the starting cell and the ending cell in the game map including the plurality of cells and the path cells, the method further comprises:
[0017] Determine the area cell of the starting cell in the game map according to the cell threshold;
[0018] In a case where the end cell is included in the area cells, a target cell path between the start cell and the end cell is generated based on the area cells.
[0019] Optionally, the generating a target path between the starting cell and the ending cell based on a path algorithm, a plurality of cells, the path cells, the path cell data, the starting cell data and the ending cell data comprises:
[0020] Determine a target path cell in the path cells based on a path algorithm, the start cell data, and the end cell data;
[0021] determining an auxiliary cell among a plurality of cells based on the target path cell, the path cell data, the start cell data, and the end cell data;
[0022] A target path between the start cell and the end cell is generated based on the target path cell and the auxiliary cell.
[0023] Optionally, before determining the starting cell and the ending cell in the game map including the plurality of cells and the path cells, the method further includes:
[0024] In a case where it is determined based on the game map and the path cells that there is an uncovered area in the game map, a path cell is added to the uncovered area based on the path cells.
[0025] Optionally, after generating the target path between the starting cell and the ending cell based on the path algorithm, the plurality of cells, the path cells, the path cell data, the starting cell data and the ending cell data, the method further includes:
[0026] In the case where the target path includes overlapping cells, overlapping path cells associated with the overlapping cells are determined, and the overlapping path cells are removed from the path cells.
[0027] According to a second aspect of an embodiment of the present application, a path generation device is provided, including:
[0028] A determination module is configured to determine a start cell and an end cell in a game map comprising a plurality of cells and path cells, wherein the path cells are determined in the plurality of cells according to a cell marking strategy;
[0029] A first generating module is configured to determine the starting cell data of the starting cell and the ending cell data of the ending cell based on the game map and the path cell data associated with the path cell;
[0030] The second generating module is configured to generate a target path between the starting cell and the ending cell based on a path algorithm, a plurality of cells, the path cells, the path cell data, the starting cell data and the ending cell data.
[0031] According to a third aspect of an embodiment of the present application, a computing device is provided, including:
[0032] Memory and processor;
[0033] The memory is used to store computer executable instructions, and the processor implements the steps of the path generation method when executing the computer executable instructions.
[0034] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the path generation method are implemented.
[0035] According to a fifth aspect of the embodiments of the present application, a chip is provided, which stores a computer program, and the computer program implements the steps of the path generation method when executed by the chip.
[0036] According to a sixth aspect of the embodiments of this specification, a computer program product is provided, including a computer program or instructions, which implement the steps of the above-mentioned path generation method when executed by a processor.
[0037] The path generation method provided by the present application is to determine the starting cell and the ending cell in a game map containing multiple cells and path cells, wherein the path cells are determined in multiple cells according to the cell marking strategy; the starting cell data of the starting cell is determined based on the path cell data of the game map and the associated path cells, and the ending cell data of the ending cell is generated based on the path algorithm, multiple cells, path cells, path cell data, starting cell data and ending cell data to generate the target path between the starting cell and the ending cell. Before generating the target path, the path cells are marked in the multiple cells contained in the game map, and the path cell data is generated based on the path cells, and the path cell data is stored in advance, so as to realize the pre-generation of data. After the path cell data is generated, a path search request can be received, and the target path is generated based on the pre-generated path cell data, the starting cell and the ending cell. When generating the target path, the path cell, the path cell data, the starting cell data and the ending cell data determined based on the path cell data can be referred to. Even if the cell volume in the game map is large, the target path can be generated quickly and accurately to meet the performance requirements of the game path search. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 is a flow chart of a path generation method provided by an embodiment of the present application;
[0039] Figure 2 This is a schematic diagram of marking game map cells of a path generation method provided by an embodiment of the present application;
[0040] Figure 3 This is a schematic diagram of game map cell data of a path generation method provided by an embodiment of the present application;
[0041] Figure 4 This is a schematic diagram of a game map target path cell of a path generation method provided in an embodiment of the present application;
[0042] Figure 5 This is a schematic diagram of a target path of a game map of a path generation method provided in an embodiment of the present application;
[0043] Figure 6 This is a schematic diagram of adding path cells to a game map according to a path generation method provided in an embodiment of the present application;
[0044] Figure 7 This is a schematic diagram of overlapping cells on a game map of a path generation method provided by an embodiment of the present application;
[0045] Figure 8 It is a processing flow chart of a path generation method applied to game path generation provided by an embodiment of the present application;
[0046] Fig. 9 is a structural schematic diagram of a path generation device provided by an embodiment of the present application;
[0047] Fig.10 It is a structural block diagram of a computing device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0048] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0049] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0050] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first.
[0051] First, the terms involved in one or more embodiments of the present invention are explained.
[0052] A* (A-star) algorithm: An algorithm widely used in path finding and graph traversal. It is a heuristic search algorithm that aims to find the shortest path from the starting point to the end point. When searching, the A* algorithm needs to determine the distance from the current position to the target point, and always search along the position closest to the target point.
[0053] Dijikstra algorithm: Dijkstra algorithm is an algorithm for solving the single-source shortest path problem in a directed graph. Dijkstra algorithm starts from a vertex and calculates the shortest path from that vertex to all other vertices in the graph. Its basic principle is to select the point with the shortest distance to expand each time and update the distance of its adjacent points until the shortest path from the source point to all other vertices is found.
[0054] Figure 1 A flow chart of a path generation method provided according to an embodiment of the present application is shown, which specifically includes the following steps:
[0055] Step 102: Determine a starting cell and an ending cell in a game map including a plurality of cells and path cells, wherein the path cells are determined in the plurality of cells according to a cell marking strategy.
[0056] Specifically, the game map can be a game map of a large-scale scene game. From the developer's perspective, the bottom layer of the game map is divided into a grid map, and the grid map contains multiple cells with a regular arrangement order. The cell division of the game map can be implemented based on the length and width of the cell. The cells in the game map can be squares or other shapes such as rectangles, and this embodiment does not impose any restrictions on this. Any cell in the game map can be used as a starting cell, and accordingly, any cell can be used as a termination cell. The cell marking strategy can be a marking strategy corresponding to the terrain dimension in the game map, or it can be a marking strategy corresponding to the range dimension of the game map. More path cells are marked in places with complex terrain, and fewer path cells are marked in places with simple terrain. Path cells refer to at least two cells selected in the game map according to the cell marking strategy. Path cells are used to perform path planning based on path cells when performing path planning based on the game map. Path cells are used to assist in generating a target path.
[0057] Based on this, a cell marking strategy is determined, and path cells are marked in multiple cells according to the cell marking strategy. Path cells are used to assist in generating a target path between a start cell and an end cell. A game map containing multiple cells and path cells is determined, and a start cell and an end cell are determined in the game map. A certain distance needs to be between the start cell and the target cell.
[0058] Furthermore, considering the differences in terrain in various areas of the game map, when marking path cells, different obstacle marking intervals can be determined according to the terrain differences. The specific implementation is as follows:
[0059] The game map is divided into an obstacle area and a non-obstacle area according to the terrain of the game map, and obstacle cells corresponding to the obstacle area and non-obstacle cells corresponding to the non-obstacle area are determined in multiple cells; the obstacle marking spacing of the obstacle area and the non-obstacle marking spacing of the non-obstacle area are determined according to the cell marking strategy; obstacle path cells are marked in the obstacle cells according to the obstacle marking spacing, and non-obstacle path cells are marked in the non-obstacle cells according to the non-obstacle marking spacing; the obstacle path cells and the non-obstacle path cells are used as the path cells.
[0060] Specifically, the obstacle area may be an area with complex and rugged terrain in the game map. The obstacle area contains insurmountable obstacles, and the path can be planned by bypassing the obstacles; the non-obstacle area may be an area with relatively flat and open terrain in the game map. The non-obstacle area does not contain obstacles, or contains short obstacles that can be crossed. The cells occupied by obstacles and affected by obstacles in the game map are regarded as obstacle cells, and the obstacle cells may be all the cells contained in the obstacle area. The other cells in the game map except obstacle cells can be regarded as non-obstacle cells, and the non-obstacle cells can also be all the cells contained in the non-obstacle area. The obstacle marking spacing refers to the cell spacing for cell marking of cells in the obstacle area; the non-obstacle marking spacing refers to the cell spacing for cell marking of cells in the non-obstacle area; the obstacle marking spacing may be smaller than the non-obstacle marking spacing. The obstacle path cells are the cells marked in the obstacle area, and the non-obstacle path cells are the cells marked in the non-obstacle area.
[0061] Based on this, according to the terrain of the game map, the area in the game map where there are insurmountable obstacles is divided into an obstacle area, and the area in the game map where there are no insurmountable obstacles is divided into a non-obstacle area. The obstacle area and the non-obstacle area together constitute the map area of the game map. Determine the obstacle cells corresponding to the obstacle area and the non-obstacle cells corresponding to the non-obstacle area in multiple cells. Determine the obstacle marking spacing of the obstacle area and the non-obstacle marking spacing of the non-obstacle area according to the cell marking strategy. The obstacle marking spacing can be less than the non-obstacle marking spacing. Mark the obstacle path cells in the obstacle cells according to the obstacle marking spacing, and mark the non-obstacle path cells in the non-obstacle cells according to the non-obstacle marking spacing. Use the obstacle path cells and the non-obstacle path cells as path cells.
[0062] For example, Figure 2 This is a schematic diagram of the game map cell markings, looking down at the game map, such as Figure 2As shown, the game map is divided into equally spaced grids. Black grids represent impassable grids and also represent obstacles. According to the complexity of the terrain, the game map is divided into an obstacle area marked by a red frame and a non-obstacle area outside the red frame. Since the obstacle area contains more obstacles and the path planning is more difficult, the obstacle marking spacing in the obstacle area is determined to be 1; the non-obstacle area contains fewer obstacles and the path planning is less difficult, so the non-obstacle marking spacing in the non-obstacle area is determined to be 3. Mark the obstacle cells in the obstacle area based on the obstacle marking spacing, and mark the non-obstacle cells in the non-obstacle area based on the non-obstacle marking spacing, and the 44 blue cells 1-44 can be marked. These 44 cells are path cells.
[0063] In summary, the game map is divided into obstacle areas and non-obstacle areas according to the terrain of the game map, and then obstacle cells are determined in the obstacle area and non-obstacle cells are determined in the non-obstacle area, and obstacle path cells and non-obstacle path cells are used as path cells. Incorporating terrain factors into the marking of path cells can improve the efficiency and accuracy of subsequent path planning.
[0064] Furthermore, considering that there is a situation where the starting cell is close to the ending cell, the target cell path between the starting cell and the target cell can be directly generated. The specific implementation is as follows:
[0065] The area cell of the starting cell is determined in the game map according to the cell threshold; when the terminating cell is included in the area cell, a target cell path between the starting cell and the terminating cell is generated based on the area cell.
[0066] Specifically, the cell threshold is a pre-set number of cells around the starting cell. The regional cell refers to the search in the directions of the starting cell, right, front, back, left front, right front, left back and right back, etc., until the number of cells found is greater than the cell threshold. The found cell is the regional cell. The target cell path is composed of the cells contained in the regional cell connected in sequence.
[0067] Based on this, the cell threshold is used to search for cells in all directions in the game map starting from the starting cell to determine the regional cells of the starting cell. When the regional cells contain the terminal cell, it means that the starting cell is close to the terminal cell. Based on the regional cells, candidate paths between the starting cell and the terminal cell are generated, and the candidate path with the smallest path cost is selected as the target cell path according to the path cost.
[0068] Using the above example, the cell threshold can be set to 20,000. With the starting cell as the center, search in the left, right, front, back, left front, right front, left back, and right back directions until 20,000 cells are found, and these 20,000 cells are used as region cells. Plan the target cell path between the starting cell and the target cell in the region cells.
[0069] In summary, when the region cell includes the terminating cell, the target cell path between the starting cell and the terminating cell is generated based on the region cell, thereby improving the generation efficiency of the target cell path.
[0070] Step 104: Determine the starting cell data of the starting cell and the ending cell data of the ending cell based on the game map and the path cell data associated with the path cell.
[0071] Specifically, after determining the starting cell and the ending cell in the game map containing multiple cells and path cells, the starting cell data of the starting cell and the ending cell data of the ending cell can be determined based on the path cell data of the game map and the associated path cells, wherein the starting cell data refers to the path data between the starting cell and multiple cells within the starting cell range, and the starting cell data can be the movement cost or movement consumption between the starting cell and multiple cells within the starting cell range. Correspondingly, the ending cell data refers to the connectivity data between the ending cell and multiple cells within the ending cell range, and the ending cell data can be the movement cost or movement consumption between the ending cell and multiple cells within the ending cell range.
[0072] Based on this, after determining the starting cell and the ending cell in the game map containing multiple cells and path cells, the starting cell data of the starting cell is determined based on the game map and the path cell data associated with the path cell, and the ending cell data of the ending cell is determined based on the game map and the path cell data associated with the path cell.
[0073] In actual applications, path cell data is generated based on path cells and path connectivity strategies. Path cell data can be generated when the server starts and stored until the server shuts down. After the path cell data is generated, the subsequent target path construction can be performed. The cell connectivity strategy can be the connectivity range of the cell, and the connectivity range of the cell can be set to twice the standard spacing. Path cell data refers to the connectivity data between at least two adjacent path cells. The connectivity data specifically refers to the moving path between two adjacent path cells and the moving cost of the moving path. The moving cost is the moving cost between adjacent cells on the left or right or up and down, and the moving cost between diagonally adjacent cells.
[0074] Based on this, the connectivity range of the path cell is determined based on the cell connectivity strategy. The connected path cells of each path cell are determined according to the connectivity range of the cell, and then the connectivity data of each path cell is calculated to form the path cell data of the path cell. The path cell data can be calculated based on the Dijikstra algorithm.
[0075] like Figure 3 As shown in the figure, after the blue path cells are determined, the connectivity range of the path cells is determined to be twice the standard spacing of the path cells according to the cell connectivity strategy. Taking path cell 1 as an example, the cells connected to path cell 1 are connected path cells 2, 3, 6, 7, 11 and 13. The movement cost between adjacent cells on the left or right or up and down is 10, and the movement cost between adjacent cells diagonally is 14. The movement cost of the movement path from path cell 1 to each connected path cell is calculated respectively, and the connectivity data is composed of the movement path and the movement cost of the movement path. In practical applications, the standard spacing can be set to 8 meters, and the spacing of more complex terrain in the game can be 4 meters or 2 meters.
[0076] Furthermore, considering that the game map may be a large game scene, building a target path in this game scene consumes a lot of resources, which affects the game experience. Therefore, after determining the path cell, path cell data can be generated for the path cell. Subsequent path planning can be completed directly based on the path cell data. The specific implementation is as follows:
[0077] Determine a starting adjacent cell associated with the starting cell in the game map, and generate starting cell data based on the path cell data, the starting cell and the starting adjacent cells; determine a terminating adjacent cell associated with the terminating cell in the game map, and generate terminating cell data based on the path cell data, the terminating cell and the terminating adjacent cells.
[0078] Specifically, the starting adjacent cell refers to the cell obtained by extending the search to the left, right, front, back, left front, right front, left back and right back with the starting cell as the center. The ending adjacent cell refers to the cell obtained by extending the search to the left, right, front, back, left front, right front, left back and right back with the ending cell as the center. The starting cell data is the connected data of the starting cell, and the ending cell data is the connected data of the ending cell.
[0079] Based on this, the starting neighboring cell associated with the starting cell is determined in the game map, and the starting cell data is generated based on the path cell data, the starting cell and the starting neighboring cell. The ending neighboring cell associated with the ending cell is determined in the game map, and the ending cell data is generated based on the path cell data, the ending cell and the ending neighboring cell. Both the starting cell data and the ending cell data can be calculated based on the Dijikstra algorithm.
[0080] Using the above example, Figure 3 As shown, the starting cell S and the ending cell D are determined in the game map. The starting adjacent cell (pink cell) of the starting cell S is determined, and the ending adjacent cell (light yellow cell) of the ending cell D is determined. The starting cell data and the ending cell data are generated based on the path cell data.
[0081] In summary, the starting cell data corresponding to the starting cell and the ending cell data corresponding to the ending cell data are determined, so as to facilitate subsequent path planning for the starting cell and the ending cell, thereby improving the efficiency of path planning.
[0082] Step 106: Generate a target path between the starting cell and the ending cell based on a path algorithm, a plurality of cells, the path cells, the path cell data, the starting cell data and the ending cell data.
[0083] Specifically, after determining the starting cell data of the starting cell and the terminating cell data of the terminating cell based on the game map and the path cell data associated with the path cell, the target path between the starting cell and the terminating cell can be generated based on the path algorithm, multiple cells, path cells, path cell data, starting cell data and terminating cell data, wherein the path algorithm can be any algorithm that can realize path planning or path finding, such as the A* algorithm. The target path is a cell path composed of cells passing from the starting cell to the terminating cell. The target path consists of multiple sequentially connected cells, and the starting point of the target path is the starting cell, and the end point is the terminating cell.
[0084] Based on this, after determining the starting cell data of the starting cell and the terminating cell data of the terminating cell based on the game map and the path cell data associated with the path cell, the target path between the starting cell and the terminating cell is generated by determining each cell one by one based on the path algorithm, multiple cells, path cells, path cell data, starting cell data and terminating cell data.
[0085] Furthermore, considering that the path cells are evenly distributed in the game map, when constructing the target path between the starting cell and the target cell, path planning can be performed based on the path cells. The specific implementation is as follows:
[0086] Based on the path algorithm, the starting cell data and the ending cell data, a target path cell is determined in the path cell; based on the target path cell, the path cell data, the starting cell data and the ending cell data, an auxiliary cell is determined in multiple cells; based on the target path cell and the auxiliary cell, a target path between the starting cell and the ending cell is generated.
[0087] Specifically, the path algorithm may be an A* algorithm, and the target path cell is the path cell that needs to be passed through for path planning from the starting cell to the ending cell. The path between the target path cells can be determined based on the path cell data, and the target path can be obtained by splicing the paths corresponding to the path cell data. The target path cell plays a guiding role in the generation of the target path.
[0088] Based on this, the target path cell that needs to be passed between the starting cell and the ending cell is determined in the path cell based on the path algorithm, the starting cell data and the ending cell data. Auxiliary cells are determined in multiple cells based on the target path cell, the path cell data, the starting cell data and the ending cell data, and the target path cell plays a guiding role in the generation of the target path. After the auxiliary cells are determined, the target path between the starting cell and the ending cell can be generated based on the target path cell and the auxiliary cells.
[0089] Using the above example, we use the A* algorithm to find the path from the starting point S, and combine the path cell data, the starting cell data, and the ending cell data to determine multiple continuous target path cells with a small path cost in the path cells. Figure 4 As shown in the figure, the A* algorithm is used to find the path between the starting cell S and the ending cell D, and six target path cells, namely 35, 30, 22, 23, 19 and 10, can be determined. The six yellow target path cells serve as a guide for the construction of the subsequent target path. Figure 5 As shown, the green auxiliary cell can be determined based on the determined starting cell S, the ending cell D and the yellow target path cell, and the target path cell and the auxiliary cell together constitute the target path between the starting cell and the ending cell.
[0090] In summary, the target path between the start cell and the end cell is generated based on the target path cell and the auxiliary cell. The target path cell plays a guiding role in determining the auxiliary cell, thereby improving the generation efficiency of the target path.
[0091] Furthermore, considering the influence of the terrain in the game map, there is a problem that narrow roads cannot be identified. Narrow roads belong to uncovered areas. For this area, path cells need to be added to improve the connectivity of the cells. The specific implementation is as follows:
[0092] In a case where it is determined based on the game map and the path cells that there is an uncovered area in the game map, a path cell is added to the uncovered area based on the path cells.
[0093] Specifically, the uncovered area may be an area in the game map where the path is narrow and does not contain path cells.
[0094] Based on this, when it is determined that there is an uncovered area in the game map based on the game map and the path cells, the target cell is determined in the uncovered area based on the cell spacing corresponding to the path cells, and the target cell is marked as a path cell.
[0095] Using the above example, Figure 6 As shown, black cells represent impassable cells. From the starting cell S to the ending cell D, path cells 16 and 19 will be passed, but they are far apart. Considering the calculation time and memory consumption during pre-calculation, the search range between path cells will not be expanded indefinitely. 16 and 19 will be considered as disconnected during pre-calculation. Therefore, it is necessary to reduce the interval between path cells in the path complex area (purple area) where the path cells are not covered, so that the path cells are denser. Path cells 36 and path cells 37 are determined in the purple area to increase the connectivity between path cells.
[0096] In summary, path cells are added in the uncovered area based on the path cells, thereby improving the connectivity between the path cells.
[0097] Furthermore, when constructing the target path, due to the influence of the terrain of the game map, the same cell may be passed twice in the target path. In this case, the path cells need to be eliminated. The specific implementation is as follows:
[0098] In the case where the target path includes overlapping cells, overlapping path cells associated with the overlapping cells are determined, and the overlapping path cells are removed from the path cells.
[0099] Specifically, an overlapping cell refers to a cell that is passed at least twice in the target path. An overlapping path cell refers to a path cell that is closer to the overlapping cell.
[0100] Based on this, when the target path contains overlapping cells, it means that walking along the target path cells will pass through the same cell at least twice. The path cells closer to the overlapping cells are determined as overlapping path cells, and the overlapping path cells are removed from the path cells.
[0101] Using the above example, Figure 7 As shown, the target path is the path from the starting cell S through the path cell 32, the path cell 28, the path cell 34 and the green cell to the end cell D. The target path from the starting cell S to the end cell D can be summarized as S->32->28->34->D. Therefore, 32->28 and 28->34 will pass through cell C, and a loop is formed at this time. It is necessary to remove the path cell 28 that causes the loop to avoid the problem of the target path containing a loop.
[0102] In summary, when the target path contains overlapping cells, the overlapping path cells associated with the overlapping cells are removed from the path cells to simplify the path and avoid detours in the planned target path.
[0103] The path generation method provided by the present application is to determine the starting cell and the ending cell in a game map containing multiple cells and path cells, wherein the path cells are determined in multiple cells according to the cell marking strategy; the starting cell data of the starting cell is determined based on the path cell data of the game map and the associated path cells, and the ending cell data of the ending cell is generated based on the path algorithm, multiple cells, path cells, path cell data, starting cell data and ending cell data to generate the target path between the starting cell and the ending cell. Before generating the target path, the path cells are marked in the multiple cells contained in the game map, and the path cell data is generated based on the path cells, and the path cell data is stored in advance, so as to realize the pre-generation of data. After the path cell data is generated, a path search request can be received, and the target path is generated based on the pre-generated path cell data, the starting cell and the ending cell. When generating the target path, the path cell, the path cell data, the starting cell data and the ending cell data determined based on the path cell data can be referred to. Even if the cell volume in the game map is large, the target path can be generated quickly and accurately to meet the performance requirements of the game path search.
[0104] The following combination Figure 8Taking the application of the path generation method provided in this application to the game path generation as an example, the path generation method is further described. Figure 8 A processing flow chart of a path generation method for game path generation provided by an embodiment of the present application is shown, which specifically includes the following steps:
[0105] Step 802: Determine the game map corresponding to the game scene, and divide the game map into cells to obtain a cell map.
[0106] In the game pathfinding scenario, the game scene is generally a large game scene. In the cell map corresponding to the game scene, there are a large number of grids, the game pathfinding is relatively difficult, and the performance requirements are relatively strict.
[0107] Step 804: Mark the path cells in the cell map according to the cell marking strategy, and predetermine the connectivity data of the path cells.
[0108] Before pathfinding, determine the coordinate set of the key grids of the game scene. The key grid is the path cell. The key grid can be a grid set composed of grids with fixed coordinate intervals, or it can be determined by adding smaller coordinate intervals according to the complexity of the terrain in the game scene. After the key grid is determined, the Dijikstra algorithm is used to calculate the connectivity data of the key grid and the surrounding key grids in sequence. The connectivity data includes which key grids the key grid is connected to, which grids will be passed when the path between the key grids is formed, that is, the key grid path, and the minimum cost of the key grid path. The connectivity range of the surrounding key grids can be calculated by taking twice the default spacing of the key grids.
[0109] Step 806: Determine the starting cell and the ending cell in the cell map, and search for the starting neighboring cell of the starting cell based on the path algorithm.
[0110] Determine the starting point and the end point, and search for the grids around the starting point. Starting from the starting cell, search in the left, right, front, back, left front, right front, left back, and right back directions until 20,000 grids are found, and these 20,000 grids are used as the starting adjacent cells. The Dijikstra algorithm can be used to search for the starting adjacent cells.
[0111] Step 808: Determine whether the starting adjacent cell includes the ending cell, if so, execute step 810; if not, execute step 812.
[0112] Step 810: Determine a target cell path between a start cell and an end cell based on a cell map.
[0113] Step 812: Determine the starting connected data of the starting cell based on the starting adjacent cells.
[0114] Arrange the connectivity data from the starting point to each adjacent cell in the surrounding starting adjacent cells to form the starting connectivity data. The starting connectivity data contains the starting path from the starting point to each adjacent cell in the surrounding starting adjacent cells, and the minimum cost of the starting path. When arranging the paths between the starting point and the surrounding starting adjacent cells, only the paths from the starting point to the surrounding key grids can be recorded. The paths to non-key grids can be omitted.
[0115] Step 814: Find the terminal neighboring cells of the terminal cell based on the path algorithm, and determine the terminal connected data of the terminal cell based on the terminal neighboring cells.
[0116] Starting from the terminal cell, search in the left, right, front, back, left front, right front, left back and right back directions until 20,000 grids are found, and these 20,000 grids are used as the terminal adjacent cells. Sort out the connectivity data around the terminal point. The Dijikstra algorithm can be used to search for the terminal adjacent cells. Sort out the connectivity data from the terminal point to each adjacent cell in the surrounding terminal adjacent cells to form the terminal connectivity data. The terminal connectivity data contains the terminal path from the terminal point to each adjacent cell in the surrounding terminal adjacent cells, as well as the minimum cost of the terminal path. When sorting out the paths between the terminal point and the surrounding terminal adjacent cells, only the paths between the terminal point and the surrounding key grids can be recorded. The paths to non-key grids do not need to be recorded.
[0117] Step 816: Determine auxiliary cells in the path cells based on the path algorithm, the starting cell, the ending cell, the connectivity data of the path cells, the starting connectivity data, and the ending connectivity data.
[0118] Based on the A* algorithm, the minimum cost of the path between path cells in the connectivity data of the path cells, the starting connectivity data and the ending connectivity data, the target key grid associated with the starting point and the ending point is determined in the key grid. The target key grid is an auxiliary cell used to assist in generating the target path between the starting point and the ending point.
[0119] Step 818: Construct a target path between the start cell and the target cell based on the connectivity data of the path cells, the cell map and the auxiliary cells.
[0120] The target path between the starting point and the end point is generated by combining the cell map of the game scene, the minimum cost path in the connectivity data of the path cells, and the target key grid.
[0121] In summary, before generating the target path, the path cells are first marked in the multiple cells contained in the game map, and the connectivity data of the path cells are pre-calculated. When constructing the target path between the starting cell and the target cell, the pre-calculated connectivity data can be used. This improves the efficiency of path generation. After determining the cell map and path cells, when searching for the starting cell and the target cell, the auxiliary cells that assist in path construction can be determined first, and then the target path between the starting cell and the target cell can be constructed based on the auxiliary cells and the cell map, reducing the resource consumption of path finding and improving the efficiency of path construction.
[0122] Corresponding to the above method embodiment, the present application also provides a path generation device embodiment, Fig. 9 FIG. 1 shows a schematic diagram of the structure of a path generation device provided by an embodiment of the present application. Fig. 9 As shown, the device comprises:
[0123] A determination module 902 is configured to determine a start cell and an end cell in a game map comprising a plurality of cells and path cells, wherein the path cells are determined in the plurality of cells according to a cell marking strategy;
[0124] A first generating module 904 is configured to determine the starting cell data of the starting cell and the ending cell data of the ending cell based on the game map and the path cell data associated with the path cell;
[0125] The second generating module 906 is configured to generate a target path between the starting cell and the ending cell based on a path algorithm, a plurality of cells, the path cells, the path cell data, the starting cell data and the ending cell data.
[0126] In an optional embodiment, the determining module 902 is further configured to:
[0127] Dividing the game map into an obstacle area and a non-obstacle area according to the terrain of the game map, and determining an obstacle cell corresponding to the obstacle area and a non-obstacle cell corresponding to the non-obstacle area from a plurality of cells;
[0128] Determine the obstacle marking spacing of the obstacle area and the non-obstacle marking spacing of the non-obstacle area according to the cell marking strategy;
[0129] Marking obstacle path cells in the obstacle cells according to the obstacle marking interval, and marking non-obstacle path cells in the non-obstacle cells according to the non-obstacle marking interval;
[0130] The obstacle path cells and the non-obstacle path cells are used as the path cells.
[0131] In an optional embodiment, the first generating module 904 is further configured to:
[0132] Determining a starting neighboring cell associated with the starting cell in the game map, and generating starting cell data based on the path cell data, the starting cell and the starting neighboring cells;
[0133] A termination adjacent cell associated with the termination cell is determined in the game map, and termination cell data is generated based on the path cell data, the termination cell and the termination adjacent cell.
[0134] In an optional embodiment, the determining module 902 is further configured to:
[0135] Determine the area cell of the starting cell in the game map according to the cell threshold;
[0136] In a case where the end cell is included in the area cells, a target cell path between the start cell and the end cell is generated based on the area cells.
[0137] In an optional embodiment, the second generating module 906 is further configured to:
[0138] Determine a target path cell in the path cells based on a path algorithm, the start cell data, and the end cell data;
[0139] determining an auxiliary cell among a plurality of cells based on the target path cell, the path cell data, the start cell data, and the end cell data;
[0140] A target path between the start cell and the end cell is generated based on the target path cell and the auxiliary cell.
[0141] In an optional embodiment, the second generating module 906 is further configured to:
[0142] In a case where it is determined based on the game map and the path cells that there is an uncovered area in the game map, a path cell is added to the uncovered area based on the path cells.
[0143] In an optional embodiment, the second generating module 906 is further configured to:
[0144] In the case where the target path includes overlapping cells, overlapping path cells associated with the overlapping cells are determined, and the overlapping path cells are removed from the path cells.
[0145] The path generation method provided by the present application is to determine the starting cell and the ending cell in a game map containing multiple cells and path cells, wherein the path cells are determined in multiple cells according to the cell marking strategy; the starting cell data of the starting cell is determined based on the path cell data of the game map and the associated path cells, and the ending cell data of the ending cell is generated based on the path algorithm, multiple cells, path cells, path cell data, starting cell data and ending cell data to generate the target path between the starting cell and the ending cell. Before generating the target path, the path cells are marked in the multiple cells contained in the game map, and the path cell data is generated based on the path cells, and the path cell data is stored in advance, so as to realize the pre-generation of data. After the path cell data is generated, a path search request can be received, and the target path is generated based on the pre-generated path cell data, the starting cell and the ending cell. When generating the target path, the path cell, the path cell data, the starting cell data and the ending cell data determined based on the path cell data can be referred to. Even if the cell volume in the game map is large, the target path can be generated quickly and accurately to meet the performance requirements of the game path search.
[0146] The above is a schematic scheme of a path generation device of the present embodiment. It should be noted that the technical scheme of the path generation device and the technical scheme of the path generation method described above belong to the same concept. For details not described in detail in the technical scheme of the path generation device, please refer to the description of the technical scheme of the path generation method described above. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method, and each functional module is not an actual functional division or separation definition. The device claim defined by such a group of functional modules should be understood as a functional module architecture that mainly implements the solution through a computer program recorded in the specification, and should not be understood as a physical device that mainly implements the solution through hardware.
[0147] Fig.10 The structure block diagram of a computing device 1000 provided according to an embodiment of the present application is shown. The components of the computing device 1000 include but are not limited to a memory 1010 and a processor 1020. The processor 1020 is connected to the memory 1010 via a bus 1030, and the database 1050 is used to store data.
[0148] The computing device 1000 also includes an access device 1040 that enables the computing device 1000 to communicate via one or more networks 1060. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1040 may include one or more of any type of network interface (e.g., a network interface card (NIC)) that is wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0149] In one embodiment of the present application, the above components of the computing device 1000 and Fig.10 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig.10 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.
[0150] The computing device 1000 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 1000 may also be a mobile or stationary server.
[0151] The processor 1020 is used to execute computer executable instructions of the path generation method.
[0152] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned path generation method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned path generation method.
[0153] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which are used in a path generation method when executed by a processor.
[0154] The above is a schematic solution of a computer-readable storage medium of this embodiment. It should be noted that the technical solution of the storage medium and the technical solution of the above-mentioned path generation method belong to the same concept, and the details not described in detail in the technical solution of the storage medium can be referred to the description of the technical solution of the above-mentioned path generation method.
[0155] An embodiment of the present application further provides a chip storing a computer program, which implements the steps of the path generation method when executed by the chip.
[0156] An embodiment of the present specification also provides a computer program product, including a computer program or instructions, which implements the steps of the above-mentioned path generation method when executed by a processor.
[0157] The above is a schematic solution of a computer program product of this embodiment. It should be noted that the technical solution of the computer program product and the technical solution of the above-mentioned path generation method belong to the same concept, and the details not described in detail in the technical solution of the computer program product can be referred to the description of the technical solution of the above-mentioned path generation method.
[0158] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0159] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0160] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0161] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0162] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.
Claims
1. A path generation method, characterized in that: include: Determine a start cell and an end cell in a game map comprising a plurality of cells and path cells, wherein the path cells are determined in the plurality of cells according to a cell marking strategy; Determining the starting cell data of the starting cell and the ending cell data of the ending cell based on the game map and the path cell data associated with the path cell; A target path between the start cell and the end cell is generated based on a path algorithm, a plurality of cells, the path cells, the path cell data, the start cell data and the end cell data.
2. The path generation method according to claim 1, characterized in that: The determination of the path cell includes: Dividing the game map into an obstacle area and a non-obstacle area according to the terrain of the game map, and determining an obstacle cell corresponding to the obstacle area and a non-obstacle cell corresponding to the non-obstacle area from a plurality of cells; Determine the obstacle marking spacing of the obstacle area and the non-obstacle marking spacing of the non-obstacle area according to the cell marking strategy; Marking obstacle path cells in the obstacle cells according to the obstacle marking interval, and marking non-obstacle path cells in the non-obstacle cells according to the non-obstacle marking interval; The obstacle path cells and the non-obstacle path cells are used as the path cells.
3. The path generation method according to claim 1, characterized in that: The determining of the starting cell data of the starting cell and the ending cell data of the ending cell based on the game map and the path cell data associated with the path cell comprises: Determining a starting neighboring cell associated with the starting cell in the game map, and generating starting cell data based on the path cell data, the starting cell and the starting neighboring cells; A termination adjacent cell associated with the termination cell is determined in the game map, and termination cell data is generated based on the path cell data, the termination cell and the termination adjacent cell.
4. The path generation method according to claim 1, characterized in that: After determining the starting cell and the ending cell in the game map including the plurality of cells and the path cells, the method further includes: Determine the area cell of the starting cell in the game map according to the cell threshold; In a case where the end cell is included in the area cells, a target cell path between the start cell and the end cell is generated based on the area cells.
5. The path generation method according to claim 1, characterized in that: The method of generating a target path between the starting cell and the ending cell based on a path algorithm, a plurality of cells, the path cells, the path cell data, the starting cell data and the ending cell data comprises: Determine a target path cell in the path cells based on a path algorithm, the start cell data, and the end cell data; determining an auxiliary cell among a plurality of cells based on the target path cell, the path cell data, the start cell data, and the end cell data; A target path between the start cell and the end cell is generated based on the target path cell and the auxiliary cell.
6. The path generation method according to claim 1, characterized in that: Before determining the starting cell and the ending cell in the game map including a plurality of cells and path cells, the method further includes: In a case where it is determined based on the game map and the path cells that there is an uncovered area in the game map, a path cell is added to the uncovered area based on the path cells.
7. The path generation method according to claim 1, characterized in that: After generating the target path between the starting cell and the ending cell based on the path algorithm, the plurality of cells, the path cells, the path cell data, the starting cell data and the ending cell data, the method further includes: In the case where the target path includes overlapping cells, overlapping path cells associated with the overlapping cells are determined, and the overlapping path cells are removed from the path cells.
8. A path generation device, characterized in that: include: A determination module is configured to determine a start cell and an end cell in a game map comprising a plurality of cells and path cells, wherein the path cells are determined in the plurality of cells according to a cell marking strategy; A first generating module is configured to determine the starting cell data of the starting cell and the ending cell data of the ending cell based on the game map and the path cell data associated with the path cell; The second generating module is configured to generate a target path between the starting cell and the ending cell based on a path algorithm, a plurality of cells, the path cells, the path cell data, the starting cell data and the ending cell data.
9. A computing device, characterized in that include: Memory and processor; The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions to implement the steps of the path generation method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by a processor, the steps of the path generation method described in any one of claims 1 to 7 are implemented.
11. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the path generation method according to any one of claims 1 to 7 are implemented.
