A game character path-finding method, device and computer equipment

Generating SVO nodes and constructing open lists and closed lists by voxelizing game scenes solves the problem of low pathfinding accuracy in large game scenes, improves the accuracy and efficiency of path generation, and ensures the effectiveness of paths.

CN112657190BActive Publication Date: 2024-09-27BEIJING PIXEL SOFTWARE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011577751.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-28
Publication Date
2024-09-27
Estimated Expiration
2040-12-28

AI Technical Summary

Technical Problem

The existing Dijkstra algorithm and A* algorithm have low pathfinding accuracy in large-scale game scenes, resulting in large path generation errors and unable to meet the needs of game experience.

Method used

Generate multiple SVO nodes through voxelized game scenes, build open lists and closed lists, set the starting SVO node as the current node, obtain the movable nodes and their cost values, and continuously update the optimal nodes until the SVO node is terminated, generating path.

Benefits of technology

The accuracy of path finding and path generation efficiency are improved, the effectiveness of the path is ensured, and the problem of low path finding accuracy in the existing technology is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112657190B
    Figure CN112657190B
Patent Text Reader

Abstract

The embodiment of the present invention discloses a path-finding method, device and computer equipment for a game character. The path-finding method for a game character includes: generating multiple SVO nodes by voxelizing a game scene; obtaining a starting SVO node corresponding to the starting point coordinates and a terminating SVO node corresponding to the terminating point coordinates, and constructing an open list and a closed list; setting the starting SVO node as the current node, obtaining all movable nodes of the current node, and storing the current node, the movable node and the cost value corresponding to each movable node in the open list; moving the current node from the open list to the closed list, and selecting the movable node with the smallest cost value from the open list as the optimal node; continuously searching for the optimal node and updating the open list until the new optimal node is the terminating SVO node, and constructing a path according to the nodes in the closed list. This improves the accuracy of path-finding and optimizes the experience of game players.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of game technology, and in particular to a path-finding method, device and computer equipment for a game character. Background Art

[0002] In games, virtual characters controlled by players or non-player characters controlled by the system often need to move from one location to another. During the movement, generating paths based on pathfinding algorithms can effectively improve the player's gaming experience.

[0003] Existing pathfinding methods are usually based on pathfinding algorithms and starting points and end points to construct paths. Commonly used pathfinding algorithms include Dijkstra algorithm and A* algorithm.

[0004] However, the above two pathfinding algorithms have low pathfinding accuracy. If applied to large-scale game scenarios, even greater errors will occur. Therefore, a pathfinding method is needed to solve the above problems. Summary of the invention

[0005] In view of the above-mentioned problem of low path-finding accuracy, the present invention provides a path-finding method, device and computer equipment for a game character.

[0006] First, the first embodiment of the present invention provides a game character path finding method, comprising:

[0007] Generate multiple SVO nodes by voxelizing the game scene;

[0008] Obtain the starting SVO node corresponding to the starting point coordinates and the ending SVO node corresponding to the ending point coordinates, and construct an open list and a closed list according to the starting SVO node and the ending SVO node;

[0009] Set the starting SVO node as the current node, obtain all movable nodes of the current node, and store the current node, movable nodes and the cost value corresponding to each movable node in an open list, where the cost value is the estimated value of the game character moving from the current node to the movable node, and the movable node is the neighbor node to which the game character can move from the current node among all neighbor nodes of the current node;

[0010] Move the current node from the open list to the closed list, and select the movable node with the smallest replacement value from the open list as the optimal node;

[0011] If the optimal node is not the terminating SVO node, the optimal node is set as the new current node, the open list is updated and a new optimal node is selected again. When the new optimal node is the terminating SVO node, the terminating SVO node is moved from the open list to the closed list, and a path is constructed based on all the nodes in the closed list.

[0012] Furthermore, the path-finding method of the game character further includes:

[0013] Get the starting SVO node corresponding to the starting point coordinates and the ending SVO node corresponding to the ending point coordinates, and determine whether the starting SVO node and the ending SVO node are nodes to which the game character can move;

[0014] If the starting SVO node and / or the ending SVO node are not nodes to which the game character can move, searching for nodes to which the game character can move around the starting SVO node and / or the ending SVO node based on a preset range, and using the nodes to which the game character can move around the starting SVO node and / or the ending SVO node as new starting SVO nodes and / or new ending SVO nodes;

