CN111202985A - Path planning method and system in 2D game and electronic equipment - Google Patents

Path planning method and system in 2D game and electronic equipment Download PDF

Info

Publication number
CN111202985A
CN111202985A CN202010049832.8A CN202010049832A CN111202985A CN 111202985 A CN111202985 A CN 111202985A CN 202010049832 A CN202010049832 A CN 202010049832A CN 111202985 A CN111202985 A CN 111202985A
Authority
CN
China
Prior art keywords
platform
platforms
path
game
virtual character
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010049832.8A
Other languages
Chinese (zh)
Other versions
CN111202985B (en
Inventor
管强强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202010049832.8A priority Critical patent/CN111202985B/en
Publication of CN111202985A publication Critical patent/CN111202985A/en
Application granted granted Critical
Publication of CN111202985B publication Critical patent/CN111202985B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/55Controlling game characters or game objects based on the game progress
    • A63F13/56Computing the motion of game characters with respect to other game characters, game objects or elements of the game scene, e.g. for simulating the behaviour of a group of virtual soldiers or for path finding
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/60Methods for processing data by generating or executing the game program
    • A63F2300/64Methods for processing data by generating or executing the game program for computing dynamical parameters of game objects, e.g. motion determination or computation of frictional forces for a virtual car
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The embodiment of the invention provides a path planning method, a path planning system and electronic equipment in a 2D game, and relates to the technical field of game development. The path planning method in the 2D game comprises the steps of firstly obtaining all platforms in a game scene, including a starting point platform and an end point platform corresponding to a starting point and an end point of a path to be planned, then determining action connection relations among the platforms, and finally calculating the optimal path from the starting point platform to the end point platform by using a preset path finding algorithm according to the action connection relations. The method can abstract the platforms into points and abstract the connection relation between the platforms into the connection lines between the points, and the steps can be completed in the preprocessing of certain games of fixed maps, so that the efficiency is improved. The mobile control can be classified and controlled, and each control can be processed respectively, so that the control scheme is more flexible, and the expansibility is improved.

Description

Path planning method and system in 2D game and electronic equipment
Technical Field
The invention relates to the technical field of game development, in particular to a path planning method and system in a 2D game and electronic equipment.
Background
The path planning scheme in the existing 2D game mostly adopts a map partitioning mode, and a final path planning scheme is obtained through calculation according to the attribute and the connection relation of each map block, and the mode is suitable for the 2D game with a fixed view angle. However, the above scheme is not applicable to the platform jump type game, because the terrain organization unit of the platform jump type game is each layer of platform, if the platform is divided according to the blocks, a situation that a single block contains a plurality of platforms or does not contain the platforms occurs, and the execution effect of the physical system in the platform jump type game is also influenced by the manner of dividing the blocks.
Disclosure of Invention
The embodiment of the invention aims to provide a path planning method and system in a 2D game and electronic equipment, so as to solve the problem of poor path planning effect in the conventional platform jump game.
In a first aspect, an embodiment of the present invention provides a path planning method in a 2D game, where a game scene of the game includes multiple platforms, and the platforms are used for virtual characters to stop or act, and the method includes:
acquiring all platforms in the game scene, wherein the platforms comprise a starting point platform and an end point platform which correspond to a starting point and an end point of a path to be planned;
determining action connection relation among platforms;
and calculating to obtain the optimal path from the starting platform to the end platform by utilizing a preset path finding algorithm according to the action connection relation.
In some embodiments, the step of determining an action connection relationship between platforms includes:
for each platform:
determining all direct connection platforms that the virtual role can directly reach from the platform;
determining an action mode adopted by the virtual role from the platform to each direct-connected platform;
wherein the action mode comprises jumping, climbing or transferring.
In some embodiments, after the step of determining the action taken by the virtual character to reach each directly connected platform from the platform, the method further includes:
the effective starting range of each action mode on the platform is calculated.
In some embodiments, the step of calculating the optimal path from the starting platform to the ending platform by using a preset routing algorithm according to the action connection relationship comprises:
determining all alternative paths from a starting point platform to a terminal point platform;
calculating the time consumption of each alternative path by using a preset path searching algorithm according to the action connection relation;
and selecting the alternative path with the least time consumption as the optimal path.
In some embodiments, the step of calculating the time consumption of each alternative path by using a preset routing algorithm according to the action connection relationship includes:
for each alternative path:
determining all the passing platforms in the alternative path;
calculating unit time consumption between two adjacent passing platforms according to the action connection relation;
and overlapping all units of two adjacent passing platforms consumes time, and acquiring the alternative path.
In some embodiments, the step of calculating a unit elapsed time between two adjacent routing platforms includes:
calculating the transverse time consumption between two adjacent passing platforms;
calculating longitudinal time consumption between two adjacent passing platforms;
and overlapping the horizontal time consumption and the longitudinal time consumption to obtain the unit time consumption between two adjacent passing platforms.
In some embodiments, the lateral time consumption is: the sum of the length of the passing platform and the Manhattan distance between two adjacent passing platforms.
In some embodiments, the above longitudinal elapsed time is: the product of the longitudinal parameter and the number of failures;
the longitudinal parameter is the Manhattan distance between two adjacent passing platforms, and the failure times are the times that the virtual character cannot reach between the two adjacent passing platforms.
In a second aspect, an embodiment of the present invention provides a path planning system in a 2D game, a game scene of the game includes multiple platforms, and the platforms are used for virtual characters to stop or act, and the system includes:
the platform data acquisition module is used for acquiring all platforms in the game scene, wherein the platforms comprise a starting point platform and an end point platform which correspond to a starting point and an end point of a path to be planned;
the platform relation determining module is used for determining action connection relation among the platforms;
and the platform path calculation module is used for calculating the optimal path from the starting point platform to the destination platform by utilizing a preset routing algorithm according to the action connection relation.
In some embodiments, the platform relationship determining module includes:
the system comprises a first relation determining module, a first judging module and a second relation determining module, wherein the first relation determining module is used for determining all direct-connected platforms which can be directly reached by a virtual role from the platform;
the second relation determining module is used for determining an action mode adopted by the virtual role from the platform to each direct-connected platform; wherein the action mode comprises jumping, climbing or transferring.
In some embodiments, the platform relationship determining module further includes:
and the starting range calculation module is used for calculating the effective starting range of each action mode on the platform.
In some embodiments, the platform path calculating module includes:
the alternative path determining module is used for determining all alternative paths from the starting point platform to the end point platform;
the route time consumption calculation module is used for calculating the time consumption of each alternative route by using a preset route searching algorithm according to the action connection relation;
and the path acquisition module is used for selecting the alternative path with the minimum time consumption as the optimal path.
In some embodiments, the route-time-consumption calculating module includes:
a path platform acquisition module, configured to determine all via platforms in the alternative path;
the adjacent route time-consuming calculation module is used for calculating unit time-consuming between two adjacent passing platforms according to the action connection relation;
and the time consumption acquisition module is used for overlapping unit time consumption of all the two adjacent passing platforms and acquiring the time consumption of the alternative path.
In some embodiments, the neighboring path elapsed time calculation module includes:
the transverse time-consuming calculation module is used for calculating transverse time-consuming between two adjacent passing platforms;
the longitudinal time consumption calculation module is used for calculating longitudinal time consumption between two adjacent passing platforms;
and the time-consuming superposition calculation module is used for superposing the transverse time-consuming and the longitudinal time-consuming to obtain the unit time-consuming between the two adjacent passing platforms.
In some embodiments, the lateral time consumption in the lateral time consumption calculation module is: the sum of the length of the passing platform and the Manhattan distance between two adjacent passing platforms.
In some embodiments, the horizontal elapsed time in the vertical elapsed time calculation module is: the product of the longitudinal parameter and the number of failures;
the longitudinal parameter is the Manhattan distance between two adjacent passing platforms, and the failure times are the times that the virtual character cannot reach between the two adjacent passing platforms.
In a third aspect, an embodiment of the present invention provides an electronic device, including a memory and a processor, where the memory stores a computer program operable on the processor, and the processor implements the steps of the path planning method in the 2D game when executing the computer program.
In a fourth aspect, an embodiment of the present invention provides a computer-readable medium having non-volatile program code executable by a processor, where the program code causes the processor to execute the steps of the path planning method in the 2D game.
The embodiment of the invention provides a path planning method, a path planning system and electronic equipment in a 2D game. The path planning method in the 2D game comprises the steps of firstly obtaining all platforms in a game scene, wherein the platforms comprise a starting point platform and an end point platform which correspond to a starting point and an end point of a path to be planned, then determining action connection relations among the platforms, and finally calculating the optimal path from the starting point platform to the end point platform by utilizing a preset routing algorithm according to the action connection relations.
By adopting the path planning method, the system and the electronic equipment in the 2D game provided by the embodiment of the invention, the platforms can be abstracted into points, the connection relation between the platforms can be abstracted into connecting lines between the points, and for some games with fixed maps, the steps can be completed in the preprocessing, so that the efficiency is accelerated. The mobile control can be classified and controlled, and each control can be processed respectively, so that the control scheme is more flexible, and the expansibility is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a path planning method in a 2D game according to an embodiment of the present invention;
fig. 2 is a flowchart of step S102 in the path planning method in the 2D game according to the embodiment of the present invention;
fig. 3 is a flowchart of step S103 in the path planning method in the 2D game according to the embodiment of the present invention;
fig. 4 is a flowchart of step S302 in the path planning method in the 2D game according to the embodiment of the present invention;
fig. 5 is a flowchart of step S32 in the path planning method in the 2D game according to the embodiment of the present invention;
FIG. 6 is a schematic diagram of a map in a game according to an embodiment of the present invention;
FIG. 7 is a schematic diagram illustrating virtual character jumping process optimization in a game according to an embodiment of the present invention;
fig. 8 is a flowchart of path point loading preprocessing in the path planning method in the 2D game according to the embodiment of the present invention;
fig. 9 is a flowchart of virtual character movement control in a path planning method in a 2D game according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of a path planning system in a 2D game according to an embodiment of the present invention;
fig. 11 is a schematic diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the embodiments, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The 2D game is a two-dimensional interactive game, the viewing angle in the game is generally fixed, the characters in the game are in a two-dimensional game interface, platforms with different heights are usually arranged in the game interface, and the player plays the game by manipulating the characters to avoid or jump to the platforms.
In some 2D games, a game character can play the game by self-movement, for example, after a player selects a target point in a game scene map, the game character can automatically run to the target point. Because the 2D scene is used, the map is generally divided into a plurality of meshes, and the shortest path is calculated according to the connection relationship of the meshes, so that the game character is controlled to move along the path. Therefore, path planning is crucial to the gaming experience.
However, the game experience effect of the path planning realized by the existing mesh division mode in the platform jump type game is not good, because the terrain organization unit of the platform jump type game is a single platform on each layer, in the mesh division process, some meshes may contain a plurality of platforms, and some meshes may not contain platforms, so that the game scene cannot be completely represented by adopting the mode, and the final path planning is influenced.
In a platform jump type game, a game role needs a large number of jump actions to finally complete the game, a related physical system needs to be followed in the jump process to simulate the gravity effect generated in the jump process, and the current path planning in a grid mode does not consider the type of scene, so that the final path planning effect is influenced.
Aiming at the problem of poor path planning effect in the platform jump type game, the embodiment of the invention provides a path planning method, a path planning system and electronic equipment in the game aiming at the game scene.
The embodiment of the invention provides a path planning method in a 2D game. The flow chart of the method is shown in fig. 1, and comprises the following steps:
step S101: all platforms in a game scene of the game are obtained, wherein the platforms comprise a starting point platform and an end point platform which correspond to a starting point and an end point of a path to be planned.
The platforms mentioned in the platform jump type game are located in areas of different heights in the game scene. Most platforms are planar, and virtual characters can move horizontally on the platforms; there are also platforms that are inclined and on which the avatar moves under the influence of gravity-like forces.
Different types of games comprise different platforms, the common platform is a hard horizontal platform similar to the ground, and the virtual character on the platform has no difference from the ground; some game platforms are elastic, similar to spring trampolines, and virtual characters cannot stand still on the platforms and can only jump up and down; there are also some game platforms that resemble ropes on which the virtual character can only be hung, and cannot stand still (or for a long time); still further, the platform may be of the pipeline type, and the avatar may stand above the pipeline or may drill into the interior of the pipeline. In addition, in order to enhance the interest of the game, a plurality of platforms of the above different types may be integrated in the same game or the same scene, and the embodiment is not limited thereto.
Because the attributes and materials of the platforms are different, the states of the virtual characters are different, for example, in a hard platform, the virtual characters can stay for a long time and can also move or attack; in a non-horizontal hard platform, the virtual character can stay for a long time, but the virtual character can move or attack in the process if relevant operation is needed to counteract the sliding caused by the gravity effect; in the elastic platform, because the virtual character can not stay and can only jump up and down, the movement of the virtual character can only be realized by jumping, and the virtual character can also realize attack in the jumping process; in a rope type platform, because the virtual character needs to be fixed in the platform by four limbs, the stay can be realized, but the moving speed is influenced, and the virtual character cannot attack enemies generally; in the pipeline platform, when the virtual character is positioned above the pipeline, the state is the same as that of the hard platform, so that the stopping, moving and attacking can be realized; and when the virtual character was located inside the pipeline, the virtual character can only lie prone and remove inside the pipeline usually, and the translation rate is slower.
As can be seen from the above description, different types of platforms can make the virtual character in different states, and the types of platforms in the game scene mentioned in this embodiment are not limited to the above.
The platform may be obtained by traversing all components included in the game scene and obtaining the platform therefrom, and specifically, the platform is provided with a relevant mark, and the required platform can be obtained through the mark. In actual execution, a developer sets a unique ID for the platform in the process of editing the game scene map, and a special format can be set in the ID for convenient identification. For example, the ID may be set to an "alpha-numeric" mode, where the letters are fixed and the numbers are accumulated, and the two are connected by a connection symbol to form a unique ID.
The starting platform and the end platform of the path planning refer to a starting point and an end point of movement of a virtual character of the game, and the starting platform generally refers to a platform where the virtual character is currently located and can also be a starting platform when the virtual character starts when the game starts; the terminal platform is usually the platform of the game ending position, and can also be the terminal platform selected by the player.
The acquisition mode of the starting platform can be obtained through the position of the virtual character, and as the position of the virtual character is usually mobile, all platforms are traversed in the moving process, and the platform where the virtual character is located is acquired by calculating the position of the virtual character. If the current position of the virtual character is taken as a starting platform in the game, the obtained platform is the starting platform; if the platform from which the character starts is used as the starting platform in the game, the above calculation process is not needed, and the platform can be directly obtained according to the ID of the starting platform.
The acquisition mode of the terminal platform can be acquired according to the mode selected by the player, specifically, when the player selects a certain platform as the terminal platform, the ID of the platform is directly called in the process of selecting by the player, and then the terminal platform can be acquired. If the terminal platform is a platform at the game ending position, the ID of the terminal platform can be directly acquired without the above response process.
Step S102: and determining the action connection relation among the platforms.
The action of the virtual character between different platforms is of various types, for example, the virtual character acts from the upper platform to the lower platform, can directly move along two sides of the upper platform and then fall into the lower platform, and the process is similar to free fall; and can also fall to the lower platform by jumping on both sides. When the virtual character moves from the lower part to the upper part, the virtual character can be realized in a jumping way; if a rope-type climbing device is arranged between the lower platform and the upper platform, actions between the platforms can be realized in a climbing mode; if the lower platform is a spring-like elastic platform, the virtual character can jump to the upper platform directly through spring jumping. Therefore, the action types of the virtual character between the platforms are many, and the action types are only examples, and the present embodiment is not limited to the above types.
The action connection relationship between the platforms represents how the two platforms are crossed, and the mutual association between all the platforms is realized through the action connection relationship. In the process of editing the game scene map, platforms where virtual characters can stay or act can be marked in advance, the connection relation among the platforms is also configured, and the performability of path planning is guaranteed in a pre-configuration mode.
Yet another way to achieve a platform-to-platform temporal mobile connectivity is to simulate a parabola. In the field, a parabola is used as a simple and easy-to-use physical model for calculating the track of relevant motions such as object jumping or shell moving, and the virtual character jumps between platforms in a manner of simulating the parabola, so that the connection relationship between the platforms can be intuitively determined. In the process of configuring such a connection relationship, it is relatively easy to configure the connection relationship in a room-by-room game, but it is complicated to configure the connection relationship in a game scene including a plurality of platforms.
Although the type and attribute of each platform may be different, the virtual characters on the platforms can stop or act, so the platform in the game scene is often a plane with a certain length or a combination thereof, or a line segment with a certain length or a combination thereof, but not a point. However, in this embodiment, the length and the width of the platform are ignored, the platform is simulated as a point, and the connection relationship of the action is simulated as a directional connection line, so that the connection relationship between the platforms in the game scene is combined to form a closed graph, because the platform in the game cannot enable the virtual character to go up but not down when no other special scene exists, and it is ensured that the platform which can go up but not down cannot exist in the game, the out-degree and the in-degree of all nodes of the closed graph are greater than zero.
Step S103: and calculating the optimal path from the starting platform to the destination platform by using a preset path-finding algorithm according to the action connection relation.
After the action linking relationship is established, it indicates that the interconnection between all platforms is completed, including the starting platform and the ending platform. The calculation of the optimal path between the two is realized by a preset routing algorithm, the routing algorithm can adopt any one of a depth-first search algorithm, a breadth-first search algorithm, a Dijkstra algorithm, a greedy optimal-first search algorithm, an A-x algorithm or a B-x algorithm, and the algorithms can also be combined with each other.
And traversing all connected platforms between the starting platform and the end platform by a preset path-finding algorithm to obtain an optimal path, wherein the optimal path is not necessarily the shortest path, but is a result of comprehensive judgment by combining the attributes of each platform and the states of the virtual roles. For example, although the distance of a certain path is shortest, the path contains the most platform crossing actions, and obviously, the path is not the optimal path; although the distance of the other path is not the shortest, the path contains the transmission connection of different rooms, the virtual character can be quickly transmitted to the other room, so that actions of crossing platforms are avoided, and the effect of the path is better than that of the previous path.
Therefore, the selection of the optimal path is a comprehensive judgment process, and since the starting point platform and the ending point platform in the game scene are fixed, the selection process of the optimal path is not fixed, and the calculation process of the path selection is also executed in real time. In the calculation process of the optimal path, all platforms are abstracted into one point, the action connection relation among all the platforms is abstracted into a connecting line, an abstract graph is formed by point lines, the optimal path is selected through the graph, and finally a point sequence result is obtained, wherein all points contained in the sequence are the optimal moving path between the starting point platform and the destination point platform.
According to the path planning method in the 2D game, provided by the embodiment of the invention, all platform information in a game scene is acquired as a data source, and after the action connection relation between the platforms is determined, the optimal path from the starting platform to the destination platform is calculated by using a preset path-finding algorithm. In the path planning process, the platform can be abstracted into one point, the action connection relation between the platforms can be abstracted into a line, and the optimal moving path between the starting point platform and the destination point platform is obtained by using a preset path finding algorithm in a graph formed by the point line. For some games with fixed game scenes, the process can be completed in the game preprocessing process, so that the execution efficiency of the game is increased; and the movement in the platform and the movement between the platforms can be conveniently and respectively controlled, each control is respectively processed, the processing mode is more flexible, and the expansibility of the scheme is improved.
In some embodiments, in the step S102 of determining and determining an action connection relationship between platforms, for each platform, when a virtual character is in a certain platform, the platform may be used as a subject to determine the action connection relationship with the platform, and a specific process is as shown in fig. 2, and includes:
step S201, determine all direct connection platforms that the virtual role can directly reach from the platform.
In the platform jump type game, the virtual character plays the game by jumping among different platforms, so that the virtual character in the game is always positioned in a certain platform, and when the virtual character is positioned on the platform, whether the virtual character can reach the surrounding platform can be judged by calculating the distance between the platform and other surrounding platforms.
When the virtual character is positioned on a high-level platform, a bottom-level platform positioned below the high-level platform can be reached, a height threshold value can be added in the process for constraint, for example, when the height is greater than a preset height threshold value, the life value of the virtual character is reduced or even the virtual character directly dies when the virtual character jumps down from the high-level platform; the virtual role can also be directly restricted from directly jumping down; or the game picture provides related prompts when the platform is at the edge, and prompts the player for the consequences generated when the player jumps down from the high-level platform.
And when the virtual character is positioned on the bottom platform, acquiring whether the virtual character can reach the high platform or not by combining the jumping capability of the virtual character. The jumping process can be comprehensively judged by combining the horizontal distance, for example, when a high-rise platform with the height of 2 units and the virtual character located at 1 unit in front of the virtual character jumps, if the jumping capability of the virtual character is only 2 units, the virtual character cannot reach the high-rise platform, but the virtual character needs to advance 1 unit and reach the high-rise platform through jumping when the virtual character reaches the position under the high-rise platform.
When the virtual character is located on the platform, the platform is in an activated state, other surrounding platforms are traversed by obtaining the ID value of the platform, and most platforms in the platform jumping type game are fixedly arranged, so that the platform surrounding the platform only needs to be traversed, the number of traversal is reduced, and the efficiency is improved. The acquisition mode of the surrounding platforms can be determined by a relevant threshold, for example, the threshold can be set to be the size of the map view field, because in the actual game process, the player needs to see other platforms in the view field to control the virtual character to jump, and generally the player cannot directly control the virtual character to jump or fall when other platforms cannot be seen.
Step S202, determining the action mode adopted by the virtual role from the platform to each directly connected platform.
After determining all directly connected platforms that the virtual character can directly reach from the platform, the action mode of the virtual character can be determined, and the action mode comprises jumping, climbing or transferring according to the height between the platforms and the connection relation.
When the virtual character reaches the high platform from the low platform, if no other connection exists between the two platforms, the virtual character reaches the high platform in a jumping action mode; if other connections exist between the two platforms, such as ropes or stairs, the virtual character can reach the high platform in a climbing action mode, jumping can be performed in the climbing process, and the specific implementation process needs to be comprehensively considered by combining with a game scene.
When the virtual character arrives at the low platform from the high platform, if no other connection exists between the two platforms, the virtual character can fall into the low platform by directly moving from the edge of the high platform; or may jump from the edge of the high plateau into the low plateau in a parabolic manner. The falling process can be restricted through the height difference, for example, when the falling height difference is larger than the injury threshold value, the life value can be reduced when the virtual character falls to a low platform, so that the virtual character can be directly restricted from jumping and only other routes can be selected; or the virtual character does not die after the life value is reduced when jumping from a high platform to a low platform, so that the virtual character can jump.
The other action mode is transmission, the transmission process needs a transmission door which is arranged in advance to realize, the transmission door is generally divided into two ends, the two ends are respectively arranged in different platforms, and the transmission can be directly finished through the transmission door.
In some embodiments, after the step of determining the action taken by the virtual character to reach each directly connected platform from the platform, the method further includes: the effective starting range of each action mode on the platform is calculated.
After the action mode is established, the effective starting range of the action mode on the platform where the virtual character is located can be calculated, and the starting range can be understood as the range of the action. When the virtual character is in a jumping mode from a low platform to a high platform, the action range similar to a parabola can be obtained through the jumping capability of the virtual character. In the implementation process of virtual character jumping, jumping is generally performed through a track with the strongest jumping action range, although the track adopted in the previous step can jump to a high platform, the virtual character receives reverse direction control of a player in the jumping process or encounters an attack, and finally jumping failure is caused. After the player fails to jump for many times in the same place, negative effects are easily caused to the mind of the player, and the game experience is finally influenced, so that the effective starting range of the related virtual character can be enlarged after the player fails to jump for many times, the jumping capacity of the virtual character is increased, and the jumping is finally finished.
It can be seen that the effective starting range of each action mode of the virtual character on the platform can be comprehensively considered by combining the number of jump failures and the number of jump attempts, and the effective starting range can be realized in the process of path planning, for example, if the virtual character fails to jump at the same place for multiple times, the jump between the platforms can be bypassed in the subsequent path planning.
In some embodiments, the step S103 of calculating an optimal path from the starting platform to the ending platform by using a preset routing algorithm according to the action connection relationship, as shown in fig. 3, includes:
step S301, determining all alternative paths from the starting platform to the end platform.
After acquiring the action connection relations between all the platforms and the platform, abstracting the platform into a point, taking the starting platform as a starting point, the end platform as a termination point and other platforms as intermediate points, and acquiring all the alternative paths through connection. In the alternative path planning process, the path direction is to follow the starting point-ending point direction, and the path planning in the opposite direction cannot generally occur.
Step S302, calculating the time consumption of each alternative path by using a preset routing algorithm according to the action connection relation.
The method is characterized in that a directional connecting line is abstracted according to the action connecting relation, the directional connecting line and the abstract point of the platform are combined into a point line graph, all paths from a starting point to a terminal point can be visually displayed through the point line graph, and due to the fact that other related attributes are abandoned, the time consumed by each alternative path can be rapidly acquired through a preset routing algorithm.
And finally obtaining the consumed time of each alternative path by combining the movement speed of the virtual character according to the action connection relation and the distance of each alternative path in a preset path searching algorithm. It should be noted that the best path is not the shortest path, which needs to be calculated in combination with the action connection relationship between different platforms in the path, for example, a path, although the distance is shortest, includes a plurality of jumping actions and climbing actions, and although the jumping actions do not increase the time consumption too much, the risk of failure increases; the climbing action may reduce the path length, but the climbing speed is slow, which is not favorable for reducing the time consumption.
If a path includes a transfer gate, the path may be relatively long, but the transfer gate avoids the high-time-consuming and high-risk actions such as jumping and climbing platforms in other paths, and thus the time consumption is not necessarily the most.
The way-finding algorithm can be implemented by any one of a depth-first search algorithm, a breadth-first search algorithm, a Dijkstra algorithm, a greedy optimal-first search algorithm, an a-x algorithm or a B-x algorithm, or by a combination of the above algorithms.
For example, in some embodiments, the time-consuming computation process for each alternative path may be implemented by the following steps, as shown in fig. 4 in detail, including:
in step S31, all the via platforms in the alternative path are determined.
Each alternative path starts from a starting point platform and ends to a key platform, the intermediate path comprises a plurality of other platforms, and the overall trend of the alternative path is the direction from the starting point to the end point. The platform can be acquired through a preset ID value.
And step S32, calculating unit consumed time between two adjacent passing platforms according to the action connection relation.
Time consumption calculation needs to be carried out between two adjacent platforms by combining action connection relations, for example, the time consumption can be calculated by simulating a parabola in the jumping process through the initial speed, the jumping height and the jumping completion distance of the virtual character; if the virtual character adopts a climbing action mode, the time consumption can be calculated through the climbing distance and the climbing speed; if the virtual character acts in a spring jump mode, the time consumption is required to be obtained according to the elastic coefficient of the platform and the initial speed of the character; if the virtual character acts by transmission, the time consumption between platforms can be ignored, and the time consumption can be directly obtained according to the time consumption set in the game, because in some games, in order to increase the game effect, a time delay is provided in the transmission process through the transmission door to simulate the transmission effect, but the transmission delay time is usually fixed and can be directly obtained.
And step S33, overlapping all units of two adjacent passing platforms, and acquiring the time consumption of the alternative path.
And overlapping the time consumption of all the adjacent two platforms in the alternative path so as to obtain the time consumption of the alternative path, wherein the platform is abstracted into a point in the previous step and has no length, so the time consumption of the action of the virtual character on the platform is not considered in the step.
Step S303, selecting the candidate path with the least time consumption as the optimal path.
It can be seen that the candidate path with the minimum time consumption is not necessarily the shortest path, but is calculated by combining the action connection relationship between different platforms and combining a preset routing algorithm by the virtual player.
In some embodiments, the step S32 of calculating the unit elapsed time between two adjacent routing platforms, as shown in fig. 5, includes:
step S501, calculating the transverse time consumption between two adjacent passing platforms.
And step S502, calculating longitudinal time consumption between two adjacent passing platforms.
It should be noted that there is no precedence order between the above steps S501 and S502, and the calculation processes of the mentioned horizontal time consumption and the vertical time consumption are parallel.
In the step S501, the length value of the platform needs to be considered, and the time consumed by the virtual character on the platform is obtained according to the speed of the virtual character and the length of the platform. In some embodiments, the lateral time consumption is: the sum of the length of the passing platform and the Manhattan distance between two adjacent passing platforms.
The manhattan distance between two adjacent platforms refers to the sum of absolute wheel base of two abstracted points between the two adjacent platforms on a standard coordinate system, and represents the distance between the two platforms. When the horizontal axis between the two platforms has no overlapping part, the distance between the two platforms is the Manhattan distance between the nearest points in the two platforms; if there is overlap, then the two platform distances are the coordinate differences on the horizontal axis.
In some embodiments, the vertical elapsed time in step S502 is: the product of the longitudinal parameter and the number of failures; the longitudinal parameter is the Manhattan distance between two adjacent passing platforms, and the failure times are the times that the virtual character cannot reach between the two adjacent passing platforms.
The longitudinal parameters include a distance value between two adjacent access platforms, the distance value is a manhattan distance between the adjacent platforms, failure times of the virtual character need to be considered in the embodiment, when the virtual character fails to jump, the failure times are accumulated and recorded, and the parameters can be used as parameters when the virtual character jumps next time and change the state of the virtual character. For example, the take-off speed of the virtual character can be increased, so that the virtual character can more easily complete the jump between platforms, and the game interest of the player is prevented from being reduced due to multiple failures.
And S503, overlapping the horizontal time consumption and the longitudinal time consumption to obtain unit time consumption between two adjacent passing platforms.
And overlapping the acquired transverse time consumption and longitudinal time consumption, wherein the overlapping process can adopt a direct addition mode, and related weight coefficients can be added into the transverse time consumption and the longitudinal time consumption to represent the importance degrees of the transverse time consumption and the longitudinal time consumption.
In order to describe the above process more intuitively, the path planning method in the 2D game is described below with reference to a game, the picture of the game is shown in fig. 6, and it can be known from a map of the game that the map includes a plurality of rooms, each room has a door connected with other rooms, and some rooms are connected with each other through stairs, and there are crossings similar to transfer doors to realize the intercommunication of different rooms.
For each type of platform in the game, the platform is characterized by initializing relevant classes and objects, in the specific implementation process, a Vertex object is initialized to represent a node of the platform, edges represent the connection relation between one Vertex and another Vertex, and each Vertex has 1 or n edges connected. All Vertex in the game map is stored in the AStar class, only one AStar object is globally arranged, and the calculation of all paths is realized from a calculation interface calculated Path provided by the AStar class.
The route searching algorithm preset in the game adopts an A-x algorithm, the route planning from the starting point A to the terminal point Z is calculated through the A-x algorithm, and a communication point marked as B exists between the starting point A and the terminal point Z. The A-x algorithm comprises two estimation functions which are respectively marked as hFunc and wFunc, wherein the hFunc is responsible for calculating the time consumed from a connected point B to an end point Z; wFunc is responsible for calculating the time spent from origin a to point of communication B. Adding the two to obtain the estimated time spent by A passing through B to Z.
The hFunc and wFunc functions are crucial to the operation efficiency of a, and for a common grid-dividing type traveling road-finding map, the calculation accuracy of the hFunc function is high, and the manhattan distance or the euclidean distance can be directly used; however, the wFunc function may set different weight values according to the terrain, which may cause a large error in the platform skip game.
As can be seen from the map shown in fig. 6, the game is similar to most other 2D games, and the starting point of the virtual character is located in a glove compartment, so the starting point platform is a glove compartment platform; the virtual character's destination is to the attic, so the destination platform is the platform where the attic is located. The selection of attic can be achieved by the player manually clicking on the screen or other touch control means, or automatically acquired according to the requirements of the game scenario. In the process of planning the route, if manhattan distance is directly used, the restaurants in the map and the relevant platforms in the kitchen are necessarily calculated once, and then the roads which can really reach the attic are found from the stairwell. This is because the difference in the horizontal distance between the attic and the platform contained in the kitchen and restaurant is small for the same horizontal level platform, and the result of hFunc using manhattan distance estimation is also small.
In order to solve the above problem, the path planning is performed by considering the room path distance, for example, when the virtual character goes from the kitchen to the attic, the path is necessarily kitchen-staircase-attic, and the room path distance is the sum of the kitchen width and the staircase width. The distance between the staircase and the room of the attic is only the width of one staircase, so that the distance in the horizontal direction is only required to be considered when path planning is carried out, and the virtual characters in the game map basically do not have the condition of detour along the vertical direction, so that the operation of going before going is intuitively avoided. Therefore, the vertical distance in the vertical direction can be realized by using the difference of the vertical positions of the two platforms.
Edge represents the connection relationship between one Vertex and another Vertex, and weight member functions are included in the Edge and used for measuring the cost of moving the two platforms. The result of the weight function depends on the relative position between the two platforms, which is the manhattan distance between the closest points on the two platforms if there is no overlapping part on the horizontal axis of the two platforms; if the horizontal axis of the two platforms contains an overlapping portion, the distance between the two platforms is the difference in the horizontal coordinates. In general grid-like path planning, weight can be directly used as the final result of wFunc, but direct substitution is not suggested in the platform jump type game, because the platform jump type game sometimes has the situation of cross-platform jump.
The situation of the cross-platform jump can be visually shown in the game interface shown in fig. 7, the virtual character in fig. 7 needs to jump from a lower-layer platform to a higher-layer platform, and the jump property of the virtual character can indicate that the jump can jump to the 3 rd step above each jump. If the weight value is used directly for estimation, the virtual character one-level jump and the direct three-level jump are the same, and if the result of the hFunc is added, the final planned path is likely to be the one-level jump. The virtual character can clearly complete the action by jumping once, three actions are needed, and the game experience degree is reduced.
For the above case, the return values of wFunc are all set to 0, and the height difference is controlled by hFunc. It can be seen that the final role of wFunc is to perform dynamic adjustment of the path, and when a virtual character moves between two platforms, if the movement fails, the number of times of failure occurrence needs to be recorded. In order to simplify the data storage amount in the game, the number of times of failure occurrence can be directly measured by the speed of the virtual character. In the specific implementation process, when a user moves on different platforms, if the user receives an attack or is controlled by a player in the reverse direction, the situation that the user does not move successfully occurs. When the virtual character moves the same platform again, the speed of the virtual character is properly increased, so that the passing success rate of the virtual character is improved; if the move has not been successful, the speed of the avatar continues to be increased. Therefore, the failure times of moving between platforms can be directly obtained through the speed of the virtual character.
The final result of wFunc is also adjusted according to the failure number n, and the adjustment process can directly adopt a product mode as follows:
wFunc=weight*n
in the above process, if the calculated result is that the failure is inevitable, the increase of the number of n is increased appropriately. This is because if the virtual character is attacked or otherwise has reduced jumping ability, so that the two platforms in the path cannot complete the movement, which is a necessary movement failure. When the next jump is made, the numerical value of n can be increased properly, so that the situation that a plurality of jumps are unsuccessful is prevented, and the experience of the player for the game is reduced.
If the game does not consider performance bottlenecks, wFunc may also be calculated based on the total elapsed time of the current path, i.e., the time taken for the current path
wFunc estimated total elapsed time (number of failures/number of attempts)
The number of attempts may be a configured number, which is adjusted according to the speed at which wFunc needs to be increased, or may be increased quickly. The method needs to recalculate when each failure of the virtual character occurs, and if the method is used in a frame synchronization game, fixed point number operation is adopted in the operation process, so that the resource consumption is more, but the method has higher precision.
And after the path planning is finished, the relevant path planning is needed in the control process of the virtual character. In the specific implementation process, the route searching process in the normal running state is initiated by a behavior tree, the behavior tree specifies a terminal position and a corresponding terminal platform, and AStar is called to perform path planning. And after the path planning is finished, controlling the virtual role to move by itself until the action tree gives an instruction of stopping moving or the target is reached.
The self-moving process comprises the following three parts:
1. on one platform, moves to the jump-off range marked in the base class of the connection of the other platform.
2. And after reaching the jump starting range, according to the type of the base class, handing over the base class to different control classes to control different jumps or moves.
3. And after the target platform is reached, moving to the position of the target point.
In the specific implementation process, the core management control class of the way-finding process control is a platform manager management class and an AutoMoveController control class. When a battle is started, a PlatformManager management class is first generated for generating platforms and connection relations between the platforms according to configured waypoint information, the PlatformManager management class includes all Platform base classes, and the PlatformManager is globally unique.
Platform as a base class of a Platform includes basic information such as a start point, an end point, etc. of the Platform, and different subclasses may correspond to different Platform types, for example: SlopPlatform corresponds to a slope platform, horizon platform corresponds to a horizontal platform, ClimbPlatform corresponds to a climbing platform, and elastic Platform corresponds to a spring jump platform. If other special platforms need to be added, the platform can be directly added, and later development and maintenance are facilitated.
Each Platform will contain a plurality of Link base classes according to the connection relationship between itself and other platforms, the Link is a base class of the connection relationship, and the connection relationship represents how two platforms cross, for example, JumpLink therein indicates that the Platform passes through in a jump manner, and ClimbLink indicates that the Platform passes through in a climbing manner. The LinkType connection relationship comprises Jump, Walk, Climb and Elasticjump, and the corresponding links also comprise JumpLink, WalkLink, ClimbLink and ElasticJumLink subclasses. And if other connection relations need to be added subsequently, directly adding a LinkType and a new Link subclass. Meanwhile, the Link base class also records the moving range of the virtual character from the current platform to another platform, such as the take-off range, and the take-off range can be calculated and obtained by using a mode of simulating a parabola.
PlatformManager also holds the AStar way-finding algorithm, as introduced above, mainly responsible for finding the shortest path from the platform.
The AutoMoveController is mainly responsible for the movement control of the virtual role, and different virtual roles have different AutoMoveController objects.
The AutoMoveController holds a PathFinder, and the PathFinder mainly stores some dynamic information of the virtual role in the path finding process, provides hFunc and wFunc for the AStar algorithm and completes path estimation. It is then also responsible for concatenating the PlatformManager to complete the path planning.
The AutoMoveController holds an AutoMove for controlling AI movement on a platform. The AutoOneMyController is used for controlling the role to move from one platform to another platform, the AutoOneMyv is a base class, the main method comprises oneenter, onUpdate and oneExit, which correspond to LinkType, and each connection has different control subclasses for control, such as AutoOneJump and AutoOneElasticJump. And if other connection modes exist subsequently, only the new AutoOneMethoe subclass needs to be expanded. The important point is AutoOneJump, only because most of the platform game scenes move between platforms through jumping, when onenterer, the pressing time of a direction key and a jump key is calculated according to the transverse and longitudinal distance between the platforms (the jump height is controlled by the pressing time of the jump key), then the direction key and the jump key are pressed according to needs, a timer is used for controlling when the direction key and the jump key are released, onUpdate is adjusted every time, the method is mainly used for controlling the position of a role in the air, for example, the process of needing air turning is finished at the place, and the oneExit removes the timer.
The path planning method described in the above embodiment is simplified into a path point loading preprocessing flow and a virtual character movement control flow.
Specifically, the flow of the path point loading preprocessing is shown in fig. 8, and includes:
step S801, load all platform information, which mainly includes information such as platform ID, start platform, and end platform.
Step S802, establishing a connection relation between platforms.
And step S803, calculating mobile connection modes between platforms, including jumping, climbing, transmitting and the like.
In step S804, a movement start range from one platform to another platform is calculated.
If the connection is a jump connection, calculating a jump starting range;
if the connection is climbing connection, calculating a climbing starting position;
if it is a transfer connection, the starting position of the transfer is calculated.
As shown in fig. 9, the virtual character movement control flow includes:
step S901, a moving mode and a moving start position range of the virtual character to the next platform are obtained.
Step S902, move the virtual character to within the starting position range.
Step S903, call a corresponding movement mode processing function, and perform a movement.
In step S904, the virtual character performs continuous control on the virtual character during the movement process, for example, performs jump posture and position control on the virtual character during the jump process.
Step S905, determine whether the virtual character reaches the next platform.
If yes, the movement control of the virtual role on the platform is completed, and the subsequent platform movement process is executed to step S907; if not, step S906 is performed.
And step S906, error processing is carried out, and the path planning process is carried out again.
Step 907, determine whether the virtual role reaches the target platform.
If so, ending the movement control of the virtual character; if not, the process returns to step S901 again to perform the movement control of the next stage.
In order to improve the path planning effect and the game experience degree, the calculation process in the path planning can be optimized in a relevant mode. For path planning, the relevant optimization process is to adjust hFunc and wFunc, so that the path planning finally realized by hFunc and wFunc is more reasonable, the number of platforms required to be traversed in the path planning process is reduced, and the path planning efficiency is improved. The mobile control mainly simulates the operation of a parabola, the calculation amount is large, and the time is consumed, so that a parabola table can be cached in advance, the related operation can be completed by directly looking up the table, and the calculation pressure is reduced.
In the process of path planning, because of the calculated planning result, the virtual character can be realized in the process of jumping, and actually, a real player may make a mistake in the process of jumping, for example, the position of a jumping point is advanced in the past; and after taking off, the player can control the direction in the opposite direction, and the like. And the distance between the platforms is mostly fixed, and the tracks of the virtual characters after path planning are the same when the virtual characters pass through the same platforms, so that the virtual characters are too mechanized, and the game experience is poor. Therefore, a related fault mechanism can be added in the behavior tree, and the fault occurrence probability is intentionally increased, so that the virtual character in the path planning is closer to a real scene when moving.
As can be seen, the path planning method in the 2D game provided in the above embodiment has the advantages that the extension of the relevant control classes required in the path planning process is more convenient, the execution efficiency is further improved, and the control of the virtual character is more flexible.
An embodiment of the present invention provides a path planning system in a game, a game scene of the game includes a plurality of platforms, and the platforms are used for virtual characters to stay or act, as shown in fig. 10, the system includes:
the platform data acquisition module 1001 is configured to acquire all platforms in a game scene, where the platforms include a start platform and an end platform corresponding to a start point and an end point of a path to be planned;
a platform relation determining module 1002, configured to determine an action connection relation between platforms;
the platform path calculating module 1003 is configured to calculate an optimal path from the starting platform to the ending platform by using a preset routing algorithm according to the action connection relationship.
In some embodiments, the platform relation determining module 1002 includes:
the system comprises a first relation determining module, a first judging module and a second relation determining module, wherein the first relation determining module is used for determining all direct-connected platforms which can be directly reached by a virtual role from the platform;
the second relation determining module is used for determining an action mode adopted by the virtual role from the platform to each direct-connected platform; wherein the action mode comprises jumping, climbing or transferring.
In some embodiments, the platform relation determining module 1002 further includes:
and the starting range calculation module is used for calculating the effective starting range of each action mode on the platform.
In some embodiments, the platform path calculating module 1003 includes:
the alternative path determining module is used for determining all alternative paths from the starting point platform to the end point platform;
the route time consumption calculation module is used for calculating the time consumption of each alternative route by using a preset route searching algorithm according to the action connection relation;
and the path acquisition module is used for selecting the alternative path with the minimum time consumption as the optimal path.
In some embodiments, the route-time-consumption calculating module includes:
a path platform acquisition module, configured to determine all via platforms in the alternative path;
the adjacent route time-consuming calculation module is used for calculating unit time-consuming between two adjacent passing platforms according to the action connection relation;
and the time consumption acquisition module is used for overlapping unit time consumption of all the two adjacent passing platforms and acquiring the time consumption of the alternative path.
In some embodiments, the neighboring path elapsed time calculation module includes:
the transverse time-consuming calculation module is used for calculating transverse time-consuming between two adjacent passing platforms;
the longitudinal time consumption calculation module is used for calculating longitudinal time consumption between two adjacent passing platforms;
and the time-consuming superposition calculation module is used for superposing the transverse time-consuming and the longitudinal time-consuming to obtain the unit time-consuming between the two adjacent passing platforms.
In some embodiments, the lateral time consumption in the lateral time consumption calculation module is: the sum of the length of the passing platform and the Manhattan distance between two adjacent passing platforms.
In some embodiments, the horizontal elapsed time in the vertical elapsed time calculation module is: the product of the longitudinal parameter and the number of failures;
the longitudinal parameter is the Manhattan distance between two adjacent passing platforms, and the failure times are the times that the virtual character cannot reach between the two adjacent passing platforms.
The path planning device in the game provided by the embodiment of the invention has similar technical characteristics to the path planning method in the 2D game provided by the above embodiment, and detailed implementation modes are not repeated in this embodiment.
The embodiment also provides an electronic device, a schematic structural diagram of which is shown in fig. 11, where the electronic device 100 includes a processor 101 and a memory 102; the memory 102 is used for storing one or more computer instructions, and the one or more computer instructions are executed by the processor to implement the above-mentioned path planning method for use in the 2D game.
The electronic device shown in fig. 11 further includes a bus 103 and a communication interface 104, and the processor 101, the communication interface 104, and the memory 102 are connected through the bus 103.
The Memory 102 may include a high-speed Random Access Memory (RAM) and may also include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Bus 103 may be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 11, but that does not indicate only one bus or one type of bus.
The communication interface 104 is configured to connect with at least one user terminal and other network units through a network interface, and send the packaged IPv4 message or IPv4 message to the user terminal through the network interface.
The processor 101 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 101. The Processor 101 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component. The various methods, steps, and logic blocks disclosed in the embodiments of the present disclosure may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present disclosure may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 102, and the processor 101 reads the information in the memory 102 and completes the steps of the method of the foregoing embodiment in combination with the hardware thereof.
Embodiments of the present invention provide a computer readable medium having non-volatile program code executable by a processor, the program code causing the processor to perform the steps of the method provided by the above embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus, and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present invention or a part thereof, which essentially contributes to the prior art, can be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (11)

1. A path planning method in a 2D game is characterized in that a game scene of the game comprises a plurality of platforms, the platforms are used for virtual characters to stop or act, and the method comprises the following steps:
acquiring all platforms in the game scene, wherein the platforms comprise a starting point platform and an end point platform which correspond to a starting point and an end point of a path to be planned;
determining action connection relation among platforms;
and calculating to obtain the optimal path from the starting platform to the end platform by utilizing a preset path finding algorithm according to the action connection relation.
2. The method of claim 1, wherein the step of determining an action connection relationship between platforms comprises:
for each platform:
determining all direct connection platforms that the virtual role can directly reach from the platform;
determining an action mode adopted by the virtual role to reach each direct-connected platform from the platform;
wherein the action pattern comprises jumping, climbing or transferring.
3. The method of claim 2, wherein the step of determining the manner of action taken by the virtual character to reach each of the directly connected platforms from that platform is further followed by:
and calculating the effective starting range of each action mode on the platform.
4. The method according to claim 1, wherein the step of calculating the optimal path from the starting platform to the ending platform by using a predetermined routing algorithm according to the action connection relationship comprises:
determining all alternative paths from the starting point platform to the end point platform;
calculating the time consumption of each alternative path by using a preset path searching algorithm according to the action connection relation;
and selecting the alternative path with the least time consumption as the optimal path.
5. The method according to claim 4, wherein the step of calculating the time consumption of each alternative path by using a preset routing algorithm according to the action connection relationship comprises:
for each of the alternative paths:
determining all the passing platforms in the alternative path;
calculating unit time consumption between two adjacent passing platforms according to the action connection relation;
and overlapping all units of two adjacent passing platforms consumes time, and acquiring the alternative path.
6. The method of claim 5, wherein the step of calculating the unit elapsed time between two adjacent routing platforms comprises:
calculating the transverse time consumption between two adjacent passing platforms;
calculating longitudinal time consumption between the two adjacent passing platforms;
and overlapping the transverse consumed time and the longitudinal consumed time to obtain unit consumed time between the two adjacent passing platforms.
7. The method of claim 6, wherein the lateral time consumption is: the length of the passing platform and the sum of the Manhattan distances between the two adjacent passing platforms.
8. The method of claim 6, wherein the longitudinal elapsed time is: the product of the longitudinal parameter and the number of failures;
the longitudinal parameter is a Manhattan distance between the two adjacent passing platforms, and the failure times are times that the virtual character cannot reach between the two adjacent passing platforms.
9. A path planning system in a 2D game, wherein a game scene of the game includes a plurality of platforms, and the platforms are used for virtual characters to stop or act, the system comprising:
the platform data acquisition module is used for acquiring all platforms in the game scene, wherein the platforms comprise a starting point platform and an end point platform which correspond to a starting point and an end point of a path to be planned;
the platform relation determining module is used for determining action connection relation among the platforms;
and the platform path calculation module is used for calculating the optimal path from the starting point platform to the destination platform by utilizing a preset routing algorithm according to the action connection relation.
10. An electronic device comprising a memory and a processor, wherein the memory stores a computer program operable on the processor, and wherein the processor implements the steps of the method of any of claims 1 to 8 when executing the computer program.
11. A computer-readable medium having non-volatile program code executable by a processor, characterized in that the program code causes the processor to perform the steps of the method of any of claims 1 to 8.
CN202010049832.8A 2020-01-16 2020-01-16 Path planning method and system in 2D game and electronic equipment Active CN111202985B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010049832.8A CN111202985B (en) 2020-01-16 2020-01-16 Path planning method and system in 2D game and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010049832.8A CN111202985B (en) 2020-01-16 2020-01-16 Path planning method and system in 2D game and electronic equipment

Publications (2)

Publication Number Publication Date
CN111202985A true CN111202985A (en) 2020-05-29
CN111202985B CN111202985B (en) 2023-04-07

Family

ID=70780785

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010049832.8A Active CN111202985B (en) 2020-01-16 2020-01-16 Path planning method and system in 2D game and electronic equipment

Country Status (1)

Country Link
CN (1) CN111202985B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111840989A (en) * 2020-08-05 2020-10-30 网易(杭州)网络有限公司 Method and device for processing moving route of virtual object and electronic equipment
CN111921192A (en) * 2020-08-31 2020-11-13 网易(杭州)网络有限公司 Control method and device of virtual object
CN112686362A (en) * 2020-12-28 2021-04-20 北京像素软件科技股份有限公司 Game space way-finding model training method and device, electronic equipment and storage medium
WO2022247319A1 (en) * 2021-05-25 2022-12-01 网易(杭州)网络有限公司 Game display method and apparatus, and terminal

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103893969A (en) * 2014-04-15 2014-07-02 广州博冠信息科技有限公司 Way-finding method and device in game
WO2018130135A1 (en) * 2017-01-13 2018-07-19 腾讯科技(深圳)有限公司 Method and device for controlling way-finding of simulation object, and server

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103893969A (en) * 2014-04-15 2014-07-02 广州博冠信息科技有限公司 Way-finding method and device in game
WO2018130135A1 (en) * 2017-01-13 2018-07-19 腾讯科技(深圳)有限公司 Method and device for controlling way-finding of simulation object, and server

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111840989A (en) * 2020-08-05 2020-10-30 网易(杭州)网络有限公司 Method and device for processing moving route of virtual object and electronic equipment
CN111840989B (en) * 2020-08-05 2023-10-27 网易(杭州)网络有限公司 Virtual object moving route processing method and device and electronic equipment
CN111921192A (en) * 2020-08-31 2020-11-13 网易(杭州)网络有限公司 Control method and device of virtual object
CN112686362A (en) * 2020-12-28 2021-04-20 北京像素软件科技股份有限公司 Game space way-finding model training method and device, electronic equipment and storage medium
WO2022247319A1 (en) * 2021-05-25 2022-12-01 网易(杭州)网络有限公司 Game display method and apparatus, and terminal

Also Published As

Publication number Publication date
CN111202985B (en) 2023-04-07

Similar Documents

Publication Publication Date Title
CN111202985B (en) Path planning method and system in 2D game and electronic equipment
JP5887458B1 (en) A game system for searching for a route of a non-player character based on a player's movement history
US20220226728A1 (en) Route navigation system within a game application environment
JP5767760B2 (en) Network game system without dynamic obstacles and its processing method
CN113365706A (en) Artificial Intelligence (AI) model training using cloud gaming networks
WO2018130135A1 (en) Method and device for controlling way-finding of simulation object, and server
Gordillo et al. Improving playtesting coverage via curiosity driven reinforcement learning agents
US11110352B2 (en) Object moving method and apparatus, storage medium, and electronic apparatus
CN111714892A (en) Game way finding method and device, storage medium and computer equipment
Cui et al. Direction oriented pathfinding in video games
CN112090078B (en) Game character movement control method, device, equipment and medium
CN111437603A (en) Method and system for generating map of electronic game
CN106060052A (en) Three-dimensional navigation method for network game of mobile terminal
CN111177291B (en) Object moving method, device, equipment and medium
CN111701246A (en) Game AI decision configuration method and device
KR20230145430A (en) Method and device for displaying coordinate axes in a virtual environment, and terminals and media
CN111389007B (en) Game control method and device, computing equipment and storage medium
US20230311002A1 (en) Decision model training method and apparatus
US11219825B2 (en) Non-transitory computer-readable medium and video game processing system
CN113797543A (en) Game processing method, game processing device, computer device, storage medium, and program product
Adegun et al. Design and implementation of an intelligent gaming agent using A* algorithm and finite state machines
CN117899487B (en) Data processing method, device, equipment, storage medium and program product
CN114247132B (en) Control processing method, device, equipment, medium and program product for virtual object
CN114768254A (en) Virtual scene path finding method and device, electronic device and storage medium
CN117732072A (en) Cross-layer path finding method, device, computer equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant