Method, device and electronic device for generating navigation path
By generating a mapping map of the scene map in navigation games and calculating priority, the problem of unoptimized navigation paths caused by the loop attributes of the game scene is solved, and the game experience is improved.
Patent Information
- Application Number
- CN202210881189.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-26
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2042-07-26
AI Technical Summary
In navigation games, since the game scene has loop attributes, the navigation path generated based on the scene map is not necessarily the optimal path, and the path may not even be found, resulting in a reduced player's gaming experience.
By generating a map of the scene map and determining the navigation path in the map, the navigation path is displayed in the scene map, using the relative position and size of the map to calculate priority, and determining adjacent locations to generate more optimized or distance Shorter path.
Improves the player's gaming experience, ensuring that more optimized or shorter navigation paths can be found in game scenes with loop attributes.
Smart Images

Figure CN115430152B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of game technology, and in particular to a method, device and electronic device for generating a navigation path. Background Art
[0002] In sailing games, the game scene mainly includes land areas and ocean areas; players can control the movement of ships in the ocean area, but ships cannot directly reach land areas and some unlocked areas, so land areas and unlocked areas become blocking areas for ships, which cause certain obstructions to the movement of ships. In order to reach the destination smoothly, players can first select the end location on the scene map. The game system generates a navigation path based on the current position and end location of the ship, and then controls the ship to move along the navigation path to reach the destination. However, considering that in sailing games, the game scene has a circular attribute, that is, similar to the earth, starting from a position, moving east or west can reach the destination; but the scene map is a flat map, which easily leads to the navigation path generated based on the scene map is not the optimal path, or even leads to the inability to find the navigation path, reducing the player's gaming experience. Summary of the invention
[0003] In view of this, an object of the present invention is to provide a method, device and electronic device for generating a navigation path, so as to obtain a more optimized or shorter path and improve the game experience of players.
[0004] In a first aspect, an embodiment of the present invention provides a method for generating a navigation path, providing a graphical user interface through a terminal device; a scene map of a game scene is displayed in the graphical user interface; a controlled virtual object is located in the game scene; the controlled virtual object is controlled by the terminal device; the method comprises: generating a mapping map of the scene map in response to a selection operation on a first position in the scene map; wherein the mapping map is the same as the scene map; the mapping map is adjacent to the scene map; determining a mapping position of the first position in the mapping map; determining a navigation path from the current position to the first position from the scene map based on the current position, the first position and the mapping position of the controlled virtual object; and displaying the navigation path in the scene map.
[0005] The above-mentioned step of determining the mapping position of the first position in the mapping map includes: arranging the mapping map and the scene map horizontally; and determining the mapping position of the first position based on the relative position of the mapping map and the scene map, and the map size of the scene map.
[0006] The above-mentioned mapping map includes a first mapping map and a second mapping map; the first mapping map, the scene map and the second mapping map are arranged horizontally in sequence; based on the relative position of the mapping map and the scene map, and the map size of the scene map, the step of determining the mapping position of the first position includes: based on the first relative position of the first mapping map and the scene map, and the map size of the scene map, determining the first mapping position in the first mapping map; based on the second relative position of the second mapping map and the scene map, and the map size of the scene map, determining the second mapping position in the second mapping map.
[0007] The above-mentioned step of determining a navigation path from the current position to the first position in the scene map based on the current position, the first position and the mapped position of the controlled virtual object includes: determining the current position of the controlled virtual object as the first position to be traversed; determining the next traversal position adjacent to the position to be traversed from a specified position range of the position to be traversed based on the current position, the first position and the mapped position of the controlled virtual object; updating the next traversal position to the position to be traversed, and continuing to execute the step of determining the next traversal position adjacent to the position to be traversed from a specified position range of the position to be traversed based on the current position, the first position and the mapped position of the controlled virtual object, until the next traversal position is the first position.
[0008] The above-mentioned step of determining the next traversal position adjacent to the position to be traversed from the specified position range of the position to be traversed based on the current position, the first position and the mapped position of the controlled virtual object includes: obtaining at least one adjacent position of the position to be traversed; wherein the distance between the adjacent position and the position to be traversed is less than a preset distance threshold; calculating the priority of the adjacent position based on the current position, the first position and the mapped position of the controlled virtual object; and determining the adjacent position with the highest priority as the next traversal position adjacent to the position to be traversed.
[0009] The above-mentioned step of calculating the priority of the adjacent position based on the current position, the first position and the mapped position of the controlled virtual object includes: calculating the minimum distance between the adjacent position and the current position, and determining the minimum distance as a first intermediate value; calculating a first distance value between the adjacent position and the first position, and a second distance value between the adjacent position and the mapped position; determining a second intermediate value based on the minimum distance value between the first distance value and the second distance value; and determining the priority of the adjacent position based on the first intermediate value and the second intermediate value.
[0010] The above-mentioned mapping maps include multiple; the mapping position includes a first mapping position and a second mapping position; the first mapping position and the second mapping position are located in different mapping maps; the step of calculating the first distance value between the adjacent position and the first position, and the second distance value between the adjacent position and the mapping position, includes: calculating the first distance value between the adjacent position and the first position; calculating the second distance value between the adjacent position and the first mapping position, and the second distance value between the adjacent position and the second mapping position.
[0011] The above-mentioned step of determining the navigation path from the current position to the first position from the scene map based on the current position, the first position and the mapped position of the controlled virtual object includes: initializing a set of positions to be traversed and a set of positions that have been traversed; adding the current position to the set of positions to be traversed, and setting the priority of the current position to the highest priority; if the set of positions to be traversed is not empty, obtaining the target position with the highest priority from the set of positions to be traversed; if the target position is not the first position, deleting the target position from the set of positions to be traversed, and adding the target position to the set of positions that have been traversed; traversing the neighboring positions of the target position, if the neighboring position is not located in the set of positions to be traversed, setting the parent position of the neighboring position as the target position, calculating the priority of the neighboring position based on the current position, the first position and the mapped position of the controlled virtual object, and adding the neighboring position to the set of positions to be traversed; continuing to execute the step of obtaining the target position with the highest priority from the set of positions to be traversed if the set of positions to be traversed is not empty; if the target position is the first position, starting from the first position, gradually tracking the parent position until reaching the current position, and using the tracked path as the navigation path.
[0012] The above-mentioned step of determining a navigation path from the current position to the first position in the scene map based on the current position, the first position and the mapping position of the controlled virtual object includes: starting from the current position of the controlled virtual object, performing a pathfinding operation to the first position in the scene map to obtain a first initial path; starting from the current position of the controlled virtual object, performing a pathfinding operation to the mapping position in the scene map and the mapping map to obtain a second initial path; based on the first initial path and the second initial path, determining the navigation path from the current position to the first position.
[0013] The above-mentioned step of determining the navigation path from the current position to the first position based on the first initial path and the second initial path includes: if the path length of the first initial path is less than the path length of the second initial path, determining the first initial path as the navigation path from the current position to the first position; if the path length of the second initial path is less than the path length of the first initial path, mapping the partial path in the second initial path located in the mapping map to the scene map to obtain the navigation path from the current position to the first position.
[0014] In a second aspect, an embodiment of the present invention provides a device for generating a navigation path, which provides a graphical user interface through a terminal device; a scene map of a game scene is displayed in the graphical user interface; a controlled virtual object is located in the game scene; the controlled virtual object is controlled by the terminal device; the device includes: a map generation module, which is used to generate a mapping map of the scene map in response to a selection operation on a first position in the scene map; wherein the mapping map is the same as the scene map; the mapping map is adjacent to the scene map; a position determination module, which is used to determine the mapping position of the first position in the mapping map; a path determination module, which is used to determine the navigation path from the current position to the first position from the scene map based on the current position, the first position and the mapping position of the controlled virtual object; and a path display module, which is used to display the navigation path in the scene map.
[0015] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned navigation path generation method.
[0016] In a fourth aspect, an embodiment of the present invention provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned navigation path generation method.
[0017] The embodiments of the present invention bring the following beneficial effects:
[0018] The above-mentioned method, device and electronic device for generating a navigation path generate a mapping map of the scene map in response to a selection operation on the first position in the scene map; wherein the mapping map is the same as the scene map; the mapping map and the scene map are set adjacent to each other; the mapping position of the first position is determined in the mapping map; based on the current position, the first position and the mapping position of the controlled virtual object, the navigation path from the current position to the first position is determined from the scene map; and the navigation path is displayed in the scene map. In this method, when generating the navigation path, the scene map and the mapping map are set adjacent to each other, and the mapping position of the selected first position is determined in the mapping map, so that the navigation path can be generated based on the first position and the mapping position together. For game scenes with cyclic properties, compared with the method of generating a navigation path based only on the scene map, this embodiment adds the path-finding direction of the path, which is conducive to obtaining a more optimized or shorter path, thereby improving the player's gaming experience.
[0019] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0020] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0022] Figure 1 A flowchart of a method for generating a navigation path provided by an embodiment of the present invention;
[0023] Figure 2 A schematic diagram of a scene map and a mapping map provided by an embodiment of the present invention;
[0024] Figure 3 A schematic diagram of another scene map and mapping map provided by an embodiment of the present invention;
[0025] Figure 4 A schematic diagram of a scene map and multiple mapping maps provided by an embodiment of the present invention;
[0026] Figure 5 A schematic diagram of another scene map and multiple mapping maps provided by an embodiment of the present invention;
[0027] Figure 6 A schematic diagram of a method for calculating a diagonal distance provided by an embodiment of the present invention;
[0028] Figure 7 A flowchart of using the A* algorithm to generate a navigation path provided by an embodiment of the present invention;
[0029] Figure 8 A schematic diagram of the structure of a navigation path generation device provided by an embodiment of the present invention;
[0030] Fig. 9 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0032] In sailing games, the game scene is usually spherical or cylindrical like the earth, which has a circular property, while the scene map is a plane, such as a rectangular plane or a circular plane, which does not have a circular property; the scene map does not completely match the game scene; as a result, the navigation path generated based on the scene map is not the optimal path, and may even make it impossible to find the navigation path, reducing the player's gaming experience.
[0033] Based on this, the embodiments of the present invention provide a method, device and electronic device for generating a navigation path. The technology can be applied to sailing games or other types of games in which a path is determined through a scene map.
[0034] The method for generating a navigation path in one embodiment of the present disclosure may be run on a local terminal device or a server. When the method for generating a navigation path is run on a server, the method may be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.
[0035] In an optional implementation, various cloud applications can be run under the cloud interaction system, such as cloud games. Taking cloud games as an example, cloud games refer to a game mode based on cloud computing. In the operation mode of cloud games, the operating body of the game program and the main body of the game screen presentation are separated. The storage and operation of the navigation path generation method are completed on the cloud game server. The role of the client device is used for receiving and sending data and presenting the game screen. For example, the client device can be a display device with data transmission function close to the user side, such as a mobile terminal, a TV, a computer, a handheld computer, etc.; but the cloud game server in the cloud is used for information processing. When playing the game, the player operates the client device to send an operation instruction to the cloud game server. The cloud game server runs the game according to the operation instruction, encodes and compresses the game screen and other data, and returns it to the client device through the network. Finally, the client device decodes and outputs the game screen.
[0036] In an optional embodiment, taking a game as an example, a local terminal device stores a game program and is used to present a game screen. The local terminal device is used to interact with the player through a graphical user interface, that is, the game program is downloaded and installed by an electronic device and run conventionally. The local terminal device may provide the graphical user interface to the player in a variety of ways, for example, it may be rendered and displayed on a display screen of the terminal, or provided to the player through a holographic projection. For example, the local terminal device may include a display screen and a processor, the display screen is used to present a graphical user interface, the graphical user interface includes a game screen, and the processor is used to run the game, generate a graphical user interface, and control the display of the graphical user interface on the display screen.
[0037] In a possible implementation, an embodiment of the present invention provides a method for generating a navigation path, providing a graphical user interface through a terminal device, wherein the terminal device may be the local terminal device mentioned above, or may be a client device in the cloud interaction system mentioned above. A scene map of a game scene is displayed in the graphical user interface; a controlled virtual object is located in the game scene; the controlled virtual object is controlled by the terminal device; the game scene generally includes various types of terrain, roads, buildings, etc.; in sailing games, the game scene mainly includes land areas and ocean areas; the scene map identifies the distribution of various areas in the game scene, the distribution locations of important roads and buildings, and other information; the scene map may be displayed above the display level of the game scene; the scene map may be a small map, or a large map displayed through a window. The controlled virtual object may be an object such as a ship or a character; the player performs relevant operations through the terminal device, and then controls the controlled virtual object through the terminal device, for example, controlling the movement path and posture of the controlled virtual object, performing interactive operations, etc.
[0038] like Figure 1 As shown, the method for generating the navigation path includes the following steps:
[0039] Step S102, in response to a selection operation on a first position in the scene map, generating a mapping map of the scene map; wherein the mapping map is the same as the scene map; and the mapping map and the scene map are adjacently arranged;
[0040] Players can select a destination in the scene map. The selection operation can be a single-click operation, a double-click operation, or a trigger operation for a specified control. After the first position is selected, the first position can be used as the destination. It should be noted that some areas in the scene map may not allow the selection operation to be performed. For example, in a sailing game, a ship cannot directly reach a position on the land area. If the first position is in the land area, the selection operation cannot be successfully performed. For another example, there may be an unlocked area in the game scene. The controlled virtual object cannot reach the unlocked area. If the first position is in the unlocked area, the selection operation cannot be successfully performed.
[0041] If the location where the player performs the selection operation is located in the above-mentioned land area or an unlocked area, the selection operation cannot be performed and the selection operation cannot be responded to. At this time, a prompt message can be generated to prompt that the location where the selection operation is currently performed cannot be used as a destination.
[0042] The mapping map of the above-mentioned scene map can be obtained by copying the scene map, and the map content and map size of the mapping map are the same as those of the scene map; after the mapping map is generated, the mapping map is set adjacent to the scene map. In one way, there is one mapping map, which is located on the left side, right side, top side, bottom side, etc. of the scene map; in another way, the mapping map includes multiple mapping maps, which are distributed at different positions of the scene map, and each mapping map is adjacent to the scene map.
[0043] In the above manner, by setting the mapping map adjacent to the scene map, the cyclical nature of the game scene can be represented by a plane map, that is, in the game scene, the controlled virtual object can reach position B along the path in the first direction at position A, or along the path in the second direction; and the first direction and the second direction are opposite or approximately opposite directions. In the scene map, position B and position A have a specific relative direction, such as the first direction mentioned above, so the controlled virtual object can only reach position B along the path in the relative direction; and in this embodiment, the scene map is also adjacent to the mapping map; in this case, position B and position A have two relative directions; specifically, the controlled virtual object reaches position B from position A along the path in the first direction; or it can reach position B in the mapping map from position A along the second direction.
[0044] After the mapping map and the scene map are set adjacent to each other, two positions that were originally far apart in the scene map can obtain a closer path through the mapping map; for example, position C located at the left edge of the scene map and position D located at the right edge of the scene map. If the path is only found through the scene map, then the path will most likely need to pass through the entire scene map; in this embodiment, if the mapping map position is adjacent to the left side of the scene map, at this time, the right edge of the mapping map is adjacent to the left edge of the scene map, then the distance between position C in the scene map and position D in the mapping map is very close. At this time, the path does not need to pass through the entire scene map, and position D can be reached through only a very short path.
[0045] Step S104, determining a mapping position of the first position in the mapping map;
[0046] It should be noted that the mapping map does not need to be displayed in the graphical user interface to avoid confusion for players. Since the mapping map is the same as the scene map, each position in the scene map can find a corresponding position in the mapping map. For the first position, the corresponding position in the mapping map is the above-mentioned mapping position.
[0047] In one method, a first coordinate system can be established based on the scene map to obtain a first coordinate value of the first position; then a second coordinate system can be established based on the mapping map, and the mapping position can be determined from the mapping map through the second coordinate system and the first coordinate value.
[0048] Step S106, determining a navigation path from the current position to the first position from the scene map based on the current position, the first position and the mapped position of the controlled virtual object;
[0049] Considering that there may be obstacles, preset roads, and inaccessible areas in the game scene, the controlled virtual object usually cannot reach the first position in a straight line, and needs to find a path in the scene map. The above navigation path can be generated by a preset path-finding algorithm.
[0050] In actual implementation, the pathfinding process usually starts from the current position of the controlled virtual object, searches for the first adjacent position of the current position, and the first adjacent position is closer to the first position; then, searches for the second adjacent position of the first adjacent position, and the second adjacent position is closer to the first position than the first adjacent position; that is, the first position can be used as a reference to guide the search direction of the position until the search reaches the first position, which is the end position of the navigation path.
[0051] In this embodiment, when searching for adjacent positions, not only the distance between the adjacent position and the first position should be considered, but also the distance between the adjacent position and the mapped position should be considered; that is, when searching for adjacent positions, the shortest path is used as the search basis. At this time, the search may be conducted toward the first position or toward the mapped position; if the distance between the mapped position and the current position is close, the end position of the navigation path is likely to be the mapped position.
[0052] In another implementation, the first position and the mapped position can be regarded as two end positions, and the path is searched from the current position from the first position and the mapped position respectively to obtain two initial paths, and then the lengths of the two initial paths are compared, and the initial path with the shortest length is used as the above navigation path.
[0053] Step S108, displaying the navigation path in the scene map.
[0054] If each position on the navigation path is located on the scene map, the navigation path can be directly displayed on the scene map, for example, by indicating the starting point of the navigation path (i.e., the current position mentioned above), the scene position passed through, and the end point (i.e., the first position mentioned above) in the form of arrows and dotted lines; but if the end point of the navigation path is a mapped position, part of the path in the navigation path is located on the mapped map. At this time, the part of the path on the mapped map is remapped to the scene map, and the complete navigation path is displayed on the scene map. In this case, the navigation path may be divided into two paths. For example, the scene map is a rectangle, the starting point of the navigation path is located in the left area of the rectangle, and the end point is located in the right area of the rectangle. The navigation path extends from the starting point to the position K on the left edge of the scene map, and then continues to extend from the position M on the right edge of the scene map until it reaches the end point; wherein, position K and position M are adjacent in the game scene, but are farther apart in the scene map.
[0055] The above-mentioned method for generating a navigation path generates a mapping map of the scene map in response to a selection operation for the first position in the scene map; wherein the mapping map is the same as the scene map; the mapping map and the scene map are set adjacent to each other; the mapping position of the first position is determined in the mapping map; based on the current position, the first position and the mapping position of the controlled virtual object, the navigation path from the current position to the first position is determined from the scene map; and the navigation path is displayed in the scene map. In this method, when generating a navigation path, the scene map and the mapping map are set adjacent to each other, and the mapping position of the selected first position is determined in the mapping map, so that the navigation path can be generated based on the first position and the mapping position together. For game scenes with cyclic properties, compared with the method of generating a navigation path based only on the scene map, this embodiment adds the path-finding direction of the path, which is conducive to obtaining a more optimized or shorter path, thereby improving the player's gaming experience.
[0056] The following embodiments continue to describe how a mapping map is generated and how a mapping position is determined.
[0057] Specifically, the mapping map and the scene map are arranged horizontally; based on the relative position of the mapping map and the scene map, and the map size of the scene map, the mapping position of the first position is determined.
[0058] Figure 2 As an example, the mapping map and the scene map are both rectangular and have the same size; the mapping map and the scene map are arranged horizontally, and the mapping map is located on the left side of the scene map; of course, the mapping map can also be located on the right side, top side, bottom side, etc. of the scene map, such as Figure 3 , the mapping map is located below the scene map.
[0059] In one implementation, a coordinate system may be established based on the scene map, in which the coordinate value of the first position is (x, y). Figure 2 For example, the mapping map is on the left side of the scene map, and the width of the scene map is w. At this time, the coordinates of the mapping position are (xw, y). Figure 3 For example, the mapping map is located at the lower side of the scene map, and the height of the scene map is h. At this time, the coordinates of the mapping position are (x, yh).
[0060] observe Figure 2 It can be seen that in the scene map, the distance between the current position and the first position is far, so the generated path length is also longer; but the distance between the current position and the mapped position is close, at this time, the generated path length is also shorter; through the path between the current position and the mapped position, the navigation path between the current position and the first position in the scene map can be obtained.
[0061] This method can obtain the optimal path with a shorter distance and improve the player's gaming experience.
[0062] In another embodiment, the mapping map includes a first mapping map and a second mapping map; the first mapping map, the scene map and the second mapping map are arranged horizontally in sequence; based on a first relative position between the first mapping map and the scene map, and a map size of the scene map, a first mapping position is determined in the first mapping map; based on a second relative position between the second mapping map and the scene map, and a map size of the scene map, a second mapping position is determined in the second mapping map.
[0063] Figure 4 As an example, assuming that the coordinate value of the first position is (x, y) and the width of the scene map is w, then the coordinate value of the first mapping position is (xw, y) and the coordinate value of the second mapping position is (x+w, y). Figure 4In the example, the current position is close to the first mapping position in the first mapping map. In this case, the navigation path is usually determined based on the path between the current position and the first mapping position.
[0064] However, considering that the current position may be any position in the scene map, mapping maps are set on both sides of the scene map, which is conducive to finding the final navigation path for the current position at any position. Figure 5 As an example, the current position is located in the right area of the scene map. At this time, among the first mapping position, the first position and the second mapping position, the second mapping position is closest to the current position. At this time, the navigation path is generally determined based on the path between the current position and the second mapping position.
[0065] In the above manner, by setting a plurality of mapping maps, it is helpful to generate navigation paths in multiple directions, thereby obtaining a more preferred path.
[0066] The following embodiments continue to describe a specific implementation method for determining a navigation path from a current position to a first position in a scene map based on the current position, the first position and the mapped position of the controlled virtual object.
[0067] In one method, the current position of the controlled virtual object is determined as the first position to be traversed; based on the current position, the first position and the mapped position of the controlled virtual object, the next traversal position adjacent to the position to be traversed is determined from a specified position range of the position to be traversed; the next traversal position is updated to the position to be traversed, and the step of determining the next traversal position adjacent to the position to be traversed from a specified position range of the position to be traversed based on the current position, the first position and the mapped position of the controlled virtual object is continued until the next traversal position is the first position.
[0068] In order to facilitate pathfinding and generating navigation paths in the scene map, the scene map can be divided into multiple grids, each of which is a square with a side length of unit length; the mapping map is also divided into grids according to the same unit length. In the scene map, the intersection of the horizontal and vertical lines is regarded as a position. When the mapping map and the scene map are arranged horizontally, in order to facilitate the calculation of the distance, if the first side of the mapping map is adjacent to the second side of the scene map, the distance between the first side and the second side is also set to the above unit length.
[0069] In this embodiment, the path is found by traversal, and the navigation path is finally obtained; first, the current position of the controlled virtual object is the starting point of the navigation path, and the current position is taken as the first traversal position, and the next traversal position adjacent to the position to be traversed is determined from the specified position range of the position to be traversed; wherein the specified position range can be the position on the left, right, upper, lower, upper left, lower left, upper right, and lower right of the position to be traversed; the distance between these positions and the position to be traversed is a unit length, or a square root of 2 times the unit length. In addition, the specified position range can also be expanded, for example, a distance threshold is pre-set, and all positions within the distance threshold are taken as positions within the specified position range. There may be positions around the position to be traversed that the controlled virtual object cannot pass through, such as the position where the obstacle is located. At this time, it is necessary to delete these positions that cannot be passed from the specified position range, and select the next traversal position from the positions that the controlled virtual object can pass through.
[0070] In this embodiment, based on the current position, the first position and the mapped position of the controlled virtual object, the next traversal position adjacent to the position to be traversed is determined; in a specific implementation method, at least one adjacent position of the position to be traversed is obtained; wherein the distance between the adjacent position and the position to be traversed is less than a preset distance threshold; based on the current position, the first position and the mapped position of the controlled virtual object, the priority of the adjacent position is calculated; the adjacent position with the highest priority is determined as the next traversal position adjacent to the position to be traversed.
[0071] For example, for each adjacent position, the priority of the adjacent position is calculated based on parameters such as the distance, relative angle, etc. between the adjacent position and the current position, the first position, and the mapped position. When calculating the priority based on the distance, it can be implemented in the following manner: calculate the minimum distance between the adjacent position and the current position, and determine the minimum distance as the first intermediate value; calculate the first distance value between the adjacent position and the first position, and the second distance value between the adjacent position and the mapped position; determine the second intermediate value based on the minimum distance value between the first distance value and the second distance value; determine the priority of the adjacent position based on the first intermediate value and the second intermediate value.
[0072] The minimum distance between the adjacent position and the current position can be determined by the diagonal distance between the adjacent position and the current position. In the grid of the scene map and the mapping map, if it is allowed to move directly from a position to a position diagonally adjacent to the position, the diagonally adjacent position can be the upper left, lower left, upper right, or lower right position. In this case, the diagonal distance can be used to represent the distance between the adjacent position and the current position, such as Figure 6 shown.
[0073] It should be noted here that when determining the second intermediate value, it is determined based on the minimum distance value of the first distance value and the second distance value, that is, the distance value corresponding to the position that the adjacent position is closer to, the first position and the mapped position, is used; in addition, when determining the second intermediate value, some other parameter values may also be referred to, in which case, the second intermediate value is equal to the sum of the minimum distance value and the other parameter values. Then, the sum of the first intermediate value and the second intermediate value is used as the priority of the adjacent position. Of course, the product of the first intermediate value and the second intermediate value can also be used as the priority of the adjacent position.
[0074] It can be seen from the above embodiments that the mapping map may include multiple mapping positions including a first mapping position and a second mapping position; the first mapping position and the second mapping position are located in different mapping maps; at this time, in order to find a path from the scene map and multiple mapping maps, it is necessary to calculate the first distance value between the adjacent position and the first position; calculate the second distance value between the adjacent position and the first mapping position, and the second distance value between the adjacent position and the second mapping position. In this case, a first distance value and multiple second distance values are obtained, the minimum distance value is determined from the first distance value and the multiple second distance values, and then the second intermediate value is determined in the above manner.
[0075] The above-mentioned priority can be calculated by a heuristic function, which can be expressed as: f*(n)=g*(n)+h*(n); wherein n represents the adjacent position; f*(n) represents the priority of the adjacent position; g*(n) represents the minimum distance between the adjacent position and the above-mentioned current position, that is, the above-mentioned first intermediate value; h*(n) represents the above-mentioned second intermediate value, which is determined based on the minimum distance value among the distances between the adjacent position and the above-mentioned first position and the mapping position, and the minimum distance value is added to other parameter values to obtain the second intermediate value.
[0076] In the above manner, the distance between the neighboring position and the mapped position is introduced into the heuristic function, so that the A* algorithm can support the bidirectional path finding in the map with cyclic properties of this embodiment, thereby obtaining the navigation path with the shortest distance.
[0077] The following embodiments use the A* algorithm to find the path and generate a navigation path. Figure 7 As shown, the following steps are included:
[0078] Step S702, initializing the set of positions to be traversed and the set of positions that have been traversed;
[0079] After initialization, the to-be-traversed collection and the traversed collection are empty.
[0080] Step S704, adding the current position to the set of positions to be traversed, and setting the priority of the current position to the highest priority;
[0081] Step S706, if the set of positions to be traversed is not empty, obtaining the target position with the highest priority from the set of positions to be traversed;
[0082] Step S708, if the target position is not the first position, delete the target position from the set of positions to be traversed, and add the target position to the set of positions that have been traversed;
[0083] When the target position is not the first position, that is, the target position is not the end position, the target position is deleted from the set of positions to be traversed, and the target position is added to the set of traversed positions.
[0084] Step S710, traverse the neighboring positions of the target position, if the neighboring position is not in the set of positions to be traversed, set the parent position of the neighboring position as the target position, calculate the priority of the neighboring position based on the current position, the first position and the mapping position of the controlled virtual object, and add the neighboring position to the set of positions to be traversed; continue to execute if the set of positions to be traversed is not empty, and obtain the target position with the highest priority from the set of positions to be traversed, that is, continue the loop starting from the above step S606.
[0085] In the above steps, based on the current position, the first position and the mapped position of the controlled virtual object, the priority of the adjacent position is calculated, and the method of calculating the priority in the above embodiment can be referred to. If the traversed adjacent position is in the set of positions to be traversed, the adjacent position is skipped and the traversal continues to the next adjacent position.
[0086] Step S712: if the target position is the first position, starting from the first position, gradually track the parent position until reaching the current position, and use the tracked path as the navigation path.
[0087] In the above step S710, if the neighboring position is not located in the set of positions to be traversed, the parent position of the neighboring position is set as the target position. Through this step, the neighboring position and the target position generate a parent-child relationship. When the target position reaches the first position, a series of adjacent positions will be generated, and the adjacent positions have a parent-child relationship. Along the parent-child relationship, it can be gradually tracked from the first position to the current position. At this time, the path composed of the positions experienced during the tracking process is used as the navigation path.
[0088] In the above-mentioned embodiment, the distance between the position on the scene map and the first position and the mapped position is comprehensively considered during the training process to perform path finding. Another path finding method is provided below.
[0089] Starting from the current position of the controlled virtual object, a pathfinding operation is performed in the scene map to the first position to obtain a first initial path; starting from the current position of the controlled virtual object, a pathfinding operation is performed in the scene map and the mapping map to the mapping position to obtain a second initial path; based on the first initial path and the second initial path, a navigation path from the current position to the first position is determined.
[0090] The above-mentioned pathfinding operation can be implemented using the aforementioned A* algorithm, or can be implemented using other algorithms. In the above-mentioned method, the first position is used as the end point for pathfinding, and the mapped position is used as the end point for pathfinding, and after obtaining two initial paths, an initial path is determined as the navigation path.
[0091] Specifically, if the path length of the first initial path is smaller than the path length of the second initial path, the first initial path is determined as the navigation path from the current position to the first position; if the path length of the second initial path is smaller than the path length of the first initial path, the partial path in the second initial path located in the mapping map is mapped to the scene map to obtain the navigation path from the current position to the first position.
[0092] If there are multiple mapped locations, each mapped location can be used as the end point for path finding. In this way, multiple initial paths can be obtained through multiple training operations, and then the path with the shortest distance is determined from the initial paths as the navigation path.
[0093] Corresponding to the above method embodiment, see Figure 8 The schematic diagram of the structure of a navigation path generation device shown in the figure provides a graphical user interface through a terminal device; a scene map of a game scene is displayed in the graphical user interface; a controlled virtual object is located in the game scene; the controlled virtual object is controlled by the terminal device; the device includes:
[0094] A map generation module 80, for generating a mapping map of the scene map in response to a selection operation on a first position in the scene map; wherein the mapping map is the same as the scene map; and the mapping map is adjacent to the scene map;
[0095] a position determination module 82, for determining a mapping position of a first position in a mapping map;
[0096] a path determination module 84, for determining a navigation path from the current position to the first position from the scene map based on the current position, the first position and the mapped position of the controlled virtual object;
[0097] The path display module 86 is used to display the navigation path in the scene map.
[0098] The above-mentioned navigation path generation device generates a mapping map of the scene map in response to a selection operation on the first position in the scene map; wherein the mapping map is the same as the scene map; the mapping map and the scene map are set adjacent to each other; the mapping position of the first position is determined in the mapping map; based on the current position, the first position and the mapping position of the controlled virtual object, the navigation path from the current position to the first position is determined from the scene map; and the navigation path is displayed in the scene map. In this method, when generating the navigation path, the scene map and the mapping map are set adjacent to each other, and the mapping position of the selected first position is determined in the mapping map, so that the navigation path can be generated based on the first position and the mapping position together. For game scenes with cyclic properties, compared with the method of generating a navigation path based only on the scene map, this embodiment adds the path-finding direction of the path, which is conducive to obtaining a more optimized or shorter path, thereby improving the player's gaming experience.
[0099] The above-mentioned position determination module is also used to: arrange the mapping map and the scene map horizontally; and determine the mapping position of the first position based on the relative position of the mapping map and the scene map, and the map size of the scene map.
[0100] The above-mentioned mapping map includes a first mapping map and a second mapping map; the first mapping map, the scene map and the second mapping map are arranged horizontally in sequence; the above-mentioned position determination module is also used to: determine the first mapping position in the first mapping map based on the first relative position of the first mapping map and the scene map, and the map size of the scene map; determine the second mapping position in the second mapping map based on the second relative position of the second mapping map and the scene map, and the map size of the scene map.
[0101] The above-mentioned path determination module is also used to: determine the current position of the controlled virtual object as the first position to be traversed; based on the current position, the first position and the mapped position of the controlled virtual object, determine the next traversal position adjacent to the position to be traversed from the specified position range of the position to be traversed; update the next traversal position to the position to be traversed, and continue to execute the step of determining the next traversal position adjacent to the position to be traversed from the specified position range of the position to be traversed based on the current position, the first position and the mapped position of the controlled virtual object, until the next traversal position is the first position.
[0102] The above-mentioned path determination module is also used to: obtain at least one adjacent position of the position to be traversed; wherein the distance between the adjacent position and the position to be traversed is less than a preset distance threshold; calculate the priority of the adjacent position based on the current position, the first position and the mapping position of the controlled virtual object; and determine the adjacent position with the highest priority as the next traversal position adjacent to the position to be traversed.
[0103] The above-mentioned path determination module is also used to: calculate the minimum distance between the adjacent position and the current position, and determine the minimum distance as the first intermediate value; calculate the first distance value between the adjacent position and the first position, and the second distance value between the adjacent position and the mapped position; determine the second intermediate value based on the minimum distance value between the first distance value and the second distance value; determine the priority of the adjacent position based on the first intermediate value and the second intermediate value.
[0104] The above-mentioned mapping maps include multiple; the mapping position includes a first mapping position and a second mapping position; the first mapping position and the second mapping position are located in different mapping maps; the above-mentioned calculation of the first distance value between the adjacent position and the first position; the calculation of the second distance value between the adjacent position and the first mapping position, and the calculation of the second distance value between the adjacent position and the second mapping position.
[0105] The above-mentioned path determination module is also used to: initialize the set of positions to be traversed and the set of positions that have been traversed; add the current position to the set of positions to be traversed, and set the priority of the current position to the highest priority; if the set of positions to be traversed is not empty, obtain the target position with the highest priority from the set of positions to be traversed; if the target position is not the first position, delete the target position from the set of positions to be traversed, and add the target position to the set of positions that have been traversed; traverse the neighboring positions of the target position, if the neighboring position is not located in the set of positions to be traversed, set the parent position of the neighboring position as the target position, calculate the priority of the neighboring position based on the current position, the first position and the mapped position of the controlled virtual object, and add the neighboring position to the set of positions to be traversed; continue to execute the step of obtaining the target position with the highest priority from the set of positions to be traversed if the set of positions to be traversed is not empty; if the target position is the first position, start from the first position and gradually track the parent position until reaching the current position, and use the tracked path as the navigation path.
[0106] The above-mentioned path determination module is also used to: start from the current position of the controlled virtual object, perform a pathfinding operation to the first position in the scene map to obtain a first initial path; start from the current position of the controlled virtual object, perform a pathfinding operation to the mapping position in the scene map and the mapping map to obtain a second initial path; based on the first initial path and the second initial path, determine the navigation path from the current position to the first position.
[0107] The above-mentioned path determination module is also used to: if the path length of the first initial path is less than the path length of the second initial path, determine the first initial path as the navigation path from the current position to the first position; if the path length of the second initial path is less than the path length of the first initial path, map the part of the path in the second initial path located in the mapping map to the scene map to obtain the navigation path from the current position to the first position.
[0108] This embodiment also provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above navigation path generation method. The electronic device can be a server or a touch terminal device.
[0109] See also Fig. 9 As shown, the electronic device includes a processor 100 and a memory 101, wherein the memory 101 stores machine executable instructions that can be executed by the processor 100, and the processor 100 executes the machine executable instructions to implement the above-mentioned method for generating a navigation path.
[0110] Further, Fig. 9 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 100 , the communication interface 103 and the memory 101 are connected via the bus 102 .
[0111] The memory 101 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0112] The processor 100 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 100. The above processor 100 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101 and completes the steps of the method of the above embodiment in combination with its hardware.
[0113] The processor in the above electronic device can implement the following operations in the above navigation path generation method by executing the machine executable instructions:
[0114] A graphical user interface is provided through a terminal device; a scene map of a game scene is displayed in the graphical user interface; a controlled virtual object is located in the game scene; the controlled virtual object is controlled by the terminal device; in response to a selection operation on a first position in the scene map, a mapping map of the scene map is generated; wherein the mapping map is the same as the scene map; the mapping map is adjacent to the scene map; a mapping position of the first position is determined in the mapping map; based on the current position, the first position and the mapping position of the controlled virtual object, a navigation path from the current position to the first position is determined from the scene map; and the navigation path is displayed in the scene map.
[0115] The mapping map and the scene map are arranged horizontally; based on the relative position of the mapping map and the scene map, and the map size of the scene map, the mapping position of the first position is determined.
[0116] The mapping map includes a first mapping map and a second mapping map; the first mapping map, the scene map and the second mapping map are arranged horizontally in sequence; based on a first relative position between the first mapping map and the scene map, and a map size of the scene map, a first mapping position is determined in the first mapping map; based on a second relative position between the second mapping map and the scene map, and a map size of the scene map, a second mapping position is determined in the second mapping map.
[0117] The current position of the controlled virtual object is determined as the first position to be traversed; based on the current position, the first position and the mapped position of the controlled virtual object, the next traversal position adjacent to the position to be traversed is determined from the specified position range of the position to be traversed; the next traversal position is updated to the position to be traversed, and the step of determining the next traversal position adjacent to the position to be traversed from the specified position range of the position to be traversed based on the current position, the first position and the mapped position of the controlled virtual object is continued until the next traversal position is the first position.
[0118] Acquire at least one adjacent position of the position to be traversed; wherein the distance between the adjacent position and the position to be traversed is less than a preset distance threshold; calculate the priority of the adjacent position based on the current position, the first position and the mapping position of the controlled virtual object; determine the adjacent position with the highest priority as the next traversal position adjacent to the position to be traversed.
[0119] Calculate the minimum distance between the neighboring position and the current position, and determine the minimum distance as a first intermediate value; calculate a first distance value between the neighboring position and the first position, and a second distance value between the neighboring position and the mapped position; determine a second intermediate value based on the minimum distance value between the first distance value and the second distance value; determine the priority of the neighboring position based on the first intermediate value and the second intermediate value.
[0120] The above-mentioned mapping maps include multiple; the mapping position includes a first mapping position and a second mapping position; the first mapping position and the second mapping position are located in different mapping maps; a first distance value between an adjacent position and the first position is calculated; a second distance value between an adjacent position and the first mapping position, and a second distance value between an adjacent position and the second mapping position are calculated.
[0121] Initialize the set of positions to be traversed and the set of positions that have been traversed; add the current position to the set of positions to be traversed, and set the priority of the current position to the highest priority; if the set of positions to be traversed is not empty, obtain the target position with the highest priority from the set of positions to be traversed; if the target position is not the first position, delete the target position from the set of positions to be traversed, and add the target position to the set of positions that have been traversed; traverse the neighboring positions of the target position, and if the neighboring position is not in the set of positions to be traversed, set the parent position of the neighboring position to the target position, calculate the priority of the neighboring position based on the current position, the first position and the mapped position of the controlled virtual object, and add the neighboring position to the set of positions to be traversed; continue to execute the step of obtaining the target position with the highest priority from the set of positions to be traversed if the set of positions to be traversed is not empty; if the target position is the first position, start from the first position and gradually track the parent position until reaching the current position, and use the tracked path as the navigation path.
[0122] Starting from the current position of the controlled virtual object, a pathfinding operation is performed in the scene map to the first position to obtain a first initial path; starting from the current position of the controlled virtual object, a pathfinding operation is performed in the scene map and the mapping map to the mapping position to obtain a second initial path; based on the first initial path and the second initial path, a navigation path from the current position to the first position is determined.
[0123] If the path length of the first initial path is less than the path length of the second initial path, the first initial path is determined as the navigation path from the current position to the first position; if the path length of the second initial path is less than the path length of the first initial path, the part of the second initial path located in the mapping map is mapped to the scene map to obtain the navigation path from the current position to the first position.
[0124] In this method, when generating a navigation path, the scene map and the mapping map are set adjacent to each other, and the mapping position of the selected first position is determined in the mapping map, so that the navigation path can be generated based on the first position and the mapping position. For game scenes with cyclic properties, compared with the navigation path generated only based on the scene map, this embodiment adds the path finding direction, which is conducive to obtaining a more optimized or shorter path, thereby improving the player's gaming experience.
[0125] This embodiment further provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned navigation path generation method.
[0126] The machine executable instructions stored in the machine readable storage medium can implement the following operations in the method for generating the navigation path by executing the machine executable instructions:
[0127] A graphical user interface is provided through a terminal device; a scene map of a game scene is displayed in the graphical user interface; a controlled virtual object is located in the game scene; the controlled virtual object is controlled by the terminal device; in response to a selection operation on a first position in the scene map, a mapping map of the scene map is generated; wherein the mapping map is the same as the scene map; the mapping map is adjacent to the scene map; a mapping position of the first position is determined in the mapping map; based on the current position, the first position and the mapping position of the controlled virtual object, a navigation path from the current position to the first position is determined from the scene map; and the navigation path is displayed in the scene map.
[0128] The mapping map and the scene map are arranged horizontally; based on the relative position of the mapping map and the scene map, and the map size of the scene map, the mapping position of the first position is determined.
[0129] The mapping map includes a first mapping map and a second mapping map; the first mapping map, the scene map and the second mapping map are arranged horizontally in sequence; based on a first relative position between the first mapping map and the scene map, and a map size of the scene map, a first mapping position is determined in the first mapping map; based on a second relative position between the second mapping map and the scene map, and a map size of the scene map, a second mapping position is determined in the second mapping map.
[0130] The current position of the controlled virtual object is determined as the first position to be traversed; based on the current position, the first position and the mapped position of the controlled virtual object, the next traversal position adjacent to the position to be traversed is determined from the specified position range of the position to be traversed; the next traversal position is updated to the position to be traversed, and the step of determining the next traversal position adjacent to the position to be traversed from the specified position range of the position to be traversed based on the current position, the first position and the mapped position of the controlled virtual object is continued until the next traversal position is the first position.
[0131] Acquire at least one adjacent position of the position to be traversed; wherein the distance between the adjacent position and the position to be traversed is less than a preset distance threshold; calculate the priority of the adjacent position based on the current position, the first position and the mapping position of the controlled virtual object; determine the adjacent position with the highest priority as the next traversal position adjacent to the position to be traversed.
[0132] Calculate the minimum distance between the neighboring position and the current position, and determine the minimum distance as a first intermediate value; calculate a first distance value between the neighboring position and the first position, and a second distance value between the neighboring position and the mapped position; determine a second intermediate value based on the minimum distance value between the first distance value and the second distance value; determine the priority of the neighboring position based on the first intermediate value and the second intermediate value.
[0133] The above-mentioned mapping maps include multiple; the mapping position includes a first mapping position and a second mapping position; the first mapping position and the second mapping position are located in different mapping maps; a first distance value between an adjacent position and the first position is calculated; a second distance value between an adjacent position and the first mapping position, and a second distance value between an adjacent position and the second mapping position are calculated.
[0134] Initialize the set of positions to be traversed and the set of positions that have been traversed; add the current position to the set of positions to be traversed, and set the priority of the current position to the highest priority; if the set of positions to be traversed is not empty, obtain the target position with the highest priority from the set of positions to be traversed; if the target position is not the first position, delete the target position from the set of positions to be traversed, and add the target position to the set of positions that have been traversed; traverse the neighboring positions of the target position, and if the neighboring position is not in the set of positions to be traversed, set the parent position of the neighboring position to the target position, calculate the priority of the neighboring position based on the current position, the first position and the mapped position of the controlled virtual object, and add the neighboring position to the set of positions to be traversed; continue to execute the step of obtaining the target position with the highest priority from the set of positions to be traversed if the set of positions to be traversed is not empty; if the target position is the first position, start from the first position and gradually track the parent position until reaching the current position, and use the tracked path as the navigation path.
[0135] Starting from the current position of the controlled virtual object, a pathfinding operation is performed in the scene map to the first position to obtain a first initial path; starting from the current position of the controlled virtual object, a pathfinding operation is performed in the scene map and the mapping map to the mapping position to obtain a second initial path; based on the first initial path and the second initial path, a navigation path from the current position to the first position is determined.
[0136] If the path length of the first initial path is less than the path length of the second initial path, the first initial path is determined as the navigation path from the current position to the first position; if the path length of the second initial path is less than the path length of the first initial path, the part of the second initial path located in the mapping map is mapped to the scene map to obtain the navigation path from the current position to the first position.
[0137] In this method, when generating a navigation path, the scene map and the mapping map are set adjacent to each other, and the mapping position of the selected first position is determined in the mapping map, so that the navigation path can be generated based on the first position and the mapping position. For game scenes with cyclic properties, compared with the navigation path generated only based on the scene map, this embodiment adds the path finding direction, which is conducive to obtaining a more optimized or shorter path, thereby improving the player's gaming experience.
[0138] The computer program product of the navigation path generation method, device and electronic device provided in the embodiments of the present invention includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the method described in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated here.
[0139] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0140] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, and it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0141] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0142] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0143] Finally, it should be noted that the above embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above embodiments, those skilled in the art should understand that any person skilled in the art can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for generating a navigation path, characterized in that: Providing a graphical user interface through a terminal device; the graphical user interface displays a scene map of a game scene; The controlled virtual object is located in the game scene; The controlled virtual object is controlled by the terminal device; the method comprises: In response to a selection operation on a first position in the scene map, a mapping map of the scene map is generated; wherein the mapping map is the same as the scene map; and the mapping map is disposed adjacent to the scene map; determining a mapped position of the first position in the mapped map; Determining a navigation path from the current position to the first position from the scene map based on the current position of the controlled virtual object, the first position and the mapped position; The navigation path is displayed in the scene map.
2. The method according to claim 1, characterized in that The step of determining a mapping position of the first position in the mapping map comprises: Arranging the mapping map and the scene map horizontally; Based on the relative position of the mapping map and the scene map, and the map size of the scene map, the mapping position of the first position is determined.
3. The method according to claim 2, characterized in that The mapping map includes a first mapping map and a second mapping map; the first mapping map, the scene map and the second mapping map are arranged horizontally in sequence; The step of determining the mapping position of the first position based on the relative position between the mapping map and the scene map, and the map size of the scene map, comprises: Determining a first mapping position in the first mapping map based on a first relative position between the first mapping map and the scene map, and a map size of the scene map; Based on a second relative position between the second mapping map and the scene map, and a map size of the scene map, a second mapping position is determined in the second mapping map.
4. The method according to claim 1, characterized in that: The step of determining a navigation path from the current position to the first position from the scene map based on the current position of the controlled virtual object, the first position and the mapped position comprises: Determine the current position of the controlled virtual object as the first position to be traversed; Based on the current position of the controlled virtual object, the first position and the mapped position, determining a next traversal position adjacent to the position to be traversed from a specified position range of the position to be traversed; The next traversal position is updated to the position to be traversed, and the step of determining the next traversal position adjacent to the position to be traversed from the specified position range of the position to be traversed based on the current position of the controlled virtual object, the first position and the mapping position is continued until the next traversal position is the first position.
5. The method according to claim 4, characterized in that The step of determining a next traversal position adjacent to the position to be traversed from a specified position range of the position to be traversed based on the current position of the controlled virtual object, the first position and the mapped position comprises: Acquire at least one adjacent position of the position to be traversed; wherein the distance between the adjacent position and the position to be traversed is less than a preset distance threshold; Calculating priorities of neighboring positions based on the current position of the controlled virtual object, the first position, and the mapped position; The adjacent position with the highest priority is determined as the next traversal position adjacent to the position to be traversed.
6. The method according to claim 5, characterized in that The step of calculating the priority of the adjacent positions based on the current position of the controlled virtual object, the first position and the mapped position comprises: Calculating a minimum distance between the adjacent position and the current position, and determining the minimum distance as a first intermediate value; Calculate a first distance value between the adjacent position and the first position, and a second distance value between the adjacent position and the mapped position; determining a second intermediate value based on a minimum distance value between the first distance value and the second distance value; Priorities of the neighboring locations are determined based on the first intermediate value and the second intermediate value.
7. The method according to claim 6, characterized in that The mapping maps include a plurality of mapping positions; the mapping positions include a first mapping position and a second mapping position; the first mapping position and the second mapping position are located in different mapping maps; The step of calculating a first distance value between the adjacent position and the first position, and a second distance value between the adjacent position and the mapped position comprises: Calculate a first distance value between the adjacent position and the first position; A second distance value between the adjacent position and the first mapped position and a second distance value between the adjacent position and the second mapped position are calculated.
8. The method according to claim 1, characterized in that The step of determining a navigation path from the current position to the first position from the scene map based on the current position of the controlled virtual object, the first position and the mapped position comprises: Initialize the set of positions to be traversed and the set of positions that have been traversed; Adding the current position to the set of positions to be traversed, and setting the priority of the current position to the highest priority; If the set of positions to be traversed is not empty, obtaining the target position with the highest priority from the set of positions to be traversed; If the target position is not the first position, deleting the target position from the set of positions to be traversed, and adding the target position to the set of traversed positions; Traversing the neighboring positions of the target position, if the neighboring position is not located in the set of positions to be traversed, setting the parent position of the neighboring position to be the target position, calculating the priority of the neighboring position based on the current position of the controlled virtual object, the first position and the mapped position, and adding the neighboring position to the set of positions to be traversed; continuing to execute the step of obtaining the target position with the highest priority from the set of positions to be traversed if the set of positions to be traversed is not empty; If the target location is the first location, starting from the first location, the parent location is tracked step by step until the current location is reached, and the tracked path is used as the navigation path.
9. The method according to claim 1, characterized in that: The step of determining a navigation path from the current position to the first position from the scene map based on the current position of the controlled virtual object, the first position and the mapped position comprises: Starting from the current position of the controlled virtual object, performing a pathfinding operation toward the first position in the scene map to obtain a first initial path; Starting from the current position of the controlled virtual object, a pathfinding operation is performed in the scene map and the mapping map toward the mapping position to obtain a second initial path; A navigation path from the current location to the first location is determined based on the first initial path and the second initial path.
10. The method according to claim 9, characterized in that The step of determining a navigation path from the current position to the first position based on the first initial path and the second initial path includes: If the path length of the first initial path is less than the path length of the second initial path, determining the first initial path as the navigation path from the current position to the first position; If the path length of the second initial path is less than the path length of the first initial path, the partial path of the second initial path located in the mapping map is mapped to the scene map to obtain the navigation path from the current position to the first position.
11. A navigation path generation device, characterized in that: Providing a graphical user interface through a terminal device; the graphical user interface displays a scene map of a game scene; The controlled virtual object is located in the game scene; The controlled virtual object is controlled by the terminal device; the device comprises: A map generation module, configured to generate a mapping map of the scene map in response to a selection operation on a first position in the scene map; wherein the mapping map is the same as the scene map; and the mapping map is disposed adjacent to the scene map; a position determination module, configured to determine a mapping position of the first position in the mapping map; a path determination module, configured to determine a navigation path from the current position to the first position from the scene map based on the current position of the controlled virtual object, the first position and the mapped position; A path display module is used to display the navigation path in the scene map.
12. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the method for generating a navigation path according to any one of claims 1 to 10.
13. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the method for generating a navigation path according to any one of claims 1 to 10.