[0015] The open list and the closed list are constructed according to the new starting SVO node and / or the new ending SVO node.

[0016] Furthermore, the path-finding method of the above-mentioned game character also includes:

[0017] Performing a straight line test on a new start SVO node and / or a new end SVO node;

[0018] If the new start SVO node and / or the new end SVO node pass the straight line test, construct an open list and a closed list according to the new start SVO node and / or the new end SVO node;

[0019] The straight line test includes: determining whether the game character can move from the starting SVO node to a new starting SVO node along a straight line, or determining whether the ending SVO node can move to a new ending SVO node along a straight line.

[0020] Furthermore, the path-finding method of the game character further includes:

[0021] Get all movable nodes of the current node, including:

[0022] Each time a neighbor node of the current node is searched, it is determined whether the current node or the neighbor node is a terrain node, where a terrain node is a node located at the 0th or 1st layer of the SVO tree;

[0023] If the current node or the neighboring node is a terrain node, obtain the coordinates of the current node and the neighboring node;

[0024] If the game character can move from the current node to the neighboring node based on the coordinates of the current node and the coordinates of the neighboring node, the neighboring node is a movable node.

[0025] Furthermore, the path-finding method of the above-mentioned game character also includes:

[0026] Get the terrain height map according to the current game scene;

[0027] If the game character can move from the current node to the neighboring node based on the coordinates of the current node, the coordinates of the neighboring node, and the terrain height map, the neighboring node is a movable node.

[0028] Furthermore, the path-finding method of the game character further includes:

[0029] Determine whether the current node and movable node are ordinary nodes;

[0030] If the current node and the movable node are ordinary nodes, the cost of moving the game character from the current node to the movable node is calculated according to a preset cost value estimation method;

[0031] Furthermore, the path-finding method of the game character further includes:

[0032] Determine whether there is a target node in the closed list so that the game character can move from the target node to the end SVO node in a straight line;

[0033] If it exists, based on the order of entering the closed list, delete all nodes between the target node and the terminating SVO node to update the closed list, and update the path according to the nodes in the closed list.

[0034] In a second aspect, a second embodiment of the present invention further provides a path-finding device for a game character, comprising:

[0035] The node generation module is used to generate multiple SVO nodes by voxelizing the game scene;

[0036] A node acquisition module is used to acquire a starting SVO node corresponding to the starting point coordinates and an ending SVO node corresponding to the ending point coordinates, and to construct an open list and a closed list according to the starting SVO node and the ending SVO node;

[0037] The first path construction module is used to set the starting SVO node as the current node, obtain all movable nodes of the current node, and store the current node, the movable nodes and the cost value corresponding to each movable node in an open list, wherein the cost value is an estimated value of the game character moving from the current node to the movable node, and the movable node is a neighbor node to which the game character can move from the current node among all neighbor nodes of the current node;

[0038] A second path construction module is used to move the current node from the open list to the closed list, and select a movable node with the smallest replacement value from the open list as the optimal node;

[0039] The path generation module is used to set the optimal node as the new current node if the optimal node is not the termination SVO node, update the open list and select a new optimal node again, until the new optimal node is the termination SVO node, move the termination SVO node from the open list to the closed list, and build a path based on all the nodes in the closed list.

[0040] In a third aspect, a third embodiment of the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the computer program is used to run the path-finding method of the game character in the first aspect on the processor.

[0041] In a fourth aspect, a fourth embodiment of the present invention provides a computer-readable medium storing a computer program, which executes the path-finding method of the game character in the first aspect when running on the memory.

[0042] The pathfinding method of the game character described above generates multiple SVO nodes by voxelizing the game scene; obtains the starting SVO node corresponding to the starting point coordinates and the ending SVO node corresponding to the ending point coordinates from the multiple SVO nodes, and thereby constructs an open list and a closed list; sets the starting SVO node as the current node to obtain all movable nodes of the current node, and stores the current node, movable nodes, and the cost value corresponding to each movable node in the open list; moves the current node to the closed list, and selects the optimal node from the open list; continuously updates the current node, the optimal node, and the open list, until the optimal node is the ending SVO node, and then constructs a path according to the nodes in the closed list. Thus, the moving path of the game character is generated based on the SVO node, which improves the accuracy of pathfinding, and because there is a tree-like relationship between SVO nodes, the efficiency of path generation is further improved and the validity of the path is guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope of protection of the present invention. In each of the drawings, similar components are numbered similarly.

[0044] Figure 1 A schematic flow chart of a path-finding method for a game character of the present invention is shown;

[0045] Figure 2 shows a data structure diagram of an SVO node when it is running;

[0046] Figure 3 A schematic diagram of the arrangement of SVO nodes based on the Morton code form is shown;

[0047] Figure 4 A structural schematic diagram of a path-finding device for a game character of the present invention is shown. DETAILED DESCRIPTION

[0048] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.

[0049] The components of the embodiments of the present invention generally described and shown in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0050] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.

[0051] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.

[0052] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present invention belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present invention.

[0053] Example 1

[0054] In this embodiment, see Figure 1 , shows a path-finding method for a game character, including:

[0055] S110, generating multiple SVO nodes by voxelizing the game scene.

[0056] Specifically, SVO (Sparse Voxel Octree) is a 3D computer graphics rendering technology that stores voxel information based on an octree structure and is often used in ray casting and ray tracing. Voxel, or volume pixel, is the smallest unit of digital data in three-dimensional space segmentation and is used for three-dimensional imaging.

[0057] Further, see Figure 2 , Figure 2 The data structure of the SVO node when pathfinding is performed through the SVO node is shown, and the node information of the SVO is shown. In the node information, an SVO node can be uniquely identified only by the block id, child node id, number of layers, and leaf node of the SVO node.

[0058] When an SVO node is generated based on the above SVO data structure and voxelization and applied to pathfinding, the "supplementary data" in the SVO node is instantiated only when the current game scene is larger than 512m*256m. In other words, the data size of the SVO node is 20 bytes or 24 bytes when running.

[0059] Voxelization refers to simplifying the model into a uniform three-dimensional voxel grid. The above game scene can be a large game scene of 8km*8km*8km.

[0060] The present invention is based on voxelization technology and SVO data structure, divides the game scene into SVO nodes with an accuracy of 1 meter, and completes the generation and optimization of the path based on the relationship between SVO nodes.

[0061] S120 , obtaining a starting SVO node corresponding to the starting point coordinates and an ending SVO node corresponding to the ending point coordinates, and constructing an open list and a closed list according to the starting SVO node and the ending SVO node.

[0062] Specifically, the function of obtaining the SVO node according to the coordinates is implemented based on the octree structure of the SVO node, that is, through the SVO node where the game character is currently located, the nodes of the previous layer are continuously accessed until the eighth layer node is accessed, and then the nodes corresponding to the coordinates are continuously offset.

[0063] The above open list and closed list are the OPEN list and CLOSED list in the A* algorithm. The A* algorithm is the most effective direct search method for solving the shortest path in a static road network. The formula of the A* algorithm is expressed as:

[0064] f(n)=g(n)+h(n)

[0065] Among them, f(n) is the estimated cost from the initial state to the target state via state n, g(n) is the actual cost from the initial state to state n in the state space, and h(n) is the estimated cost of the best path from state n to the target state. For path search, the state is the node in the graph, and the cost is the distance between nodes.

[0066] S130, setting the starting SVO node as the current node, obtaining all movable nodes of the current node, and storing the current node, the movable nodes and the cost value corresponding to each movable node into an open list.

[0067] Among them, the cost value is the estimated value of the game character moving from the current node to the movable node, that is, the estimated value f(n) of the game character moving from the current node to the movable node; the movable node is the neighbor node to which the game character can move from the current node among all the neighbor nodes of the current node.

[0068] When building an open list based on the current node, the current node needs to be set as the father of all movable nodes, so that after the path is built, the actual path is generated according to the tree relationship in the closed list.

[0069] Further, see Figure 3 , Figure 3 A schematic diagram of the arrangement of SVO nodes based on Morton codes is shown. Figure 3 Each number in can represent an SVO node. Shifting the number representing the SVO node to the right by 3 bits can get the parent node of the node, and shifting it to the left by 3 bits can get the child node of the node. The 6 nodes closest to an SVO node along the X-axis, Y-axis and Z-axis are the neighbor nodes of the node.

[0070] Based on the parent-child relationship between the neighbor nodes and nodes, the method of accessing the neighbor nodes from the current node in the present invention is as follows:

[0071] If the current node and the neighbor node are brother nodes, then when the current node accesses the neighbor node, it jumps from the current node to the parent node according to the information of "the nth son of the parent node" in the node information of the neighbor node, and then offsets from the parent node to the neighbor node according to the information of "the nth son of the parent node"; if the current node and the neighbor node are not brother nodes, the parent node of the parent node is continuously accessed from the current node until the parent node of the neighbor node or the top-level node is accessed.

[0072] Exemplary, based on Figure 3 ,Will Figure 3Node 7 in is set as the current node, then the neighbor nodes of the current node along the direction [x,y,z,-x,-y,-z] are [14,21,35,6,5,3]. Except for node 14 in the x direction, the current node and other neighbor nodes are brother nodes. Therefore, the current node can directly access any other neighbor node through the father node. To access node 14, the current node needs to access the parent node of the parent node, that is, access node 0 on the second layer, then node 1 on the first layer, and finally access node 14 on the 0th layer.

[0073] S140, moving the current node from the open list to the closed list, and selecting a movable node with the smallest replacement value from the open list as the optimal node.

[0074] For details, please refer to Figure 2 , Figure 2 The node information of any SVO node is also shown in the figure. The node information also includes a "state mark". The state mark information is used to mark the state of this node in the A* algorithm, that is, whether this node is in one of the three states of "unvisited", "in the open list" and "in the closed list".

[0075] S150, if the optimal node is not the terminating SVO node, set the optimal node as the new current node, update the open list and select a new optimal node again, until the new optimal node is the terminating SVO node, move the terminating SVO node from the open list to the closed list, and build a path based on all the nodes in the closed list.

[0076] In other words, the present invention enables the game character to continuously move from the current node to the optimal movable node based on the starting coordinates and the ending coordinates; when the optimal node is the ending SVO node, the optimal path is constructed based on the tree relationship between the current node and the optimal node, thereby ensuring the accuracy of the path.

[0077] Furthermore, the above S120 may also be performed in the following manner:

[0078] Get the starting SVO node corresponding to the starting point coordinates and the ending SVO node corresponding to the ending point coordinates, and determine whether the starting SVO node and the ending SVO node are nodes to which the game character can move;

[0079] If the starting SVO node and / or the ending SVO node are not nodes to which the game character can move, searching for nodes to which the game character can move around the starting SVO node and / or the ending SVO node based on a preset range, and using the nodes to which the game character can move around the starting SVO node and / or the ending SVO node as new starting SVO nodes and / or new ending SVO nodes;

[0080] The open list and the closed list are constructed according to the new starting SVO node and / or the new ending SVO node.

[0081] It is understandable that when accessing SVO nodes based on coordinates, the game character cannot access SVO nodes corresponding to any coordinates, such as nodes in stones or walls, which are nodes or positions that the game character cannot move to. Therefore, when obtaining SVO nodes based on coordinates, it is also necessary to determine whether this node is a node that the game character can move to. This avoids problems such as "piercing the model" of the game character and ensures the rationality of the game.

[0082] Furthermore, when the starting SVO node and / or the ending SVO node is a node to which the game character cannot move, the node to which the game character can move within the preset range of the node is obtained. The preset range may be [4,4,4], i.e., the two closest nodes around the node in each direction of [x,y,z,-x,-y,-z].

[0083] If there is a leaf node that the game character can move to within the preset range of the starting SVO node and / or the ending SVO node, the searched leaf node will be used as the new starting SVO node and / or the ending SVO node, and the path finding will be completed based on the new starting SVO node and / or the ending SVO node.

[0084] Based on the optimization of the above starting point and end point, it is effective to avoid the situation where the game character appears in an immovable position when moving; and pathfinding is performed according to the new starting point and end point, so that when the game character needs to find a path, the game system can generate a route closest to the end coordinates and ensure that the game character appears in the most reasonable position to move.

[0085] Furthermore, the above-mentioned construction of the open list and the closed list according to the new starting SVO node and / or the new ending SVO node includes:

[0086] Performing a straight line test on a new start SVO node and / or a new end SVO node;

[0087] If the new start SVO node and / or the new end SVO node pass the straight line test, an open list and a closed list are constructed according to the new start SVO node and / or the new end SVO node.

[0088] The straight line test includes: determining whether the game character can move from the starting SVO node to a new starting SVO node along a straight line, or determining whether the ending SVO node can move from the starting SVO node to a new ending SVO node along a straight line.

[0089] Specifically, when searching for a new starting SVO node and / or a new ending SVO node, it is necessary to use the physics engine to detect whether the game character can move from the old starting SVO node and / or the old ending SVO node to the new starting SVO node and / or the new ending SVO node in a straight line, that is, whether the game character can move from the current coordinates to the new coordinates in a straight line without obstacles.

