Game way-finding method and device, electronic equipment and storage medium

By using path navigation graphs and scaling factor mapping techniques in 2D games, the problems of low pathfinding accuracy and high overhead in 2D games are solved, and efficient pathfinding calculation is achieved.

CN120939573APending Publication Date: 2025-11-14GUANGZHOU HUYA INFORMATION TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510975302.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-15
Publication Date
2025-11-14

AI Technical Summary

Technical Problem

Existing 3D game pathfinding technology has high overhead and low pathfinding accuracy in 2D games, and cannot effectively improve the pathfinding accuracy and reduce overhead in 2D games.

Method used

A path navigation map is drawn based on walkable area information from the game's 2D map. The starting and target positions are mapped to the path navigation map using a scaling factor. The navigation path is calculated and then mapped back to the game's 2D map, thus separating game information from pathfinding calculations.

Benefits of technology

It improves the pathfinding accuracy of 2D games, reduces pathfinding overhead, optimizes the game map generation process, and reduces performance consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120939573A_ABST
    Figure CN120939573A_ABST
Patent Text Reader

Abstract

The invention relates to the field of computer data processing, in particular to a game way-finding method and device, electronic equipment and a storage medium, and the method comprises the following steps: based on a game two-dimensional map, obtaining an initial position and a target position of a to-be-navigated object; acquiring a navigation path in a path navigation map according to the initial position and the target position; wherein the path navigation map is drawn according to walking area information of the game two-dimensional map, and the size of the path navigation map and the size of the game two-dimensional map form a corresponding relation; and acquiring a corresponding navigation path in the game two-dimensional map according to the navigation path in the path navigation map. Compared with the prior art, the method has the advantages that the position acquisition of the to-be-navigated object is separated from navigation calculation by utilizing the corresponding relationship between the game two-dimensional map and the path navigation map, so that the navigation path calculation operation is optimized, and the overhead of game path finding is reduced on the basis of improving the path finding precision.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer data processing, and more specifically, to a game pathfinding method, apparatus, electronic device, and storage medium. Background Technology

[0002] Pathfinding in games refers to calculating the path formed when a movable object moves from its current position to a target location. In 2D game environments, traditional 2D pathfinding techniques suffer from low accuracy. While 3D pathfinding techniques can achieve higher accuracy, existing techniques typically analyze the game scene model and generate a game map containing scene information through complex preprocessing. Pathfinding is then performed using this map information, which is computationally expensive for 2D games. Therefore, a technique is urgently needed to improve the accuracy of pathfinding in 2D games while effectively reducing its overhead. Summary of the Invention

[0003] This invention provides a game pathfinding method, apparatus, electronic device, and storage medium to improve the pathfinding accuracy of 2D games while reducing pathfinding overhead.

[0004] According to a first aspect of this application, a game pathfinding method is provided, the method comprising: Based on the game's 2D map, obtain the starting and target positions of the object to be navigated; Based on the starting position and the target position, a navigation path is obtained from the path navigation map; wherein, the path navigation map is drawn based on the walkable area information of the game's two-dimensional map, and the size of the path navigation map corresponds to the size of the game's two-dimensional map; Based on the navigation path in the path navigation map, obtain the corresponding navigation path in the game's two-dimensional map.

[0005] Optionally, obtaining the navigation path from the path navigation map based on the starting position and the target position includes: Obtain the scaling factor between the path navigation map and the game 2D map; Based on the scaling factor, obtain the starting navigation position and target navigation position corresponding to the starting position and target position in the path navigation map; Based on the walkable area information, the navigation path from the starting navigation position to the target navigation position is obtained from the path navigation map.

[0006] Optionally, obtaining the starting navigation position and target navigation position corresponding to the starting position and target position in the path navigation map according to the scaling factor includes: Obtain the starting coordinates and target coordinates of the starting position and the target position in the game's two-dimensional map; The starting coordinates and target coordinates are adjusted according to the scaling factor to obtain the corresponding starting navigation coordinates and target navigation coordinates; The starting navigation position and the target navigation position are determined in the path navigation map based on the starting navigation coordinates and the target navigation coordinates.

[0007] Optionally, obtaining the navigation path from the starting navigation position to the target navigation position in the path navigation map based on the walkable area information includes: Obtain the region data of each walkable region from the walkable region information; the region data is the position of each region vertex of the walkable region in the path navigation map; Based on the regional data, obtain the navigation path from the starting navigation position to the target navigation position in the path navigation map.

