Game path planning methods, storage media, and program products
Patent Information
- Application Number
- CN202510203491.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-24
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2045-02-24
AI Technical Summary
[0004]但是现在自动规划路径时往往通过遍历各个游戏地图位置来选择可供通行的游戏路径,这就使得在进行自动规划路径时需要较多计算资源进行路径规划,会造成用户游戏卡顿且路径规划效率较低
[0035] According to one aspect of the embodiments of this application, a readable storage medium is provided, on which a readable program/instruction is stored, which, when executed by a processor, implements the method as described in any of the preceding claims.
Smart Images

Figure CN119770976B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of game data processing, specifically involving a game path planning method, storage medium, and program product. Background Technology
[0002] With the development of technology, the gaming industry has become increasingly popular, and games have become an indispensable form of entertainment for people. However, when playing games, users often spend a lot of time searching for target locations and maneuvering their game characters to move closer to those locations for certain "map-running" tasks.
[0003] This results in users wasting a significant amount of time and effort controlling their game characters to "run around the map," greatly diminishing the user experience. Therefore, most games introduce an automatic "map running" function, which automatically plans a path after the user sets a target location, allowing the game character to automatically move along the planned path to the target location.
[0004] However, current automatic path planning often involves traversing various locations on the game map to select a passable path. This requires significant computational resources for path planning, leading to game lag and low efficiency. Therefore, how to efficiently plan game paths is a pressing technical problem that needs to be solved. Summary of the Invention
[0005] The purpose of this application is to efficiently plan game paths.
[0006] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0007] According to one aspect of the embodiments of this application, a method for planning a game path is provided, comprising:
[0008] Obtain the movable areas and obstacle positions on the game map, including the first and second positions;
[0009] Using the first position as the start and end point respectively, construct the first path and the second path between the first position and the second position;
[0010] The target game path is obtained by combining the first path and the second path based on their intersection point.
[0011] According to one aspect of the embodiments of this application, a first path and a second path are constructed between the first position and the second position, respectively, using the first position as the start point and the end point, including:
[0012] Starting from one of the first position and the second position, and ending at the other of the first position and the second position;
[0013] Taking the starting point as the target node, obtain the initial nodes around the target node that can be moved, and calculate the score of the initial nodes based on the first distance and the second distance. The distance between the initial node and the starting point is taken as the first distance, and the distance between the initial node and the ending point is taken as the second distance.
[0014] Based on the initial node score, the target node is determined from the initial nodes;
[0015] Based on the latest determined target node, determine the next target node, until the endpoint appears in the initial node, and take the endpoint as the last target node;
[0016] Based on each of the target nodes, determine the first path and the second path.
[0017] According to one aspect of the embodiments of this application, calculating the score of the initial node based on a first distance and a second distance includes:
[0018] The actual cost and estimated cost of each initial node are calculated based on the first distance and the second distance, respectively, and the weight parameters of each node are calculated based on the obstacle information between each initial node and the endpoint.
[0019] The score of each initial node is calculated based on its actual cost, estimated cost, and weight parameters.
[0020] According to one aspect of the embodiments of this application, calculating the weight parameters of each node based on obstacle information between each initial node and the endpoint includes:
[0021] The line segment connecting the initial node and the endpoint is used as a reference line segment;
[0022] The area within the defined range of the reference line segment is determined based on the reference line segment and used as the reference area.
[0023] The number of nodes occupied by obstacles within the reference area is counted and used as the reference number;
[0024] The weight parameters of each initial node are calculated based on the number of references corresponding to each initial node.
[0025] According to one aspect of the embodiments of this application, determining a target node from the initial nodes based on the initial node score includes:
[0026] Initial nodes with scores below a set score threshold are added to a closed list, and initial nodes with scores greater than or equal to the set score threshold are added to an open list. Initial nodes in the closed list cannot be used as target nodes.
[0027] Select the initial node with the highest score from the open list as the target node, and use the initial nodes in the open list as candidate nodes.
[0028] According to one aspect of the embodiments of this application, determining the next target node based on the latest determined target node includes:
[0029] Obtain the initial nodes around the newly determined target node that can be moved;
[0030] The initial node is scored, wherein if the initial node has already been designated as a discarded node, the discarded node is not scored; if the initial node has already been designated as a candidate node, the candidate node is re-scored and used as the initial node again.
[0031] In the open list, the initial node with the highest score is selected as the next target node.
[0032] According to one aspect of the embodiments of this application, a target path is obtained by combining the first path and the second path based on the intersection of the first path and the second path, including:
[0033] When constructing the first path and the second path, if the first path and the second path intersect, the incomplete first path and the second path are directly combined to obtain the target path.
[0034] According to one aspect of the embodiments of this application, a computer device is provided, including a memory, a processor, and a readable program stored in the memory, wherein the processor executes the readable program to implement the method as described in any of the foregoing embodiments.
[0035] According to one aspect of the embodiments of this application, a readable storage medium is provided, on which a readable program / instruction is stored, which, when executed by a processor, implements the method as described in any of the preceding claims.
[0036] According to one aspect of the embodiments of this application, a program product is provided, including a readable program / instruction that, when executed by a processor, implements the method as described in any of the preceding claims.
[0037] In this application, by determining a first position and a second position, and using the first position as the starting and ending point respectively, a first path and a second path are constructed between the first and second positions. If the first path and the second path intersect, it indicates that the first path and the second path have been mutually verified, proving that the target game path determined based on the first path and the second path are both optimal game paths. Furthermore, by determining the first path and the second path bidirectionally, starting from the first position and the second position respectively, and finally determining the target game path based on the first path and the second path, this "two-pronged approach" makes the determination of the target game path more efficient.
[0038] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0039] It should be understood that the above general description and the following detailed description are exemplary and illustrative only, and should not be construed as invalidating this application. Attached Figure Description
[0040] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0041] Figure 1 A flowchart illustrating a game path planning method according to one embodiment of this application is shown.
[0042] Figure 2 A flowchart illustrating a first path and a second path between a first position and a second position, respectively, is shown according to an embodiment of this application, using a first position as the start point and an end point.
[0043] Figure 3 A flowchart illustrating the calculation of an initial node's score based on a first distance and a second distance according to an embodiment of this application is shown.
[0044] Figure 4 A flowchart illustrating the calculation of weight parameters for each node based on obstacle information between each initial node and the endpoint, according to an embodiment of this application, is shown.
[0045] Figure 5 A flowchart illustrating the process of determining a target node from initial nodes based on an initial node score, according to one embodiment of this application, is shown.
[0046] Figure 6A flowchart illustrating the determination of the next target node based on the most recently determined target node, according to one embodiment of this application, is shown.
[0047] Figure 7 A computer system architecture block diagram for implementing a game path planning method according to an embodiment of this application is shown. Detailed Implementation
[0048] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.
[0049] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0050] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0051] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0052] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0053] Please see Figure 1 , Figure 1A flowchart illustrating a game path planning method according to an embodiment of this application is shown. This application embodiment provides the steps of a game path planning method, including:
[0054] Step S110: Obtain the movable area and obstacle positions on the game map, including the first position and the second position;
[0055] Step S120: Using the first position as the start and end point respectively, construct the first path and the second path between the first position and the second position;
[0056] Step S130: Based on the intersection of the first path and the second path, combine the first path and the second path to obtain the target game path.
[0057] The above three steps are described in detail below.
[0058] In step S110, the movable area of the game map is obtained, that is, the overall location of the game map, which is also the location of each node in the game map. Theoretically, the game character can reach all nodes in the game map, but obstacles are set on the game map. If there is an obstacle on a node, the node can no longer be reached by the game character.
[0059] Therefore, the location of obstacles in the game map is obtained to determine which nodes on the game map cannot be reached.
[0060] In some embodiments, the game map is presented as a grid, with each node being a rectangle, and the movement of the game character can be viewed as the game character moving from one rectangle to another.
[0061] It should be clarified that one of the first position and the second position is the starting point on the game map, and the other is the destination on the game map. In the embodiments of this application, for the purpose of better describing the technical means included in this application, the first position is taken as the starting point and the second position as the destination.
[0062] In step S120, a first path is constructed using the first position as the starting point and the second position as the ending point. A second path is constructed using the second position as the starting point and the first position as the ending point. In other words, multiple paths are constructed between the first and second positions to select the optimal path from among these paths, or to combine these paths to obtain the optimized target game path.
[0063] On the one hand, by constructing the first path and the second path respectively, using a "two-pronged approach," multiple paths can be obtained more quickly, increasing the efficiency of determining the target game path. On the other hand, starting from different positions allows for verification and selection of the optimal path as the target game path from multiple perspectives.
[0064] Please see Figure 2 , Figure 2 This illustration shows a flowchart of constructing a first path and a second path between a first position and a second position, respectively, using a first position as the start and an end position, according to an embodiment of this application. The embodiment of this application provides step S120 of constructing a first path and a second path between a first position and a second position, respectively, using a first position as the start and an end position, including:
[0065] Step S121: Take one of the first position and the second position as the starting point and the other of the first position and the second position as the ending point;
[0066] Step S122: Using the target node as the target node, obtain the initial nodes around the target node that can be moved, and calculate the score of the initial node based on the first distance and the second distance. The distance between the initial node and the starting point is used as the first distance, and the distance between the initial node and the ending point is used as the second distance.
[0067] Step S123: Determine the target node from the initial nodes based on the initial node scores;
[0068] Step S124: Based on the latest determined target node, determine the next target node until the endpoint appears in the initial node, and take the endpoint as the last target node;
[0069] Step S125: Determine the first path and the second path based on each target node.
[0070] The above five steps are described in detail below.
[0071] In step S121, the path is constructed with one of the first position and the second position as the starting point and the other of the first position and the second position as the ending point. That is, a path is constructed with the first position as the starting point and the second position as the ending point, and a path is constructed with the second position as the starting point and the first position as the ending point.
[0072] To more vividly illustrate the technical means included in this application, the path constructed with the first position as the starting point and the second position as the ending point will be referred to as the first path. The path constructed with the second position as the starting point and the first position as the ending point will be referred to as the second path.
[0073] In step S122, paths are constructed from the first and second positions, respectively, to the second and first positions. This path construction is performed using the following techniques:
[0074] First, taking the starting point as the target node, there are four initial nodes surrounding the target node: front, back, left, and right. These four initial nodes are scored based on a first distance and a second distance, resulting in a score for each initial node. The first distance refers to the distance between the initial node and the starting point, and the second distance refers to the distance between the initial node and the destination. The target node refers to the node included in the path to be constructed.
[0075] In some embodiments, the first distance refers to the distance that needs to be traveled from the initial node to the starting point, that is, the number of target nodes between the initial node and the starting point. The second distance refers to the straight-line distance between the initial node and the destination. It should be noted that the first distance of the initial node is negatively correlated with the initial node's score, and the second distance of the initial node is negatively correlated with the initial node's score.
[0076] For example, when constructing the first path, the nodes that the final target node can theoretically move to are determined: four initial nodes: front, back, left, and right. The movement distance between each initial node and the first position is taken as the first distance, and the straight-line distance between each initial node and the second position is taken as the second distance. The score of the initial node is calculated based on the first distance and the second distance.
[0077] Please see Figure 3 , Figure 3 A flowchart illustrating the calculation of an initial node's score based on a first distance and a second distance according to an embodiment of this application is shown. This embodiment provides step S122 for calculating the initial node's score based on the first distance and the second distance, including:
[0078] Step S201: Calculate the actual cost and estimated cost of each initial node based on the first distance and the second distance, and calculate the weight parameters of each node based on the obstacle information between each initial node and the endpoint.
[0079] Step S202: Calculate the score of each initial node based on the actual cost, estimated cost, and weight parameters of each initial node.
[0080] The two steps described above are described in detail below.
[0081] In step S201, the actual cost and estimated cost of each initial node are calculated based on the first distance and the second distance, respectively. The first distance is used as the actual cost of the initial node, and the second distance is used as the estimated cost. Weight parameters for each node are calculated based on obstacle information between each initial node and the endpoint. For example, the sum of the actual cost and the estimated cost is used as the initial score, and the product of the initial score and the initial node weight parameters is used as the initial node score.
[0082] In some embodiments, taking into account the presence of obstacles in or near the initial node, after calculating the initial score of each initial node, the initial score of the initial node is multiplied by the weight parameter corresponding to each initial node to obtain the score of the initial node.
[0083] The weight parameters of the initial node can be calculated in the following way:
[0084] In some embodiments, a reference region for the initial node is defined, and the number of obstacles in the reference region and the distance between the initial node and the obstacles are calculated. The distance between the initial node and the nearest obstacle is used as the numerator, and the number of obstacles is used as the denominator. The resulting ratio is used as the weight parameter of the initial node. That is, if there is an obstacle at the initial node, the score of the initial node is zero, indicating that it is not suitable as a target node.
[0085] In some embodiments, using the initial node as a reference, a reference region for the initial node is defined. The number of obstacles in the reference region and the distance between the initial node and the obstacles are calculated. The distance between the initial node and the nearest obstacle is used as the numerator, and the number of obstacles is used as the denominator. The resulting ratio is used as the obstacle sub-value. The obstacle sub-values of each initial node are summed to obtain the obstacle sum value. The ratio of the obstacle sub-value of each initial node to the obstacle sum value is used as the weight parameter of each initial node. If an initial node has an obstacle, its obstacle sub-value is zero, and its weight parameter is also zero, indicating that the initial node cannot be a target node.
[0086] In some embodiments, the reference region can be determined by using the line segment connecting the initial node and the end point as the reference line segment.
[0087] The area within the defined range of the reference line segment is determined and used as the reference region. First, the initial nodes of the current target node are determined. Each initial node corresponds to a direction. There are generally three initial nodes, that is, three directions. This is because one of the nodes in one direction is the previous target node (the path from which the target node came), and cannot be used as an initial node. This avoids scoring nodes that cannot be used as target nodes and avoids wasting computing resources.
[0088] For example, if the initial node is to the left of the target node, then a semi-circular area is determined to the left of the reference line segment of the initial node, with the reference line segment of the initial node as the diameter, as the reference area of the initial node.
[0089] If the initial node is to the right of the target node, then a semicircular region is determined to the right of the reference line segment of the initial node, with the reference line segment of the initial node as the diameter, and this semicircular region is used as the reference region of the initial node.
[0090] If the initial node is in front of or behind the target node, the reference line segment of the initial node is bisected to obtain two sub-reference line segments. Circular regions are then defined with the diameter of each sub-reference line segment, resulting in two circular regions that serve as the reference regions for the initial node.
[0091] Because the initial nodes are close together, the lengths of the reference line segments of each initial node are similar, which ensures that the areas of the reference regions of each initial node are similar and guarantees the fairness of the weight parameters.
[0092] Please see Figure 4 , Figure 4 A flowchart illustrating the calculation of node weight parameters based on obstacle information between each initial node and the endpoint, according to an embodiment of this application, is shown. This embodiment provides step S201, which calculates node weight parameters based on obstacle information between each initial node and the endpoint, including:
[0093] Step S301: Use the line segment connecting the initial node and the end point as the reference line segment;
[0094] Step S302: Determine the area within the set range of the reference line segment based on the reference line segment, and use it as the reference area;
[0095] Step S303: Count the number of nodes occupied by obstacles in the reference area and use it as the reference number;
[0096] Step S304: Calculate the weight parameters of each initial node based on the number of references corresponding to each initial node.
[0097] The above four steps are described in detail below.
[0098] In step S301, the line segment connecting the initial node and the end point is used as the reference line segment.
[0099] To more conveniently describe the technical means in the embodiments of this application, the score of the initial node in the first path is taken as an example (the second path can refer to the first path), and the line segment connecting the initial node and the second position is used as a reference line segment.
[0100] In step S302, the area within the set range of the reference line segment is determined based on the reference line segment and used as the reference area. First, the initial nodes where the current target node exists are determined. Each initial node corresponds to a direction. Generally, there are three initial nodes, that is, three directions. This is because a node in one direction is the previous target node (the path from which the target node came) and cannot be used as an initial node. This avoids scoring nodes that cannot be used as target nodes and avoids wasting computing resources.
[0101] For example, if the initial node is to the left of the target node, then a semi-circular area is determined to the left of the reference line segment of the initial node, with the reference line segment of the initial node as the diameter, as the reference area of the initial node.
[0102] If the initial node is to the right of the target node, then a semicircular region is determined to the right of the reference line segment of the initial node, with the reference line segment of the initial node as the diameter, and this semicircular region is used as the reference region of the initial node.
[0103] If the initial node is in front of or behind the target node, the reference line segment of the initial node is bisected to obtain two sub-reference line segments. Circular regions are then defined with the diameter of each sub-reference line segment, resulting in two circular regions that serve as the reference regions for the initial node.
[0104] Because the initial nodes are close together, the lengths of the reference line segments of each initial node are similar, which ensures that the areas of the reference regions of each initial node are similar and guarantees the fairness of the weight parameters.
[0105] In step S303, the number of nodes occupied by obstacles within the reference area of each initial node is counted and used as the reference number.
[0106] In step S304, the weight parameter of each initial node is calculated based on the number of references corresponding to each initial node. For example, the sum of the number of references corresponding to each initial node is obtained as the reference sum. The ratio between the number of references corresponding to each initial node and the reference sum is used as the weight parameter of the initial node.
[0107] In some embodiments, the score of the initial node can also be calculated by referring to the distance between the initial node and obstacles within the reference area. Specifically, the distance between the initial node and the nearest obstacle is used as the numerator, the number of references or the number of obstacles is used as the denominator, and the resulting ratio is used as the weight parameter of the initial node. That is, if there is an obstacle at the initial node, the score of the initial node is zero, indicating that it is not suitable as a target node.
[0108] In some embodiments, using the initial node as a reference, a reference region for the initial node is defined. The number of obstacles in the reference region and the distance between the initial node and the obstacles are calculated. The distance between the initial node and the nearest obstacle is used as the numerator, and the number of parameters or the number of obstacles is used as the denominator. The resulting ratio is used as the obstacle sub-value. The obstacle sub-values of each initial node are summed to obtain the obstacle sum value. The ratio of the obstacle sub-value of each initial node to the obstacle sum value is used as the weight parameter of each initial node. If an initial node has an obstacle, its obstacle sub-value is zero, and its weight parameter is also zero, indicating that the initial node cannot be a target node.
[0109] In step S202, the sum of the actual cost and the estimated cost is used as the initial score of the initial node, and the product of the initial score of the initial node and the initial node weight parameter is used as the score of the initial node.
[0110] The above method can be used to score each initial node.
[0111] In step S123, the initial node with the highest score is determined as the target node based on the initial node score.
[0112] Please see Figure 5 , Figure 5 A flowchart illustrating the process of determining a target node from initial nodes based on an initial node score, according to an embodiment of this application, is shown. This embodiment provides step S123 of determining a target node from initial nodes based on an initial node score, including:
[0113] Step S401: Add initial nodes with scores less than the set score threshold to the closed list, and add initial nodes with scores greater than or equal to the set score threshold to the open list. Initial nodes in the closed list cannot be used as target nodes.
[0114] Step S402: Select the initial node with the highest score from the open list as the target node, and use the initial nodes in the open list as candidate nodes.
[0115] The two steps described above are described in detail below.
[0116] In step S401, initial nodes with scores below a set score threshold are added to a closed list, and initial nodes with scores greater than or equal to the set score threshold are added to an open list. Initial nodes in the closed list cannot be used as target nodes. That is, only initial nodes in the open list can participate in the determination of target nodes. Deprecated nodes in the closed list cannot participate in the determination of target nodes.
[0117] In some embodiments, after an initial node is selected as a target node, it is added to a closed list as a discarded node. That is, a node that has already been a target node cannot become an initial node to participate in the selection of the next target node. In this way, the number of initial nodes is reduced, thereby reducing the consumption of computing resources.
[0118] In some embodiments, abandoned nodes cannot participate in the determination of target nodes in the first path and the second path during the process of determining the first path and the second path.
[0119] In step S402, the initial node with the highest score is selected from the open list as the target node, and the initial nodes in the open list are selected as candidate nodes to distinguish the initial node of the next target node.
[0120] In this embodiment of the application, by discarding some low-scoring initial nodes, the computational resources are not wasted in the subsequent screening of initial nodes that are unlikely to become target nodes, thus saving computational resources and improving the efficiency of determining the first path and the second path.
[0121] In some embodiments, spare nodes and / or abandoned nodes are removed from the open list and / or from the open list after a set time (when they can no longer be used) to free up storage resources.
[0122] In some embodiments, for standby nodes and / or abandoned nodes, if the distance to the latest determined target node is greater than a distance threshold (making it impossible to be used again), they are removed from the open list and / or from the list to free up storage resources.
[0123] It is important to clarify that paths with different starting and ending points will each have their own corresponding open and closed lists. In other words, each path will have its own unique open and closed lists.
[0124] In step S124, based on the newly determined target node, the next target node is determined using the technical means described in step S123, until the endpoint appears in the initial node, at which point the endpoint is taken as the last target node. For example, taking the first path as an example, until the second position appears in the initial node, the second position is directly taken as the last target node. All target nodes then constitute the first path.
[0125] It is important to clarify that in some embodiments, when determining the next target node of a target node, one of its four theoretically movable nodes—front, back, left, and right—must be the previous target node of the current target node (the path it came from). Initial nodes that have already served as target nodes are removed from the initial node list. In other words, initial nodes that have already served as target nodes are no longer considered as initial nodes. That is, a node that has already served as a target node cannot become an initial node again in the selection of the next target node. This reduces the number of initial nodes and decreases the consumption of computing resources.
[0126] Please see Figure 6 , Figure 6 A flowchart illustrating the process of determining the next target node based on the latest determined target node according to an embodiment of this application is shown. This embodiment provides step S124 of determining the next target node based on the latest determined target node, including:
[0127] Step S501: Obtain the initial nodes around the newly determined target node that can be moved;
[0128] Step S502: The initial node is scored. If the initial node has already been discarded, it is not scored. If the initial node has already been selected as a candidate node, the candidate node is re-scored and used as the initial node again.
[0129] Step S503: In the open list, select the initial node with the highest score as the next target node.
[0130] The above three steps are described in detail below.
[0131] In step S501, the initial nodes around the newly determined target node that can be moved are obtained.
[0132] In step S502, the initial node is scored. If the initial node has already been designated as a discarded node, it is not scored. If the initial node has already been designated as a candidate node, the candidate node is re-scored and re-designated as an initial node to participate in the selection of the target node.
[0133] In step S503, the initial node with the highest score is selected from the open list as the next target node. This ensures that each initial node participating in the target node selection is the most recently determined initial node, avoiding waste of computing resources.
[0134] In step S125, the same technical means described in steps S121-S124 are used to determine the first path and the second path.
[0135] In this embodiment, by progressively determining the target node to define the first path and the second path, the first and second paths can be optimized. This ensures the optimization of the first target game path.
[0136] In step S130, it should be clarified that a first path and a second path are constructed simultaneously from the first position and the second position, respectively, and there is a high probability that the first path and the second path will intersect.
[0137] The target game path can be obtained by combining the first path and the second path based on their intersection point in the following ways:
[0138] Firstly, during the construction of the first and second paths, it is monitored whether the first and second paths intersect. If they do intersect, and the first and second paths are not yet fully constructed, the incomplete first and second paths can be directly spliced together from their intersection points to obtain the target game path. This method allows for faster determination of the target game path, greatly accelerating the confirmation efficiency.
[0139] If the first and second paths do not intersect during construction, then after their construction is complete, the shorter of the two paths (length refers to the number of nodes in the path) is selected as the target game path. An intersection point is a node where the first and second paths overlap.
[0140] Secondly, disregarding the intersection points of the first and second paths during construction, if the first and second paths intersect (first position and second position) after construction, the shorter of the two paths (the length of the first and second paths, which refers to the number of nodes in the path) is selected as the target game path. An intersection point is a node that overlaps between the first and second paths.
[0141] Third, without considering the intersection of the first path and the second path during the construction process, after both the first path and the second path are constructed, the number of intersections of the first path and the second path is judged; if the number of overlapping nodes (intersections) of the first path and the second path, the length of the first path, and the length of the second path are the same, it means that the first path and the second path are completely overlapping, and either the first path or the second path is selected as the target game path.
[0142] Fourth, disregarding the intersections of the first and second paths during construction, after both paths are completed, the number of intersections is determined. If the first and second paths have three or more overlapping nodes (including the first and second positions), then there are at least two sub-paths between every two adjacent overlapping nodes (the first path can be multiple or one, and the second path can be multiple or one). The sub-path with the shortest length among the sub-paths between every two adjacent overlapping nodes is selected as the target sub-path, resulting in multiple target sub-paths. All target sub-paths are then combined to obtain the target game path.
[0143] For example, disregarding the intersection of the first and second paths during construction, if the first and second paths overlap by three nodes (including the first and second positions), then there are two sub-paths from the first position to the overlapping nodes, and two sub-paths from the second position to the overlapping nodes. The shorter sub-path from the first position to the overlapping nodes is selected as the target sub-path. Similarly, the shorter sub-path from the second position to the overlapping nodes is selected as the target sub-path. Combining these two target sub-paths yields the target game path.
[0144] In this embodiment, by determining a first position and a second position, and using the first position as the starting point and the second position as the ending point respectively, a first path and a second path are constructed between the first position and the second position. If the first path and the second path intersect, it indicates that the first path and the second path have been mutually verified, proving that the target game path determined based on the first path and the second path are both optimal game paths. Furthermore, by determining the first path and the second path bidirectionally using the first position and the second position as starting points respectively, and finally determining the target game path based on the first path and the second path, this "two-pronged approach" makes the determination of the target game path more efficient.
[0145] In some embodiments, the game map is grid-like, with each grid representing a node, and the movement of the game character can be viewed as moving from one grid to another. To determine the target game path more efficiently, the following techniques can also be used for faster target game path determination:
[0146] The game map grid (nodes) is divided into M levels, where the side length of the N+1 level grid (node) is X times that of the N level grid (node), where M is a positive integer greater than or equal to 2, N is a positive integer, N+1 is less than or equal to M, and X is greater than 1.
[0147] First, the game path for the game map, including M-level nodes, is determined using the techniques employed in this application embodiment. This allows for the determination of the starting point and destination in each M-level node. Then, using each M-level grid as a sub-game map and M-1 level grids as nodes, the M-1 level game path is determined using the techniques employed in this application embodiment. This process continues until Level 1 grids are used as nodes, and Level 1 game paths are determined using the techniques employed in this application embodiment, ultimately yielding the target game path. This method allows for the progressive determination of the target game path, enabling different levels of precision for varying degrees of accuracy, increasing the accuracy of the target game path and allowing for user customization. Furthermore, this method allows for multi-threaded concurrent determination of game paths across multiple high-level grids, significantly improving the efficiency of target game path determination.
[0148] Figure 7 A computer system architecture block diagram for implementing a game path planning method according to an embodiment of this application is shown.
[0149] It should be noted that, Figure 7 The computer system 800 shown is merely an example and should not be construed as to its functionality or scope of use in the embodiments of this application.
[0150] like Figure 7As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 802 or programs loaded from storage section 808 into random access memory (RAM). The random access memory 803 also stores various programs and data required for system operation. The CPU 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output interface 805 (I / O interface) is also connected to the bus 804.
[0151] The following components are connected to the input / output interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a local area network card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the input / output interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 810 as needed so that computer programs read from it can be installed into the storage section 808 as needed.
[0152] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by central processing unit 801, it performs various functions defined in the system of this application.
[0153] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0154] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0155] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0156] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the method according to the embodiments of this application.
[0157] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.
[0158] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is solely defined by the appended claims.
Claims
1. A method for planning game paths, characterized in that, include: Obtain the movable areas and obstacle positions on the game map, including the first and second positions; Starting from one of the first position and the second position, and ending at the other of the first position and the second position; Using the starting point as the target node, obtain the initial nodes around the target node that can be moved, and calculate the actual cost and estimated cost of each initial node based on the first distance and the second distance respectively. And based on the obstacle information between each initial node and the endpoint, calculate the weight parameters of each node; wherein, The line segment connecting the initial node and the endpoint is used as a reference line segment. An area within the defined range of the reference line segment is then defined as a reference region. Specifically, if the initial node is to the left of the target node, a semicircular region is defined to the left of the reference line segment, using the initial node's reference line segment as its diameter, and this region serves as the initial node's reference region. If the initial node is to the right of the target node, a semicircular region is defined to the right of the initial node, and this region serves as the initial node's reference region. If the initial node is in front of or behind the target node, the initial node's reference line segment is bisected to obtain two sub-reference line segments. Circular regions are defined using each sub-reference line segment as its diameter, resulting in two circular regions that serve as the initial node's reference region. Calculate the number of obstacles in the reference region of the initial node, and the distance between the initial node and the obstacles. Use the distance between the initial node and the nearest obstacle as the numerator, the number of obstacles as the denominator, and the resulting ratio as the obstacle sub-value. Sum the obstacle sub-values of each initial node to obtain the obstacle sum value. Use the ratio of the obstacle sub-value of each initial node to the obstacle sum value as the weight parameter of each initial node. Based on the actual cost, estimated cost, and weight parameters of each initial node, a score is calculated for each initial node. The distance between the initial node and the starting point is taken as the first distance, and the distance between the initial node and the ending point is taken as the second distance. The sum of the actual cost and the estimated cost is taken as the initial score, and the product of the initial score and the initial node weight parameters is taken as the initial node score. Based on the initial node scores of each initial node, a target node is determined among the initial nodes; based on the latest determined target node, the next target node is determined until the endpoint appears among the initial nodes, and the endpoint is taken as the last target node; based on each target node, a first path and a second path are determined. The target game path is obtained by combining the first path and the second path based on their intersection point.
2. The method according to claim 1, characterized in that, Based on the initial node score, the target node is determined from the initial nodes, including: Initial nodes with scores below a set score threshold are added to a closed list, and initial nodes with scores greater than or equal to the set score threshold are added to an open list. Initial nodes in the closed list cannot be used as target nodes. Select the initial node with the highest score from the open list as the target node, and use the initial nodes in the open list as candidate nodes.
3. The method according to claim 2, characterized in that, Based on the latest identified target node, determine the next target node, including: Obtain the initial nodes around the newly determined target node that can be moved; The initial node is scored, wherein if the initial node has already been designated as a discarded node, the discarded node is not scored; if the initial node has already been designated as a candidate node, the candidate node is re-scored and used as the initial node again. In the open list, the initial node with the highest score is selected as the next target node.
4. The method according to claim 1, characterized in that, Based on the intersection of the first path and the second path, the first path and the second path are combined to obtain the target path, including: When constructing the first path and the second path, if the first path and the second path intersect, the incomplete first path and the second path are directly combined to obtain the target path.
5. A computer device comprising a memory, a processor, and a readable program stored in the memory, characterized in that, The processor executes the readable program to implement the method of any one of claims 1 to 4.
6. A readable storage medium, characterized in that, It stores a readable program / instruction that, when executed by a processor, implements the method of any one of claims 1 to 4.
7. A program product comprising a readable program / instructions, characterized in that, When the readable program / instruction is executed by the processor, the method of any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Path planning method and device, electronic equipment and storage medium
CN117570991A