[0090] It is understandable that in order to ensure the rationality of the game, it is necessary to determine whether the nodes corresponding to the old coordinates and the new coordinates are on an unobstructed straight line, thereby preventing game players from moving the game character to an unreachable position by setting an unreachable coordinate.

[0091] Furthermore, if both the old starting SVO node and the old terminating SVO node search for new nodes, the new starting SVO node and the new terminating SVO node need to pass the above straight line test before the open list and the closed list can be constructed according to the new starting SVO node and / or the new terminating SVO node.

[0092] If the straight line test fails, the pathfinding fails, and the old starting SVO node and / or the old ending SVO node are marked as unavailable nodes, so that when the player selects the same coordinates for pathfinding again, the player is prompted that the pathfinding failed.

[0093] Furthermore, the above S110 includes:

[0094] A plurality of SVO nodes and an SVO tree are generated by voxelizing the game scene. The SVO tree includes all SVO nodes and at least three layers of SVO nodes.

[0095] It can be understood that the generation of SVO nodes represents the construction of SVO trees. The present invention generates SVO nodes and SVO trees based on voxelization and SVO structures. The SVO tree contains at least three layers of SVO nodes. Among them, the 0th layer SVO nodes and the 1st layer SVO nodes belong to terrain nodes, that is, they represent images composed of various fixed objects on the game ground that can be observed by the naked eye of players in the game scene.

[0096] When performing pathfinding based on SVO nodes and SVO trees, the number of layers that the SVO tree needs to instantiate can be adjusted according to the memory of the computer device. Specifically, the number of layers instantiated above refers to the number of layers of pre-instantiated pathfinding compressed data. Since the N+1 layer has less data than the N layer, that is, the eight sibling nodes of the N layer belong to the same parent node at the N+1 layer, increasing the number of instantiated layers means pre-instantiating only the N+1 layer nodes and not the N layer nodes, thereby reducing the memory required for pathfinding on the computer device and improving the pathfinding speed.

[0097] Based on the relationship between the SVO node and the SVO tree, the movable node in the present invention can also be obtained in the following way:

[0098] Each time a neighbor node of the current node is searched, it is determined whether the current node or the neighbor node is a terrain node;

[0099] If the current node or the neighboring node is a terrain node, obtain the coordinates of the current node and the neighboring node;

[0100] If the game character can move from the current node to the neighboring node based on the coordinates of the current node and the coordinates of the neighboring node, the neighboring node is a movable node.

[0101] Specifically, when the game character controlled by the player moves in the game scene, in addition to the constant changes in the x and y coordinates of the game character, the z coordinate will also change to a certain extent. For example, when the character floats in the air or dives, the x, y, and z coordinates will change to a certain extent. Therefore, when searching for a path, it is also necessary to determine whether the current node or neighbor is a terrain node. If so, it is necessary to determine whether the game character can reasonably move from the current node to the corresponding position of the neighbor node.

[0102] Therefore, if one of the current node and the neighboring node is a terrain node, it is necessary to determine whether the game character can reasonably complete the position change based on the coordinates of the two nodes.

[0103] Exemplarily, if an SVO node is a terrain node, it is necessary to derive the vertical coordinate value range of a smaller node based on the maximum vertical coordinate value range of the current node and the maximum vertical coordinate value range of the neighboring node, and then based on the vertical coordinate value range of the smaller node, determine whether the game object can reasonably move from the current node to the neighboring node. If so, the neighboring node is identified as a movable node.

[0104] Furthermore, the above step of "if the game character can move from the current node to the neighboring node based on the coordinates of the current node and the neighboring node, then the neighboring node is a movable node" can also be completed in the following way:

[0105] Get the terrain height map according to the current game scene;

[0106] If the game character can move from the current node to the neighboring node based on the coordinates of the current node, the coordinates of the neighboring node, and the terrain height map, the neighboring node is a movable node.

[0107] Specifically, in the game, we will use a height map to simulate the hills and valleys in real life. The height map is actually an array, and each element of the array specifies the height value of a vertex in the terrain grid. In the present invention, the sampling size of the terrain height map is 4m*4m, corresponding to the 0th level node of the SVO tree.