[0008] Optionally, obtaining the navigation path from the starting navigation position to the target navigation position in the path navigation map based on the walkable area information includes: Obtain the valid location points in each walkable area from the walkable area information; Obtain a set of valid location points from the starting navigation position to the target navigation position, and obtain the navigation path in the path navigation map based on the set of valid location points.

[0009] Optionally, obtaining the set of valid location points from the starting navigation position to the target navigation position includes: The nearest valid location point to the starting navigation location is obtained as the starting location point, and the nearest valid location point to the target navigation location is obtained as the target location point; Path planning is performed using the starting point, the target point, and the valid points in each walkable area to obtain a set of valid points from the starting navigation position to the target navigation position.

[0010] Optionally, obtaining the scaling factor between the path navigation map and the game 2D map includes: Obtain the area coordinate information of the two-dimensional map in the game; The dimensions of the game's two-dimensional map are obtained based on the region coordinate information; The scaling factor is obtained based on the correspondence between the size of the game's 2D map and the size of the path navigation map.

[0011] According to a second aspect of this application, a game pathfinding device is provided, the device comprising: The location acquisition module is used to obtain the starting and target positions of the object to be navigated based on the game's two-dimensional map; The first path acquisition module is used to acquire a navigation path from the path navigation map based on the starting position and the target position; wherein, the path navigation map is drawn based on the walkable area information of the game's two-dimensional map, and the size of the path navigation map corresponds to the size of the game's two-dimensional map; The second path acquisition module is used to acquire the corresponding navigation path in the game's two-dimensional map based on the navigation path in the path navigation map.

[0012] According to a third aspect of this application, an electronic device is provided, comprising: Memory, used to store one or more computer programs; A processor, when the one or more computer programs are executed by the processor, implements the game pathfinding method described in the first aspect above.

[0013] According to a fourth aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the game pathfinding method described in the first aspect above.

[0014] Based on any of the above aspects, the game pathfinding method, device, electronic device, and computer storage medium provided in this application use a path navigation map that corresponds to the size of a two-dimensional game map and includes information on walkable areas within that two-dimensional game map as the basis for pathfinding and navigation calculation. The starting and target positions of the object to be navigated, determined on the two-dimensional game map, are mapped onto the path navigation map using the correspondence between the two-dimensional game map and the path navigation map to calculate the navigation path. The navigation path is then mapped back onto the two-dimensional game map. Compared to pathfinding and navigation on a game map containing complex parameter information, this application utilizes walkable area information and the correspondence between images, separating other information in the game from the pathfinding and navigation calculation. This allows for more accurate calculation of the navigation path while reducing game performance overhead. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 This is an illustrative application scenario diagram of the game pathfinding method provided in this embodiment.

[0017] Figure 2 A flowchart of the game pathfinding method provided in this embodiment.

[0018] Figure 3 This is a flowchart illustrating the steps for obtaining the navigation path provided in this embodiment.

[0019] Figure 4 This is a schematic diagram illustrating the steps for obtaining the scaling factor in this embodiment.

[0020] Figure 5 This is a flowchart illustrating the steps for obtaining the starting navigation position and the target navigation position in this embodiment.

[0021] Figure 6 This is a schematic diagram of the functional modules of the game pathfinding device provided in this embodiment.

[0022] Figure 7 This is a schematic diagram of the structure of the electronic device provided in this embodiment. Detailed Implementation

[0023] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this application. To better illustrate the following embodiments, some components in the drawings may be omitted, enlarged, or reduced, and do not represent the actual dimensions of the product; it is understandable to those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings.

[0024] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0025] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0026] Pathfinding in games refers to calculating the path a movable object takes when moving from its current position to a target location. Games include 2D and 3D games. Pathfinding technology in 3D games has continuously improved with technological advancements, while the development of pathfinding technology in the foundational 2D games has been relatively slow.

[0027] Because traditional 2D game pathfinding techniques have low accuracy, 3D game pathfinding technologies are often applied to 2D games. However, existing 3D game pathfinding technologies typically analyze game scene models and generate game maps containing complex scene information through complex preprocessing operations, such as scene data extraction and navigation mesh baking. These 3D pathfinding technologies are not designed for 2D game maps, thus often leading to increased pathfinding overhead when applied to 2D games. Therefore, there is an urgent need for a technology that can improve pathfinding accuracy and effectively reduce pathfinding overhead in 2D games.

[0028] This embodiment provides a technical solution that can solve the above problems. The specific implementation of this application will be described in detail below with reference to the accompanying drawings.

[0029] An exemplary diagram illustrating an application scenario of a game pathfinding method provided in this application embodiment is shown below. Figure 1 As shown, the application scenario includes at least a server 100 and a terminal 200 that can communicate with the server 100.

[0030] Understandably, the server 100 can be an independent electronic device or a cluster of multiple electronic devices; the terminal 200 can be a smartphone terminal, personal computer, tablet computer, vehicle terminal, etc., but is not limited to these.

[0031] In one possible implementation, server 100 and terminal 200 may respectively execute the game pathfinding method provided in the embodiments of this application, or, optionally, the game pathfinding method provided in the embodiments of this application may be partially executed in server 100 and partially executed in terminal 200.

[0032] like Figure 2 As shown, this embodiment provides a game pathfinding method, which may include the following steps: S1: Based on the game's 2D map, obtain the starting and target positions of the object to be navigated; In this embodiment, the game 2D map is a 2D rendered image rendered into the game engine, thus enabling the acquisition of the starting and target positions of the navigable object within the game based on the game 2D map. The 2D rendered map can be drawn according to the game scene, and the drawn 2D rendered map is rendered into the game engine to obtain the game 2D map.

[0033] In one implementation, the two-dimensional drawing map can be a two-dimensional artwork pre-drawn based on the game scene of the game. It is understood that the game can be a 2D game or a 3D game; when the game is a 3D game, the two-dimensional drawing map can be a two-dimensional planar artwork pre-drawn based on the game scene of the 3D game.

[0034] In one implementation, the game engine determines the regional coordinate information of the game's two-dimensional map based on its coordinate system. The regional coordinate information is the coordinate range of the game's two-dimensional map within the game engine's coordinate system, and can be represented by a set of coordinates from the bottom left corner to the top right corner of the game's two-dimensional map. The game engine can then use this regional coordinate information, based on its coordinate system, to obtain the current coordinates and destination coordinates of the object to be navigated as the starting position and target position.

[0035] S2: Obtain the navigation path from the path navigation map based on the starting position and the target position; In this embodiment, the path navigation map is drawn based on the walkable area information of the game's two-dimensional map, and the size of the path navigation map corresponds to the size of the game's two-dimensional map. Specifically, the path navigation map and the game's two-dimensional map have the same aspect ratio; the walkable area information may include several walkable areas of the two-dimensional map; objects in the game can move within these walkable areas and move from one walkable area to another walkable area connected to it; and the walkable areas are polygons.

[0036] During the rendering process of the 2D drawn map to obtain the game's 2D map, the game engine may adjust the size of the 2D drawn map, but will not adjust its content. Therefore, the game's 2D map corresponds in size to the 2D drawn map, and the 2D drawn map also contains the walkable area information.

[0037] In one implementation, obtaining the path navigation map may include: A base map of a corresponding size is constructed based on the two-dimensional map. The base map can be a blank two-dimensional image, and the aspect ratio of the base map is the same as that of the two-dimensional map. Then, based on the walkable areas of the two-dimensional map, corresponding walkable areas are divided on the base map, and the base map with the walkable areas divided is used as the path navigation map.

[0038] Since the path navigation map corresponds to the size of the two-dimensional map, there is a corresponding relationship between the size of the path navigation map and the size of the game's two-dimensional map. Therefore, there is a mapping relationship between each location point in the game's two-dimensional map and each location point in the path navigation map. When a location point is obtained in the game's two-dimensional map, its corresponding location point on the path navigation map can be obtained; similarly, when a location point is obtained in the path navigation map, its corresponding location point on the game's two-dimensional map can be obtained.

[0039] In this embodiment, after obtaining the two-dimensional drawing map and the path navigation map in advance, the two-dimensional drawing map and the path navigation map can be loaded into the game. The two-dimensional drawing map is rendered into the game engine as the game map to obtain the game two-dimensional map, and the path navigation map serves as the basis for navigation path calculation.

[0040] In one implementation, a navigation coordinate data structure can be constructed based on the path navigation map. The navigation coordinate data structure includes the navigation coordinates of all locations in the path navigation map. The navigation coordinate data structure can be represented by the set of coordinates between the bottom left corner and the top right corner of the path navigation map. The size of the path navigation map remains unchanged, so the navigation coordinates can be constructed based on the path navigation map itself or based on the locations loaded in the path navigation map, without further limitation.

[0041] In some implementations, the navigation coordinate data structure may include a walkable area coordinate dataset, which contains coordinate information of each walkable area in the path navigation map. The coordinate information may include the navigation coordinates of each vertex of the corresponding walkable area. In the walkable area coordinate dataset, the navigation coordinates of each vertex in each walkable area may be recorded in a preset order, such as recording the navigation coordinates of each vertex in a counterclockwise direction along the walkable area.

[0042] In some implementations, the navigation coordinate data structure may further include an unwalkable area coordinate dataset, which contains coordinate information of each unwalkable area in the path navigation map. It is understood that the unwalkable area can be set as other areas on the path navigation map besides the walkable areas, and can be divided during the acquisition of the path navigation map. The setting of the unwalkable area coordinate dataset is similar to the setting of the walkable area coordinate dataset, and will not be further described here.

[0043] Preferably, the navigation coordinate data structure can be pre-constructed based on the path navigation map. In this case, the operation of loading the two-dimensional drawing map and the path navigation map into the game can actually be loading the navigation coordinate data structure of the two-dimensional drawing map and the path navigation map into the game. It should be noted that the coordinate systems corresponding to the area coordinates and the navigation coordinates are constructed based on the same reference unit, so that the area coordinates of the game's two-dimensional map can correspond to the navigation coordinates in the path navigation map; preferably, the reference unit can be set to the pixels of the image.

[0044] In one implementation, such as Figure 3 As shown, obtaining the navigation path from the path navigation map based on the starting position and the target position may include: S11: Obtain the scaling factor between the path navigation map and the game 2D map; In this embodiment, when the 2D rendered map is rendered into the game engine, the game engine will scale the 2D rendered map according to the game's display requirements. It may enlarge or shrink the 2D rendered map, so the size of the game's 2D map dynamically changes compared to the 2D rendered map. Therefore, it is necessary to obtain the scaling factor between the path navigation map and the game's 2D map to determine the mapping relationship between each location point in the path navigation map and the game's 2D map.

[0045] In one implementation, such as Figure 4 As shown, obtaining the scaling factor may include: S111: Obtain the regional coordinate information of the game's two-dimensional map within the game; S112: Obtain the dimensions of the game's two-dimensional map based on the region coordinate information; S113: Obtain the scaling factor based on the correspondence between the size of the game 2D map and the size of the path navigation map.

[0046] In this embodiment, the size of the game's 2D map can be obtained by calculating the difference between the x-coordinate values ​​of its rightmost and leftmost boundaries; the size of the path navigation map can be obtained from the navigation coordinate data structure by calculating the x-coordinate values ​​of its rightmost and leftmost boundaries. Then, the ratio of the size of the game's 2D map to the size of the path navigation map is calculated as the scaling factor.

[0047] S12: Based on the scaling factor, obtain the starting navigation position and target navigation position corresponding to the starting position and target position in the path navigation map; In some implementations, such as Figure 5 As shown, obtaining the starting navigation position and target navigation position corresponding to the starting position and target position in the path navigation map according to the scaling factor may include: S121: Obtain the starting coordinates and target coordinates of the starting position and the target position in the game's two-dimensional map; S122: Adjust the starting coordinates and target coordinates according to the scaling factor to obtain the corresponding starting navigation coordinates and target navigation coordinates; S123: Determine the starting navigation position and the target navigation position in the path navigation map based on the starting navigation coordinates and the target navigation coordinates.

[0048] Understandably, since the scaling factor is obtained in step S51 and the mapping relationship between the game 2D map and the path navigation map is obtained, adjustments can be made based on the starting coordinates of the starting position and the target coordinates of the target position to obtain the starting navigation coordinates and target navigation coordinates corresponding to the starting coordinates and the target coordinates on the path navigation map. Then, the starting navigation position and the target navigation position can be determined on the path navigation map based on the starting navigation coordinates and the target navigation coordinates.

[0049] In some implementations, the adjustment may include: Align the game's 2D map and the path navigation map, multiply the aligned starting coordinates and target coordinates by the scaling factor, and obtain the starting navigation coordinates and target navigation coordinates based on the product and the alignment method.