[0108] Furthermore, based on the terrain height map and node coordinates to describe the game scene, the node game scene can be divided into the sky, water surface and ground, and the nodes can also be divided into sky nodes, ocean nodes and terrain nodes. Based on the vertical coordinate value range of the above smaller nodes and the terrain height map, it is judged whether the game object can reasonably move from the current node to the neighboring node. In this way, the situation of mixing the sky, water surface and ground is solved, so that the game character can reasonably move from any game scene to another game scene.

[0109] In addition, when estimating the cost value of terrain nodes, the g(n) of terrain nodes is larger than that of aerial nodes and underwater nodes, so that when constructing paths, the situation of being close to the ground is avoided as much as possible, and aerial routes or underwater routes are given priority.

[0110] Based on the above-mentioned method for determining movable nodes, after the path is completed, the game character can reasonably complete autonomous movement when moving, effectively avoiding the occurrence of the "penetration" problem between the game character and the scene, improving the rationality of path construction, and solving the path-finding problem when the sky, water surface and ground are mixed, thereby improving the player's experience.

[0111] Furthermore, the cost value corresponding to each movable node is obtained by:

[0112] Determine whether the current node and movable node are ordinary nodes;

[0113] If the current node and the movable node are ordinary nodes, the cost of moving the game character from the current node to the movable node is calculated according to a preset cost value estimation method.

[0114] For details, please refer to Figure 2 , the node information of all SVO nodes in the present invention includes ordinary node identification information, and the ordinary node identification information is used to identify whether a node is an ordinary node;

[0115] Among them, the ordinary node is a node in the ordinary node set of size 4*4*4 in the 0th layer of the SVO tree; multiple adjacent surfaces are formed according to the multiple nodes in the ordinary node set. When the nodes on all adjacent surfaces are movable nodes, if an ordinary node needs to access another ordinary node, the access path can be directly constructed through the internal part of the ordinary node set; and when the nodes on a certain adjacent surface are not movable nodes, the ordinary nodes on other adjacent surfaces do not determine whether they can access any node on the adjacent surface.

[0116] Specifically, according to the properties of the trivial node set, when a trivial node visits another trivial node, the node access path is generated from the relationship between the trivial nodes inside the trivial node set, thereby reducing the number of layers that the current node needs to move up or down when visiting another node, that is, reducing the number of nodes that the current node needs to visit. In addition, when using trivial nodes for cost estimation, the cost value of trivial nodes is smaller than the estimated value of non-trivial nodes, so when finding the path, trivial nodes will be given priority for path construction.

[0117] Based on the properties of the trivial node set, when the current node and the neighboring nodes are both trivial nodes, the current node constructs an access path from the inside of the trivial point set, thereby reducing the number of nodes that the current node needs to visit to access the neighboring nodes, thereby improving the pathfinding efficiency and path construction speed.

[0118] Furthermore, when the starting SVO node and / or the ending SVO node is a trivial node, the properties of the trivial node set are not used to complete the access between nodes, but the starting SVO node and / or the ending SVO node are regarded as ordinary nodes to complete the cost estimation.

[0119] Furthermore, the path-finding method for a game character provided in this embodiment further includes the following steps:

[0120] Determine whether there is a target node in the closed list so that the game character can move from the target node to the end SVO node in a straight line;

[0121] If it exists, based on the order of entering the closed list, delete all nodes between the target node and the terminating SVO node to update the closed list, and update the path according to the nodes in the closed list.

[0122] It is understandable that when pathfinding is performed based on voxelization and SVO structure, the path constructed after pathfinding is completed may have too many turns. In order to make the result of pathfinding a smooth straight line, the constructed path needs to be optimized.

[0123] Specifically, excluding the terminating SVO node, starting from the second-to-last node, determine whether there is a target node in the closed list, so that the game character can move to the terminating SVO node in a straight line without bypassing any obstacles. If there is, delete all nodes between the target node and the terminating SVO node, and set the target node as the parent of the terminating SVO node, thereby updating the path and optimizing the path finding result according to the tree relationship diagram in the closed list.

[0124] Furthermore, in addition to determining whether there is a target node that can reach the terminating SVO node in a straight line, the terminating SVO node and the starting SVO node can be interchanged, that is, determining whether there is a target node that can reach the starting SVO node in a straight line, thereby further optimizing the path finding result.

[0125] Based on the above path optimization method, the path finding result is made more accurate and effective, ensuring that the path constructed after the path finding is completed is a smooth straight line, further optimizing the game player experience.