[0050] S13: Based on the walkable area information, obtain the navigation path from the starting navigation position to the target navigation position in the path navigation map.

[0051] In this embodiment, obtaining the navigation path from the starting navigation position to the target navigation position in the path navigation map based on the walkable area information may include: Obtain the region data of each walkable region from the walkable region information; the region data is the position of each region vertex of the walkable region in the path navigation map; Based on the regional data, obtain the navigation path from the starting navigation position to the target navigation position in the path navigation map.

[0052] Understandably, the walkable area represents the area that the object to be navigated can move through. Therefore, based on the area data of the walkable area, the walkable area that the object to be navigated needs to pass through to move from the starting navigation position to the target navigation position can be obtained, and then the navigation path can be obtained based on the walkable area that needs to be passed through.

[0053] Furthermore, in one embodiment, obtaining the navigation path from the starting navigation position to the target navigation position in the path navigation map based on the walkable area information may include: Obtain the valid location points in each walkable area from the walkable area information; Obtain a set of valid location points from the starting navigation position to the target navigation position, and obtain the navigation path in the path navigation map based on the set of valid location points.

[0054] In this embodiment, the effective location points within the walkable area are reference points for movement within the corresponding walkable area. This can be understood as the movement of the object to be navigated in the game being mapped in the path navigation map as moving from one effective location point to another. Therefore, the set of effective location points from the starting navigation position to the target navigation position represents the navigation path of the object to be navigated in the path navigation map. Each walkable area has at least one effective location point, which can be set according to the size and distribution of the walkable area, as well as the required navigation accuracy.

[0055] In one optional implementation, the walkable area may be provided with an effective location point, which may be set as the midpoint of the walkable area. The horizontal coordinate of the navigation coordinate of the effective location point is the average of the horizontal coordinates of the vertices of the walkable area, and the vertical coordinate of the navigation coordinate of the effective location point is the average of the vertical coordinates of the vertices of the walkable area.

[0056] In this embodiment, since the game's 2D map may be scaled, the starting navigation position and the target navigation position may not match the valid location points. Therefore, in some implementations, obtaining the set of valid location points from the starting navigation position to the target navigation position may include: The nearest valid location point to the starting navigation location is obtained as the starting location point, and the nearest valid location point to the target navigation location is obtained as the target location point; Path planning is performed using the starting point, the target point, and the valid points in each walkable area to obtain a set of valid points from the starting navigation position to the target navigation position.

[0057] In this embodiment, after obtaining the starting position point and the target position point, a preset path planning algorithm can be used to determine the optimal set of effective position points from the starting position point to the target position point, thereby obtaining the navigation path.

[0058] S3: Obtain the corresponding navigation path in the game's two-dimensional map based on the navigation path in the path navigation map.

[0059] In this embodiment, the navigation path can be represented by a set of valid location points in the path navigation map. After obtaining the navigation path of the path navigation map, the navigation coordinates of each valid location point in the set of valid location points can be adjusted in reverse by the scaling factor to obtain the regional coordinates of the corresponding location points in the game 2D map. Then, the corresponding navigation path in the rendered map can be obtained through the regional coordinates of each corresponding location point.

[0060] In this embodiment, a two-dimensional map of the game is first drawn, and then a corresponding path navigation map is drawn based on the two-dimensional map. Walkable areas are delineated on the path navigation map. The two-dimensional map is directly used as the game map, and the path navigation map is used as the basis for pathfinding calculation. Compared with the method of analyzing the game scene and generating a game map containing scene information, this embodiment greatly optimizes the game map generation process and reduces the overhead of the map generation process. At the same time, compared with the method of pathfinding based on reference game scene information, this embodiment utilizes walkable area information and the correspondence between images to separate other information in the game from the pathfinding and navigation calculation, which can calculate the navigation path more accurately and reduce the game performance overhead.

[0061] Optionally, this embodiment also provides a game pathfinding device, such as... Figure 6 As shown, the game pathfinding device may include: The location acquisition module 11 is used to acquire the starting position and target position of the object to be navigated based on the game's two-dimensional map; In this embodiment, the location acquisition module 11 can be used to perform... Figure 2 For a detailed description of the location acquisition module 11 shown in step S1, please refer to the description of step S1.