[0126] A pathfinding method for a game character disclosed in Example 1 of the present invention generates multiple SVO nodes by voxelizing a game scene; obtains a starting SVO node corresponding to the starting point coordinates and a terminating SVO node corresponding to the terminating point coordinates from the multiple SVO nodes, and thereby constructs an open list and a closed list; sets the starting SVO node as the current node, obtains all movable nodes of the current node, and stores the current node, movable nodes, and the cost value corresponding to each movable node in the open list; moves the current node to the closed list, and selects the optimal node from the open list; continuously updates the current node, the optimal node, and the open list, until the optimal node is the terminating SVO node, and then constructs a path according to the nodes in the closed list. Thus, the moving path of the game character is generated based on the SVO node, which improves the accuracy of pathfinding, and because there is a tree-like relationship between SVO nodes, the efficiency of path generation is further improved and the validity of the path is guaranteed.

[0127] Example 2

[0128] In this embodiment, see Figure 4 , shows a path-finding device 200 for a game character, comprising: a node generation module 210, a node acquisition module 220, a first path construction module 230, a second path construction module 240, and a path generation module 250, wherein:

[0129] A node generation module 210, for generating a plurality of SVO nodes by voxelizing the game scene;

[0130] A node acquisition module 220, for acquiring a starting SVO node corresponding to the starting point coordinates and an ending SVO node corresponding to the ending point coordinates, and constructing an open list and a closed list according to the starting SVO node and the ending SVO node;

[0131] The first path construction module 230 is used to set the starting SVO node as the current node, obtain all movable nodes of the current node, and store the current node, the movable nodes and the cost value corresponding to each movable node in an open list, wherein the cost value is an estimated value of the game character moving from the current node to the movable node, and the movable node is a neighboring node to which the game character can move from the current node among all neighboring nodes of the current node;

[0132] A second path construction module 240 is used to move the current node from the open list to the closed list, and select a movable node with the smallest replacement value from the open list as the optimal node;

[0133] The path generation module 250 is used to set the optimal node as the new current node if the optimal node is not the terminating SVO node, update the open list and select a new optimal node again, until the new optimal node is the terminating SVO node, move the terminating SVO node from the open list to the closed list, and build a path based on all the nodes in the closed list.

[0134] It should be understood that the technical solution of this embodiment is used to execute a path-finding method for a game character in the above-mentioned embodiment 1 through the synergistic effect of the above-mentioned functional modules. The implementation scheme and beneficial effects involved in embodiment 1 are also applicable in this embodiment and will not be repeated here.

[0135] This embodiment also relates to a computer device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program so that the terminal device can execute the method of the above-mentioned embodiment 1.

[0136] In this embodiment, a readable storage medium is also provided, which stores a computer program. When the computer program is run on a processor, the method of the above-mentioned embodiment 1 is executed.

[0137] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow chart, and the combination of boxes in the structure diagram and / or the flow chart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0138] In addition, the functional modules or units in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0139] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0140] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A path-finding method for a game character, characterized in that: include: Generate multiple SVO nodes by voxelizing the game scene; Obtaining a starting SVO node corresponding to the starting point coordinates and an ending SVO node corresponding to the ending point coordinates, and constructing an open list and a closed list according to the starting SVO node and the ending SVO node; Set the starting SVO node as the current node, obtain all movable nodes of the current node, and store the current node, the movable node and the cost value corresponding to each of the movable nodes in the open list, wherein the cost value is an estimated value of the game character moving from the current node to the movable node, and the movable node is a neighbor node to which the game character can move from the current node among all neighbor nodes of the current node; Move the current node from the open list to the closed list, and select the movable node with the smallest replacement value from the open list as the optimal node; If the optimal node is not the terminating SVO node, the optimal node is set as a new current node, the open list is updated and a new optimal node is selected again, until the new optimal node is the terminating SVO node, the terminating SVO node is moved from the open list to the closed list, and a path is constructed according to all nodes in the closed list; The obtaining of the starting SVO node corresponding to the starting point coordinates and the terminating SVO node corresponding to the terminating point coordinates, and constructing an open list and a closed list according to the starting SVO node and the terminating SVO node, includes: Obtaining a starting SVO node corresponding to the starting point coordinates and an ending SVO node corresponding to the ending point coordinates, and determining whether the starting SVO node and the ending SVO node are nodes to which the game character can move; If the starting SVO node and / or the ending SVO node are not nodes to which the game character can move, searching for nodes to which the game character can move around the starting SVO node and / or the ending SVO node based on a preset range, and using the nodes to which the game character can move around the starting SVO node and / or the ending SVO node as new starting SVO nodes and / or new ending SVO nodes; Constructing an open list and a closed list according to the new starting SVO node and / or the new ending SVO node; The node information of all the SVO nodes includes ordinary node identification information, and the ordinary node identification information is used to mark whether the SVO node is an ordinary node. The cost value corresponding to each of the movable nodes is obtained by: Determine whether the current node and the movable node are ordinary nodes; If the current node and the movable node are the ordinary nodes, then calculating the cost of the game character moving from the current node to the movable node according to a preset cost value estimation method; Among them, the ordinary node is a node in the ordinary node set, and each ordinary node in the ordinary node set constitutes a plurality of adjacent surfaces. If the current node and the movable node are the ordinary nodes, a node access path is generated according to each of the adjacent surfaces to reduce the number of nodes that the current node needs to visit when visiting the neighboring node.

2. The method according to claim 1, characterized in that The step of constructing an open list and a closed list according to the new starting SVO node and / or the new terminating SVO node includes: Performing a straight line test on the new starting SVO node and / or the new terminating SVO node; If the new starting SVO node and / or the new terminating SVO node passes the straight line test, constructing an open list and a closed list according to the new starting SVO node and / or the new terminating SVO node; The straight line test includes: determining whether the game character can move from the starting SVO node to the new starting SVO node along a straight line, or determining whether the terminating SVO node can move to the new terminating SVO node along a straight line.

3. The method according to claim 1, characterized in that The method of generating multiple SVO nodes by voxelizing the game scene includes: Generate a plurality of SVO nodes and an SVO tree by voxelizing the game scene, wherein the SVO tree includes all the SVO nodes and at least three layers of the SVO nodes; The acquiring all movable nodes of the current node includes: Each time searching for a neighbor node of the current node, determining whether the current node or the neighbor node is a terrain node, wherein the terrain node is a node located at the 0th layer or the 1st layer of the SVO tree; If the current node or the neighboring node is a terrain node, obtaining the coordinates of the current node and the coordinates of the neighboring node; If the game character can move from the current node to the neighboring node based on the coordinates of the current node and the coordinates of the neighboring node, the neighboring node is a movable node.

4. The method according to claim 3, characterized in that: If the game character can move from the current node to the neighboring node based on the coordinates of the current node and the neighboring node, then the neighboring node is the movable node, including: Get the terrain height map according to the current game scene; If the game character can move from the current node to the neighboring node based on the coordinates of the current node, the coordinates of the neighboring node and the terrain height map, the neighboring node is the movable node.

5. The method according to claim 1, characterized in that: After the step of constructing a path according to the nodes in the closed list, the method further includes: Determine whether there is a target node in the closed list so that the game character can move from the target node to the termination SVO node in a straight line direction; If so, based on the order of entering the closed list, all nodes between the target node and the terminating SVO node are deleted to update the closed list, and the path is updated according to the nodes in the closed list.

6. A path-finding device for a game character, characterized in that: A method for executing a path-finding method for a game character according to claim 1, comprising: The node generation module is used to generate multiple SVO nodes by voxelizing the game scene; A node acquisition module, used for acquiring a starting SVO node corresponding to the starting point coordinates and an ending SVO node corresponding to the ending point coordinates, and constructing an open list and a closed list according to the starting SVO node and the ending SVO node; A first path construction module is used to set the starting SVO node as the current node, obtain all movable nodes of the current node, and store the current node, the movable node and the cost value corresponding to each of the movable nodes in the open list, wherein the cost value is an estimated value of the game character moving from the current node to the movable node, and the movable node is a neighbor node to which the game character can move from the current node among all neighbor nodes of the current node; A second path construction module, used for moving the current node from the open list to the closed list, and selecting the movable node with the smallest replacement value from the open list as the optimal node; A path generation module is used to set the optimal node as a new current node if the optimal node is not the terminating SVO node, update the open list and select a new optimal node again, until the new optimal node is the terminating SVO node, move the terminating SVO node from the open list to the closed list, and construct a path based on all nodes in the closed list.

7. A computer device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is run on the processor, the path-finding method of the game character according to any one of claims 1 to 5 is executed.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is run on a processor, the path-finding method for the game character described in any one of claims 1 to 5 is executed.