[0062] The first path acquisition module 12 is used to acquire a navigation path in the path navigation map based on the starting position and the target position; In this embodiment, the first path acquisition module 12 can be used to execute Figure 2 For a detailed description of the first path acquisition module 12, please refer to the description of step S2 shown in step S2.

[0063] The second path acquisition module 13 is used to acquire the corresponding navigation path in the game's two-dimensional map based on the navigation path in the path navigation map.

[0064] In this embodiment, the second path acquisition module 13 can be used to execute Figure 2 For a detailed description of the second path acquisition module 13, please refer to the description of step S3 shown in step S3.

[0065] It is understood that the above-described device embodiments and method embodiments can correspond to each other, and similar descriptions of the device embodiments can be referred to the method embodiments. To avoid repetition, further details are omitted here. The game pathfinding device provided in this application can execute a game pathfinding method provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects of executing the method. The functional modules of the game pathfinding device can be implemented in hardware, in software instructions, or in a combination of hardware and software modules.

[0066] Specifically, the steps of the method embodiments of this application can be implemented by integrated logic circuits in the processor hardware and / or instructions in software form. The steps of the game pathfinding method in the embodiments of this application can be directly implemented by a hardware encoding processor, or by a combination of hardware and software modules in the encoding processor. Optionally, the software module can be located in random access memory, and storage media such as read-only memory, programmable read-only memory, flash memory, electrically erasable programmable memory, and registers are all acceptable. The storage medium is located in the memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps in the above method embodiments.

[0067] This application provides an electronic device with the following structure: Figure 7 As shown. The electronic device can be as described in this embodiment. Figure 1 The server 100 or terminal 200 shown.

[0068] The electronic device includes a memory 21, a processor 22, a communication module 23, and an input / output interface 24, etc. Optionally, the memory 21, the processor 22, the communication module 23, and the input / output interface 24 can be connected and communicate with each other through a bus 25.

[0069] The memory 21 is used to store one or more computer programs and to transfer the code of the computer programs to the processor 22; when the one or more computer programs are executed by the processor 22, the game pathfinding method in this embodiment of the application is implemented.

[0070] Optionally, the electronic device can be connected to a network via communication module 23 to communicate with other devices, such as terminals or servers, to achieve data interaction. The electronic device can be various forms of digital computers, exemplarily such as desktop computers, servers, workbenches, mainframes, or other types of computers. The electronic device can also be various forms of mobile terminals, exemplarily such as smartphones, tablets, wearable devices (such as helmets, glasses, watches, etc.), and other similar mobile terminals.

[0071] Optionally, the electronic device can connect to required input / output devices, such as a keyboard or display device, via the input / output interface 24. The electronic device itself may have a display device, and other display devices can also be connected externally via the input / output interface 24. Optionally, a storage device, such as a hard disk, can also be connected via the input / output interface 24 to store data from the electronic device, read data from the storage device, or store data from the storage device in the memory 21. It is understood that the input / output interface 24 can be a wired interface or a wireless interface. Depending on the actual application scenario, the device connected to the input / output interface 24 can be a component of the electronic device or an external device connected to the electronic device when needed.

[0072] Optionally, the memory 21 may be a volatile memory and / or a non-volatile memory. The volatile memory may be a random access memory, etc., and the non-volatile memory may be a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, or a flash memory, etc.

[0073] Optionally, the computer program stored in the processor 22 can be divided into one or more modules, which are stored in the memory 21 and executed by the processor 22 to perform the method provided in this embodiment. The one or more modules can be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program in the electronic device.

[0074] Optionally, the processor 22 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 22 include, but are not limited to, a central processing unit, a graphics processing unit, a digital signal processor, various special-purpose artificial intelligence computing chips, various processors running machine learning model algorithms, and can also be any suitable controller, microcontroller, processor, etc. The processor 22 executes the various methods and processes of this embodiment, exemplarily, such as a game pathfinding method according to an embodiment of this application.

[0075] Optionally, the bus 25 may include a path for transmitting information. Depending on its function, the bus 25 may be divided into an address bus, a data bus, a control bus, etc.

[0076] In an optional implementation, this application embodiment also provides a computer storage medium storing a computer program thereon, which, when executed by a computer, enables the computer to perform the methods described in the above-described method embodiments. Part or all of the computer program can be loaded and / or installed on the memory 21 of an electronic device. When the computer program is executed by the processor 22, one or more steps of a game pathfinding method according to an embodiment of this application can be performed.

[0077] Optionally, the computer-readable storage medium may be a random access memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, etc.

[0078] Obviously, the above embodiments of this application are merely examples for clearly illustrating the technical solution of this application, and are not intended to limit the specific implementation of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of this application should be included within the protection scope of the claims of this application.

Claims

1. A game pathfinding method, characterized in that, The method includes: Based on the game's 2D map, obtain the starting and target positions of the object to be navigated; Based on the starting position and the target position, a navigation path is obtained from the path navigation map; wherein, the path navigation map is drawn based on the walkable area information of the game's two-dimensional map, and the size of the path navigation map corresponds to the size of the game's two-dimensional map; Based on the navigation path in the path navigation map, obtain the corresponding navigation path in the game's two-dimensional map.

2. The game pathfinding method according to claim 1, characterized in that, The step of obtaining the navigation path from the path navigation map based on the starting position and the target position includes: Obtain the scaling factor between the path navigation map and the game 2D map; Based on the scaling factor, obtain the starting navigation position and target navigation position corresponding to the starting position and target position in the path navigation map; Based on the walkable area information, the navigation path from the starting navigation position to the target navigation position is obtained from the path navigation map.

3. The game pathfinding method according to claim 2, characterized in that, The step of obtaining the starting navigation position and target navigation position corresponding to the starting position and target position in the path navigation map according to the scaling factor includes: Obtain the starting coordinates and target coordinates of the starting position and the target position in the game's two-dimensional map; The starting coordinates and target coordinates are adjusted according to the scaling factor to obtain the corresponding starting navigation coordinates and target navigation coordinates; The starting navigation position and the target navigation position are determined in the path navigation map based on the starting navigation coordinates and the target navigation coordinates.

4. The game pathfinding method according to claim 2, characterized in that, The step of obtaining the navigation path from the starting navigation position to the target navigation position in the path navigation map based on the walkable area information includes: Obtain the region data of each walkable region from the walkable region information; the region data is the position of each region vertex of the walkable region in the path navigation map; Based on the regional data, obtain the navigation path from the starting navigation position to the target navigation position in the path navigation map.

5. The game pathfinding method according to claim 2, characterized in that, The step of obtaining the navigation path from the starting navigation position to the target navigation position in the path navigation map based on the walkable area information includes: Obtain the valid location points in each walkable area from the walkable area information; Obtain a set of valid location points from the starting navigation position to the target navigation position, and obtain the navigation path in the path navigation map based on the set of valid location points.

6. The game pathfinding method according to claim 5, characterized in that, The step of obtaining the set of valid location points from the starting navigation position to the target navigation position includes: The nearest valid location point to the starting navigation location is obtained as the starting location point, and the nearest valid location point to the target navigation location is obtained as the target location point; Path planning is performed using the starting point, the target point, and the valid points in each walkable area to obtain a set of valid points from the starting navigation position to the target navigation position.

7. The game pathfinding method according to any one of claims 2-6, characterized in that, The step of obtaining the scaling factor between the path navigation map and the game 2D map includes: Obtain the area coordinate information of the two-dimensional map in the game; The dimensions of the game's two-dimensional map are obtained based on the region coordinate information; The scaling factor is obtained based on the correspondence between the size of the game's 2D map and the size of the path navigation map.

8. A game pathfinding device, characterized in that, The device includes: The location acquisition module is used to obtain the starting and target positions of the object to be navigated based on the game's two-dimensional map; The first path acquisition module is used to acquire a navigation path from the path navigation map based on the starting position and the target position; wherein, the path navigation map is drawn based on the walkable area information of the game's two-dimensional map, and the size of the path navigation map corresponds to the size of the game's two-dimensional map; The second path acquisition module is used to acquire the corresponding navigation path in the game's two-dimensional map based on the navigation path in the path navigation map.

9. An electronic device, characterized in that, include: Memory, used to store one or more computer programs; A processor, when the one or more computer programs are executed by the processor, implements the game pathfinding method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the game pathfinding method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Navigation method, navigation system and map data downloading method for navigation

    CN103389102A

  • Game path-searching method and apparatus

    CN106582023A

  • Route generation method and device for three-dimensional game scene, and storage medium

    CN110772791A

  • Safety path planning method based on large satellite grid map

    CN112161631A

  • Path finding method and device for virtual object in game and electronic equipment

    CN113144607A