Route searching method and device in game, computer device and readable storage medium

By dividing the game map into multiple map tiles and using field-programmable gate arrays to generate processor modules, the problem of high CPU or GPU pathfinding computation in ultra-large game scenes is solved, improving pathfinding efficiency and reducing the load on the central processing unit.

CN115957505BActive Publication Date: 2026-02-17BEIJING PIXEL SOFTWARE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211596778.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-12
Publication Date
2026-02-17
Estimated Expiration
2042-12-12

AI Technical Summary

Technical Problem

In large-scale game scenarios, using CPU or GPU for pathfinding calculations results in high computational costs and low efficiency.

Method used

The game map is divided into multiple map tiles, and a field-programmable gate array (FPGA) is used to generate processor modules. The pathfinding algorithm is executed in parallel by the processor modules, reducing the load on the central processing unit.

Benefits of technology

It improves the execution efficiency of the pathfinding algorithm, reduces the computational burden on the central processing unit, and optimizes the pathfinding process in the game.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115957505B_ABST
    Figure CN115957505B_ABST
Patent Text Reader

Abstract

The application discloses a path searching method and device in a game, a computer device and a readable storage medium, relates to the game field, and the method comprises the steps of dividing a game map into multiple map blocks; generating a processor module by using a field programmable logic gate array based on a high-level integrated tool; when a path searching request is received, the starting position and the terminal position of a moving target are acquired, and the corresponding starting map block and the terminal map block are determined; if the starting map block is consistent with the terminal map block, the processor module is corresponded to the lattice node of the starting map block, the moving path in the target block is determined by using the processor module, and the moving path in the target block is written back to a preset channel; finally, the central processing unit reads the moving path in the target block in the preset channel, and the target moving path is obtained. Based on this, the execution of the path searching algorithm mainly depends on the processor module generated by the field programmable logic gate array, so that the load of the central processing during path searching is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of games, and more particularly to a pathfinding method, apparatus, computer device, and readable storage medium in games. Background Technology

[0002] In-game pathfinding is typically achieved by using algorithms such as A-Star, executed by the CPU (Central Processing Unit) or GPU (Graphics Processing Unit).

[0003] However, with the continuous upgrading of software and hardware, game scenes are constantly expanding, and even ultra-large game scenes larger than 8KM*8KM*8KM have appeared. Therefore, if the CPU or GPU is still used to implement pathfinding in ultra-large game scenes, it will result in the CPU having to pay a very heavy computational cost, and the pathfinding efficiency will be low. Summary of the Invention

[0004] In view of this, the present invention provides a pathfinding method, apparatus, computer device and readable storage medium in games, which improves the current situation where using CPU or GPU to implement pathfinding in ultra-large game scenes results in the CPU having to pay a very heavy computational cost and the pathfinding efficiency being low.

[0005] In a first aspect, embodiments of the present invention provide a pathfinding method in a game, applied to a computer device, the computer device including a central processing unit and a field-programmable gate array, the method comprising:

[0006] The game map is divided into multiple map blocks, wherein each map block includes a preset number of grid nodes;

[0007] Based on high-level synthesis tools, the preset number of processor modules are generated using the field-programmable gate array;

[0008] In response to a pathfinding request, the system obtains the starting and ending positions of the moving target corresponding to the pathfinding request, and determines the starting map tile to which the starting position belongs and the ending map tile to which the ending position belongs.

[0009] If the starting map tile is the same as the ending map tile, then the processor module is mapped one-to-one with the grid nodes of the starting map tile, and the processor module is used to determine the movement path within the target tile based on a preset algorithm, and the movement path within the target tile is written back to a preset channel, wherein the preset channel includes a high-speed serial computer expansion bus standard channel.

[0010] Read the movement path within the target block in the preset channel to obtain the target movement path corresponding to the pathfinding request.

[0011] Optionally, in one feasible embodiment of the present invention, dividing the game map into multiple map tiles includes:

[0012] The game map is divided into multiple map tiles, and the inter-tile movement path between two connected map tiles is determined based on the adjacency relationship of each map tile.

[0013] After responding to a pathfinding request, obtaining the starting and ending positions of the moving target corresponding to the pathfinding request, and determining the starting map tile to which the starting position belongs and the ending map tile to which the ending position belongs, the method further includes:

[0014] If the starting map tile and the ending map tile are not the same, then all target map tiles corresponding to the pathfinding request are determined, and the movement paths between all target map tiles are determined.

[0015] For each target map tile, the processor module is mapped one-to-one with the grid nodes of the target map tile, and the corresponding processor module is used to determine the movement path within the target tile based on a preset algorithm, and the movement path within the target tile is written back to the preset channel.

[0016] Read the movement path within the target block in the preset channel, and obtain the target movement path corresponding to the pathfinding request based on the movement path between the target blocks.

[0017] Optionally, in one feasible embodiment of the present invention, if the starting map tile and the ending map tile are inconsistent, determining all target map tiles corresponding to the pathfinding request and determining the inter-target tile movement paths corresponding to all target map tiles includes:

[0018] If the starting map tile and the ending map tile are not the same, then all target map tiles corresponding to the pathfinding request are determined based on the A* algorithm, and the inter-target movement paths corresponding to all target map tiles are determined.

[0019] Optionally, in one feasible embodiment of the present invention, the grid node includes obstacle grid nodes and non-obstacle grid nodes;

[0020] If the starting map tile is the same as the ending map tile, then the processor module is mapped one-to-one with the grid nodes of the starting map tile, and the processor module is used to determine the movement path within the target tile based on a preset algorithm, and the movement path within the target tile is written back to a preset channel, including:

[0021] If the starting map tile is the same as the ending map tile, then the processor module is mapped one-to-one with the grid nodes of the starting map tile;

[0022] The starting grid node and the ending grid node in the starting map block are determined using the starting position and the ending position, respectively.

[0023] For each non-obstacle grid node in the starting map block, excluding the starting grid node and the scanned node, the processor module corresponding to the non-obstacle grid node repeatedly executes the preset steps at a preset cycle until the ending grid node is set as the scanned node. Then, the preset path set corresponding to the ending grid node is used to determine the movement path within the target block, and the movement path within the target block is written back to the preset channel.

[0024] The preset steps include:

[0025] Based on a preset period, detect whether there is a starting grid node or a scanned node within a preset range;

[0026] If a starting cell node exists, the direction from the starting cell node to the non-obstacle cell node is recorded in the preset path set of the non-obstacle cell node;

[0027] If there are scanned nodes, then according to the preset path set of the scanned nodes, the target node with the smallest distance between the starting grid node and the non-obstacle grid node among all the scanned nodes is selected, and the direction of the target node pointing to the non-obstacle grid node and the information in the preset path set of the target node are recorded in the preset path set of the non-obstacle grid node.

[0028] Set the non-obstacle grid node as a scanned node.

[0029] Optionally, in one feasible embodiment of the present invention, the preset step further includes:

[0030] If the number of directions recorded in the preset path set of the scanned node exceeds a preset number, then the scanned node is set as an unwalkable node.

[0031] Secondly, embodiments of the present invention provide a pathfinding device in a game, applied to a computer device, the computer device including a central processing unit and a field-programmable gate array, the device comprising:

[0032] A partitioning module is used to divide the game map into multiple map tiles, wherein each map tile includes a preset number of grid nodes;

[0033] A generation module is used to generate the preset number of processor modules using the field-programmable gate array based on high-level synthesis tools.

[0034] The response module is used to respond to a pathfinding request, obtain the starting position and ending position of the moving target corresponding to the pathfinding request, and determine the starting map tile to which the starting position belongs and the ending map tile to which the ending position belongs.

[0035] The write-back module is used to map the starting map tile to the grid nodes of the starting map tile one by one if the starting map tile is the same as the ending map tile, and to use the processor module to determine the movement path within the target tile based on a preset algorithm, and to write back the movement path within the target tile to a preset channel, wherein the preset channel includes a high-speed serial computer expansion bus standard channel.

[0036] The reading module is used to read the movement path within the target block in the preset channel to obtain the target movement path corresponding to the pathfinding request.

[0037] Optionally, in one feasible embodiment of the present invention, the partitioning module is further configured to divide the game map into multiple map blocks, and determine the inter-block movement path between two connected map blocks based on the adjacency relationship of each map block;

[0038] The device further includes:

[0039] The determination module is used to determine all target map tiles corresponding to the pathfinding request and determine the inter-target movement paths corresponding to all target map tiles if the starting map tile and the ending map tile are inconsistent.

[0040] The path write-back module is used to map each target map tile to a grid node of the target map tile, and to use the corresponding processor module to determine the movement path within the target tile based on a preset algorithm, and to write the movement path within the target tile back to the preset channel.

[0041] The path determination module is used to read the movement path within the target block in the preset channel, and obtain the target movement path corresponding to the pathfinding request based on the movement path between the target blocks.

[0042] Optionally, in one feasible embodiment of the present invention, the determining module is further configured to determine all target map blocks corresponding to the pathfinding request based on the A* algorithm if the starting map block and the ending map block are inconsistent, and to determine the inter-target block movement path corresponding to all target map blocks.

[0043] Thirdly, embodiments of the present invention provide a computer device, including a memory and a processor, wherein the memory stores a computer program, and the computer program, when run on the processor, executes a pathfinding method in any of the games disclosed in the first aspect.

[0044] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, which, when run on a processor, executes a pathfinding method in any of the games disclosed in the first aspect.

[0045] In the pathfinding method in the game provided by this invention, the computer device divides the game map into multiple map tiles, and then completes pathfinding based on the smaller map tiles in subsequent processes to avoid the high load caused by directly performing pathfinding on the complete game map. Next, based on high-level synthesis tools, a preset number of processor modules are generated using field-programmable gate arrays (FPGAs) to simulate and replace the grid nodes in the map tiles in subsequent processes to execute the corresponding pathfinding algorithm, thereby reducing the pressure on the central processing unit (CPU). Subsequently, when a pathfinding request is received, the starting position and ending position of the moving target corresponding to the pathfinding request are obtained, and the starting map tile to which the starting position belongs and the ending map tile to which the ending position belongs are determined. Then, if the starting map tile and the ending map tile are the same, the processor modules are mapped one-to-one with the grid nodes of the starting map tile to simulate the grid nodes in the map tile through the processor modules, and the movement path within the target tile is determined by the processor modules based on a preset algorithm, and the movement path within the target tile is written back to a preset channel. Finally, the CPU reads the movement path within the target tile from the preset channel to obtain the target movement path corresponding to the pathfinding request. Based on this, the embodiments of the present invention enable the execution of the pathfinding algorithm to mainly rely on the processor modules generated by the field-programmable gate array, thereby reducing the load on the central processing unit during pathfinding; at the same time, since the embodiments of the present invention utilize multiple generated processor modules to execute the pathfinding algorithm, each step of the training algorithm will be executed by each processor module separately, thereby improving the execution efficiency of the pathfinding algorithm. Attached Figure Description

[0046] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope of protection of the present invention. In the various drawings, similar components are numbered similarly.

[0047] Figure 1 A flowchart illustrating the first pathfinding method in a game provided by an embodiment of the present invention is shown;

[0048] Figure 2 A flowchart illustrating a second pathfinding method in a game provided by an embodiment of the present invention is shown;

[0049] Figure 3 A flowchart illustrating the third pathfinding method in a game provided by an embodiment of the present invention is shown;

[0050] Figure 4 A schematic diagram of the pathfinding device in a game provided by an embodiment of the present invention is shown. Detailed Implementation

[0051] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0052] The components of the embodiments of the invention described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0053] In the following, the terms “comprising,” “having,” and their cognates, which may be used in various embodiments of the invention, are intended only to indicate a particular feature, number, step, operation, element, component, or combination thereof, and should not be construed as excluding, firstly, the presence of one or more other features, numbers, steps, operations, elements, components, or combinations thereof, or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations thereof.

[0054] Furthermore, the terms "first," "second," and "third" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.

[0055] Unless otherwise specified, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of the invention pertain. Terms (such as those defined in commonly used dictionaries) shall be interpreted as having the same meaning as in their contextual meaning in the relevant technical field and shall not be interpreted as having an idealized or overly formal meaning, unless clearly defined in the various embodiments of the invention.

[0056] Example 1

[0057] Reference Figure 1 The diagram shows a flowchart of a first pathfinding method in a game provided by an embodiment of the present invention. The pathfinding method in the game provided by the embodiment of the present invention is applied to a computer device, which includes a central processing unit and a field-programmable gate array.

[0058] It should be understood that the emergence of extremely large game scenes makes the execution of pathfinding algorithms by the central processing unit (CPU) computationally expensive and inefficient. Therefore, this embodiment of the invention employs a parallel / combined control approach between the CPU and a Field Programmable Gate Array (FPGA) to specifically optimize the pathfinding mechanism / function through the FPGA, thereby reducing the CPU's load on pathfinding.

[0059] Based on this, the pathfinding method in the game provided by the embodiments of the present invention includes:

[0060] Step S110: Divide the game map into multiple map blocks, wherein each map block includes a preset number of grid nodes.

[0061] In other words, the embodiments of the present invention first divide the complete game map into multiple blocks, namely map blocks. Then, when performing pathfinding, the smaller map blocks are pathfinded in batches, segment by segment / one by one, to avoid the high load and low efficiency caused by directly executing the pathfinding algorithm on the complete game map.

[0062] Understandably, a complete game scene consists of multiple grid nodes. Each grid node represents a terrain of a certain size in the game scene. For example, if the game scene is 100 meters by 100 meters, it can be composed of 100 grid nodes of 10 meters by 10 meters. Each grid node can refer to a part of the game scene.

[0063] Optionally, in one feasible approach, grid nodes are divided into sky nodes, ocean nodes, and ground nodes. That is, grid nodes will be classified into different categories based on the actual terrain they correspond to.

[0064] In another feasible embodiment of the present invention, the grid nodes include obstacle grid nodes and non-obstacle grid nodes.

[0065] It's easy to understand that obstacle grid nodes represent locations / areas that game characters / objects cannot walk or go to. For example, if a grid node corresponds to a game scene that only contains rocks that cannot be penetrated / walked through, then the grid node will be considered an obstacle grid node.

[0066] Non-obstacle grid nodes represent walkable locations for the game character. For example, if the game scene corresponding to a grid node only contains ground with a terrain height less than the preset value, or a forest scene composed of multiple tree objects, then the grid node will be treated as a non-obstacle grid node.

[0067] Step S120: Based on the high-level synthesis tool, the preset number of processor modules are generated using the field-programmable gate array.

[0068] Understandably, High Level Synthesis (HLS) tools can simulate the components of field-programmable gate arrays in a software environment, and can achieve the specified functions relatively efficiently.

[0069] Based on this, embodiments of the present invention utilize high-level synthesis tools to simulate / emulate each component of the field-programmable gate array as a grid node in a map tile in a software environment. That is, a processor module with the same number of grid nodes as the map tile is generated. In subsequent processes, each processor module completes the corresponding algorithm steps in parallel to achieve efficient pathfinding.

[0070] Step S130: In response to the pathfinding request, obtain the starting position and ending position of the moving target corresponding to the pathfinding request, and determine the starting map tile to which the starting position belongs and the ending map tile to which the ending position belongs.

[0071] It is understood that, in the embodiments of the present invention, the movement target corresponding to the pathfinding request represents a game object that needs to perform movement behavior, and can be regarded as a game character controlled by the player or the server.

[0072] Furthermore, the starting position indicates the current location of the moving target, i.e., the starting point. The ending position indicates the final location the moving target needs to reach, i.e., the ending point.

[0073] Based on this, when the computer device in this embodiment of the invention receives a pathfinding request, it will obtain the starting / current position and the destination position of the moving target corresponding to the pathfinding request, and determine the map tile where the moving target is currently located based on the starting position, and determine the map tile that the moving target finally needs to reach based on the destination position, that is, determine the starting map tile and the destination map tile.

[0074] Step S140: If the starting map block is consistent with the ending map block, then the processor module is mapped one-to-one with the grid nodes of the starting map block, and the processor module is used to determine the movement path within the target block based on a preset algorithm, and the movement path within the target block is written back to a preset channel, wherein the preset channel includes a high-speed serial computer expansion bus standard channel.

[0075] Understandably, if the starting map tile and the ending map tile are the same map tile, that is, the starting position and the ending position belong to the same map tile, then the computer device only needs to determine / find the movement path of the moving target within the map tile to complete the pathfinding.

[0076] Therefore, in this embodiment of the invention, the grid nodes of the starting map tile / ending map tile are mapped one-to-one with the previously generated processor modules, so that each processor module is equivalent to the grid node in the starting map tile. Thus, when executing the pathfinding algorithm, each processor module can complete each step of the pathfinding algorithm accordingly.

[0077] As an example, suppose the game scene corresponding to the starting map tile / ending map tile is a two-dimensional scene, and when the movement path within the target tile is obtained by the A* algorithm or Dijkstra's algorithm, then in the first iteration, the processor module corresponding to the starting position checks whether the eight vertices / grid nodes in the eight directions of up, down, left, right, up-left, up-right, down-left and down-right are vertices that have not yet been checked.

[0078] If so, in the next iteration, these 8 grid nodes are converted into checked vertices, and the processor modules corresponding to these 8 grid nodes will also execute "checking whether the grid nodes in its 8 directions are unchecked vertices". This process continues until the grid node corresponding to the termination position is detected.

[0079] It is easy to see that in this case, each step of the pathfinding algorithm will be executed by the corresponding processor module, thereby avoiding the situation where the central processing unit needs to execute all steps of the pathfinding algorithm completely, reducing the load on the central processing unit. At the same time, since the pathfinding algorithm is executed by multiple processor modules, the computer device can execute the pathfinding logic with higher efficiency.

[0080] Furthermore, since the movement path within the target block is generated by the processor module, that is, by the field-programmable gate array, but tasks such as triggering the movement behavior of the moving target or generating movement instructions still need to be executed by the central processing unit, the processor module in this embodiment of the invention will write back the movement path within the target block to a preset channel after generating the movement path within the target block, so that the central processing unit can obtain the movement path within the target block by reading the data in the preset channel.

[0081] It should be noted that, because the Peripheral Component Interconnect Express (PCIe) channel has a high data transmission rate, this embodiment of the invention uses the PCIe channel as the communication channel between the central processing unit and the field-programmable gate array. However, it is easy to understand that the preset channel type is configurable according to actual conditions, and the aforementioned PCIe channel is merely a preferred method used in this embodiment of the invention.

[0082] Furthermore, it can be understood that if the starting map tile and the ending map tile are not the same map tile, the steps performed by the computer device can be set according to the actual situation. For example, in a feasible method provided in an embodiment of the present invention, the computer device needs to determine each map tile that the moving target needs to pass through, and determine the intra-block movement path of the moving target in each map tile it passes through.

[0083] Step S150: Read the movement path within the target block in the preset channel to obtain the target movement path corresponding to the pathfinding request.

[0084] In other words, the central processing unit accesses a preset channel to obtain the target movement path in the preset channel, and then determines the target movement path in the starting map tile / ending map tile, thereby completing the pathfinding.

[0085] Based on this, the embodiments of the present invention enable the execution of the pathfinding algorithm to mainly rely on the processor modules generated by the field-programmable gate array, thereby reducing the load on the central processing unit during pathfinding; at the same time, since the embodiments of the present invention utilize multiple generated processor modules to execute the pathfinding algorithm, each step of the training algorithm will be executed by each processor module separately, thereby improving the execution efficiency of the pathfinding algorithm.

[0086] Optionally, in one feasible embodiment of the present invention, please refer to the following: Figure 2 This diagram illustrates a second pathfinding method in a game provided by an embodiment of the present invention. In this feasible method, step S110 specifically includes:

[0087] Step S111: Divide the game map into multiple map tiles, and determine the inter-tile movement path between two connected map tiles based on the adjacency relationship of each map tile.

[0088] Furthermore, after step S130, the method further includes:

[0089] Step S160: If the starting map tile and the ending map tile are inconsistent, then determine all target map tiles corresponding to the pathfinding request, and determine the inter-target tile movement path corresponding to all target map tiles;

[0090] Step S170: For each target map tile, the processor module is mapped one-to-one with the grid nodes of the target map tile, and the corresponding processor module is used to determine the movement path within the target tile based on a preset algorithm, and the movement path within the target tile is written back to the preset channel.

[0091] Step S180: Read the movement path within the target block in the preset channel, and obtain the target movement path corresponding to the pathfinding request based on the movement path between the target blocks.

[0092] That is, in addition to dividing the game map into multiple map blocks, this embodiment of the invention will also determine the inter-block movement path between two connected map blocks. Then, when the moving target needs to pass through two or more map blocks, the computer device will determine the target inter-block movement path of the moving target based on the inter-block movement path.

[0093] Furthermore, since the starting and ending map tiles are not the same, the moving target must pass through at least two different map tiles during its journey from the starting position to the ending position. Simultaneously, because different map tiles correspond to different game scenes, and the starting and ending points of the moving target are also different across different map tiles, this embodiment of the invention will generate / determine the corresponding intra-tile movement path for each map tile the moving target passes through.

[0094] That is, for each target map tile, the grid nodes of the target map tile are mapped one-to-one with the processor module, and the processor module is controlled to determine the movement path of the moving target within the target tile according to the preset algorithm.

[0095] Once the movement path within any target map tile is determined, or once the movement paths within all target map tiles are determined, the processor module writes the determined movement path within the target tile back to the preset channel, so that the central processing unit can access the preset channel to determine the movement path of the moving target.

[0096] Optionally, in one feasible embodiment of the present invention, the central processing unit determines the inter-block movement path based on the A* algorithm; that is, step S160 specifically includes:

[0097] If the starting map tile and the ending map tile are not the same, then all target map tiles corresponding to the pathfinding request are determined based on the A* algorithm, and the inter-target movement paths corresponding to all target map tiles are determined.

[0098] It is understandable that the A* algorithm is the most efficient direct search method for finding the shortest path in a static road network. Therefore, in order to ensure the effectiveness of the pathfinding mechanism / function, this embodiment of the invention uses the A* algorithm to determine the movement path between target blocks.

[0099] That is, the central processing unit will determine the map tiles / target map tiles that the moving target needs to pass through according to the A* algorithm; at the same time, since the embodiments of the present invention predetermine the inter-tile movement path between two connected map tiles, after determining the target map tile, the central processing unit obtains the target inter-tile movement path corresponding to all target map tiles by reading the predetermined inter-tile movement path.

[0100] Optionally, in one feasible embodiment of the present invention, please refer to... Figure 3 The diagram illustrates a third pathfinding method in a game provided by an embodiment of the present invention. In this feasible method, the grid nodes include obstacle grid nodes and non-obstacle grid nodes.

[0101] Therefore, in this feasible embodiment of the present invention, step S140 specifically includes:

[0102] S141, if the starting map tile is the same as the ending map tile, then the processor module is mapped one-to-one with the grid nodes of the starting map tile;

[0103] S142, using the starting position and the ending position, determine the starting grid node and the ending grid node in the starting map block respectively;

[0104] S143, for each non-obstacle grid node in the starting map block other than the starting grid node and the scanned node, the processor module corresponding to the non-obstacle grid node repeatedly executes the preset steps at a preset cycle until the termination grid node is set as the scanned node. Then, the preset path set corresponding to the termination grid node is used to determine the movement path within the target block, and the movement path within the target block is written back to the preset channel.

[0105] The preset steps include:

[0106] Based on a preset period, detect whether there is a starting grid node or a scanned node within a preset range;

[0107] If a starting cell node exists, the direction from the starting cell node to the non-obstacle cell node is recorded in the preset path set of the non-obstacle cell node;

[0108] If there are scanned nodes, then according to the preset path set of the scanned nodes, the target node with the smallest distance between the starting grid node and the non-obstacle grid node among all the scanned nodes is selected, and the direction of the target node pointing to the non-obstacle grid node and the information in the preset path set of the target node are recorded in the preset path set of the non-obstacle grid node.

[0109] Set the non-obstacle grid node as a scanned node.

[0110] Understandably, if the game scene is two-dimensional, the preset range of a grid node represents the area formed by the eight nearest grid nodes in eight directions: up, down, left, right, up-left, up-right, down-left, and down-right. If the game scene is three-dimensional, the preset range of a grid node represents a cube centered on itself, containing 26 nearest grid nodes in different directions.

[0111] Furthermore, in this embodiment of the invention, if the game character controlled by the player can only move in a two-dimensional plane, then in the first loop, all non-obstacle grid nodes in the eight directions surrounding the starting grid node will be scanned to the starting grid node.

[0112] The processor module corresponding to the non-obstacle cell node will record the direction from which the starting cell node points to itself. For example, the cell node to the right of the starting cell node will be recorded as {'right'}. At the same time, this non-obstacle cell node will be transformed into a scanned node.

[0113] In the second loop, all non-obstruction grid nodes in the eight directions surrounding the starting grid node will be transformed into scanned nodes. Let lattice1 be the non-obstruction grid node to the right of the starting grid node in the first loop, and lattice2 be the non-obstruction grid node adjacent to the right of lattice1. Then, in the second loop, the nodes above and below lattice1 will be scanned nodes, while the nodes to the right, upper right, and lower right of lattice1 will not be scanned nodes.

[0114] Furthermore, lattice2 will detect 3 scanned nodes. However, based on the preset path set of the scanned nodes above and below lattice1, and assuming that the distance between two connected grid nodes is 5 when they are in the same column or row, and 7 when they are diagonally opposite, it can be known that the distance from the starting grid node, through these two scanned nodes, to lattice2 is 12. The distance formed by the starting grid node - lattice1 - lattice2 is 10. Therefore, the preset path set of lattice2 will record the content of {'right', 'right'}.

[0115] Based on this loop, when the final terminating cell node is set as a scanned node, the present invention will determine the movement path within the target block according to the preset path set of the terminating cell nodes that have been transformed into scanned nodes.

[0116] Furthermore, it is understandable that if the starting map tile and the ending map tile are not the same, that is, if there are two or more target map tiles, the computer device needs to determine the starting point and ending point of the target map tile based on the starting grid node and the inter-tile movement path.

[0117] As an example, let the movement path between target blocks be the first map block - the second map block - the third map block, where the first map block is the starting map block and the third map block is the ending map block. The non-obstruction grid node lattice3 of the first map block and the non-obstruction grid node lattice4 of the second map block constitute the movement path between the first map block and the second map block, i.e., lattice3-lattice4; the non-obstruction grid node lattice5 of the second map block and the non-obstruction grid node lattice6 of the third map block constitute the movement path between the second map block and the third map block, i.e., lattice5-lattice6.

[0118] Based on this, the starting point of the first map tile is the starting grid node corresponding to the starting position, and the ending point is lattice3; in the second map tile, the starting point is lattice4, and the ending point is lattice5; in the third map tile, the starting point is lattice6, and the ending point is the ending grid node corresponding to the ending position.

[0119] It is conceivable that the starting and ending points in different map tiles determine the specific execution process of the pathfinding algorithm in different map tiles.

[0120] Optionally, to further optimize the pathfinding results and improve the gaming experience for players / users, in one feasible embodiment of the present invention, the preset steps further include:

[0121] If the number of directions recorded in the preset path set of the scanned node exceeds a preset number, then the scanned node is set as an unwalkable node.

[0122] It is understandable that if the preset path set of the scanned node records multiple directions, then according to the records of the preset path set of this scanned node, it is necessary to pass through multiple grid nodes. That is, if the moving target needs to pass through this scanned node, the movement path within the block is long and the movement efficiency is low.

[0123] Therefore, to avoid low-quality pathfinding results due to long intra-block movement paths, this embodiment of the invention checks the number of directions recorded in the preset path set of the scanned node to determine whether the preset path set of the scanned node has recorded directions multiple times. If so, the scanned node is set as an unwalkable node, and in subsequent loops, non-obstacle grid nodes will ignore unwalkable nodes.

[0124] In one example, each processor module implements a preset path set based on a 64-bit unsigned integer (uint). Each 3 bits of this unsigned integer can represent 8 numbers from 0 to 7, corresponding to 8 directions; thus, this unsigned integer can record 21 directions. Therefore, in this example, if any processor module needs to record more than 21 directions, the path is considered infeasible, and the corresponding non-obstacle grid node is marked as an unwalkable node.

[0125] Example 2

[0126] Corresponding to the pathfinding method in the game provided in Embodiment 1 of the present invention, Embodiment 2 of the present invention also provides a pathfinding device in the game, referring to... Figure 4 The diagram illustrates the structure of a pathfinding device in a game according to an embodiment of the present invention. The pathfinding device 200 provided in this embodiment is applied to a computer device, which includes a central processing unit and a field-programmable gate array (FPGA). The device includes:

[0127] The partitioning module 210 is used to divide the game map into multiple map blocks, wherein the map blocks include a preset number of grid nodes;

[0128] Generation module 220 is used to generate the preset number of processor modules using the field-programmable gate array based on high-level synthesis tools;

[0129] The response module 230 is used to respond to a pathfinding request, obtain the starting position and ending position of the moving target corresponding to the pathfinding request, and determine the starting map tile to which the starting position belongs and the ending map tile to which the ending position belongs.

[0130] The write-back module 240 is used to, if the starting map block and the ending map block are the same, correspond the processor module to the grid nodes of the starting map block one by one, use the processor module to determine the movement path within the target block based on a preset algorithm, and write back the movement path within the target block to a preset channel, wherein the preset channel includes a high-speed serial computer expansion bus standard channel.

[0131] The reading module 250 is used to read the movement path within the target block in the preset channel to obtain the target movement path corresponding to the pathfinding request.

[0132] Optionally, in one feasible embodiment of the present invention, the partitioning module is further configured to divide the game map into multiple map blocks, and determine the inter-block movement path between two connected map blocks based on the adjacency relationship of each map block;

[0133] The device further includes:

[0134] The determination module is used to determine all target map tiles corresponding to the pathfinding request and determine the inter-target movement paths corresponding to all target map tiles if the starting map tile and the ending map tile are inconsistent.

[0135] The path write-back module is used to map each target map tile to a grid node of the target map tile, and to use the corresponding processor module to determine the movement path within the target tile based on a preset algorithm, and to write the movement path within the target tile back to the preset channel.

[0136] The path determination module is used to read the movement path within the target block in the preset channel, and obtain the target movement path corresponding to the pathfinding request based on the movement path between the target blocks.

[0137] Optionally, in one feasible embodiment of the present invention, the determining module is further configured to determine all target map blocks corresponding to the pathfinding request based on the A* algorithm if the starting map block and the ending map block are inconsistent, and to determine the inter-target block movement path corresponding to all target map blocks.

[0138] Optionally, in one feasible embodiment of the present invention, the grid node includes obstacle grid nodes and non-obstacle grid nodes;

[0139] The write-back module includes:

[0140] The corresponding submodule is used to map the processor module to the grid nodes of the starting map block one by one if the starting map block and the ending map block are the same.

[0141] The node determination submodule is used to determine the starting grid node and the ending grid node in the starting map block using the starting position and the ending position, respectively.

[0142] The loop submodule is used to repeatedly execute preset steps at a preset cycle for each non-obstacle grid node in the starting map block, excluding the starting grid node and the scanned node, until the ending grid node is set as the scanned node. Then, the preset path set corresponding to the ending grid node is used to determine the movement path within the target block, and the movement path within the target block is written back to the preset channel.

[0143] The preset steps include:

[0144] Based on a preset period, detect whether there is a starting grid node or a scanned node within a preset range;

[0145] If a starting cell node exists, the direction from the starting cell node to the non-obstacle cell node is recorded in the preset path set of the non-obstacle cell node;

[0146] If there are scanned nodes, then according to the preset path set of the scanned nodes, the target node with the smallest distance between the starting grid node and the non-obstacle grid node among all the scanned nodes is selected, and the direction of the target node pointing to the non-obstacle grid node and the information in the preset path set of the target node are recorded in the preset path set of the non-obstacle grid node.

[0147] Set the non-obstacle grid node as a scanned node.

[0148] Optionally, in one feasible embodiment of the present invention, the preset step further includes:

[0149] If the number of directions recorded in the preset path set of the scanned node exceeds a preset number, then the scanned node is set as an unwalkable node.

[0150] The pathfinding device 200 in the game provided in this application embodiment can realize each process of the pathfinding method in the game corresponding to Embodiment 1, and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0151] This invention also provides a computer device, including a memory and a processor. The memory stores a computer program, and the computer program executes a pathfinding method in a game as described in Embodiment 1 when it runs on the processor.

[0152] This invention also provides a computer-readable storage medium storing a computer program, which executes a pathfinding method in a game as described in Embodiment 1 when run on a processor.

[0153] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that, as an alternative implementation, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

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

[0155] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a smartphone, personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0156] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.

Claims

1. A pathfinding method in a game, characterized by, The method is applied to a computer device including a central processing unit and a field programmable logic gate array, and comprises the following steps: dividing a game map into a plurality of map blocks, wherein the map blocks include a preset number of grid nodes; generating the preset number of processor modules by using the field programmable logic gate array based on a high-level synthesis tool; in response to a pathfinding request, obtaining a start position and an end position of a moving target corresponding to the pathfinding request, and determining a start map block to which the start position belongs and an end map block to which the end position belongs; if the start map block is consistent with the end map block, one-to-one correspondence between the processor modules and the grid nodes of the start map block is established, a target intra-block moving path is determined by using the processor modules based on a preset algorithm, and the target intra-block moving path is written back to a preset channel, wherein the preset channel includes a high-speed serial computer expansion bus standard channel; reading the target intra-block moving path in the preset channel to obtain a target moving path corresponding to the pathfinding request.

2. The pathfinding method in a game according to claim 1, wherein, The method further comprises the following steps: dividing a game map into a plurality of map blocks, and determining an inter-block moving path of two connected map blocks based on an adjacency relationship of each map block; after the step of, in response to a pathfinding request, obtaining a start position and an end position of a moving target corresponding to the pathfinding request, and determining a start map block to which the start position belongs and an end map block to which the end position belongs, the method further comprises the following steps: if the start map block is inconsistent with the end map block, determining all target map blocks corresponding to the pathfinding request, and determining a target inter-block moving path corresponding to all target map blocks; for each target map block, one-to-one correspondence between the processor modules and the grid nodes of the target map block is established, a target intra-block moving path is determined by using the corresponding processor modules based on a preset algorithm, and the target intra-block moving path is written back to the preset channel; reading the target intra-block moving path in the preset channel, and obtaining a target moving path corresponding to the pathfinding request according to the target inter-block moving path.

3. The pathfinding method in a game according to claim 2, wherein, if the start map block is inconsistent with the end map block, all target map blocks corresponding to the pathfinding request are determined based on an A-star algorithm, and a target inter-block moving path corresponding to all target map blocks is determined. the grid nodes include obstacle grid nodes and non-obstacle grid nodes; 4. The pathfinding method in a game according to claim 1, wherein, if the start map block is consistent with the end map block, one-to-one correspondence between the processor modules and the grid nodes of the start map block is established, a target intra-block moving path is determined by using the processor modules based on a preset algorithm, and the target intra-block moving path is written back to a preset channel, wherein the preset channel includes a high-speed serial computer expansion bus standard channel; reading the target intra-block moving path in the preset channel to obtain a target moving path corresponding to the pathfinding request. ​ determine a start grid node and a terminal grid node in the start map block respectively by using the start position and the end position; for each non-obstacle grid node in the start map block except the start grid node and the scanned node, a preset step is repeatedly executed by a processor module corresponding to the non-obstacle grid node at a preset period until the terminal grid node is set as a scanned node, a target intra-block moving path is determined by using a preset path set corresponding to the terminal grid node, and the target intra-block moving path is written back to a preset channel; the preset step comprises: detecting whether there is a start grid node or a scanned node in a preset range based on a preset period; if there is a start grid node, a direction of the start grid node pointing to the non-obstacle grid node is recorded in a preset path set of the non-obstacle grid node; if there is a scanned node, a target node with the smallest distance between the start grid node and the non-obstacle grid node is determined from all the scanned nodes according to the preset path set of the scanned node, and information of a direction of the target node pointing to the non-obstacle grid node and a preset path set of the target node is recorded in the preset path set of the non-obstacle grid node; the non-obstacle grid node is set as a scanned node.

5. The pathfinding method in a game according to claim 4, wherein, the preset step further comprises: if the number of directions recorded in the preset path set of the scanned node exceeds a preset number, the scanned node is set as an un-walkable node.

6. A pathfinding device in a game, characterized by applied to a computer device, the computer device comprising a central processing unit and a field programmable logic gate array, the device comprising: a division module configured to divide a game map into a plurality of map blocks, wherein the map blocks comprise a preset number of grid nodes; a generation module configured to generate the preset number of processor modules by using the field programmable logic gate array based on a high-level synthesis tool; a response module configured to, in response to a pathfinding request, acquire a start position and an end position of a moving target corresponding to the pathfinding request, and determine a start map block to which the start position belongs and an end map block to which the end position belongs; a write-back module configured to, if the start map block is consistent with the end map block, one-to-one correspond the processor modules to the grid nodes of the start map block, determine a target intra-block moving path based on a preset algorithm by using the processor modules, and write the target intra-block moving path back to a preset channel, wherein the preset channel comprises a high-speed serial computer expansion bus standard channel; a reading module configured to read the target intra-block moving path in the preset channel to obtain a target moving path corresponding to the pathfinding request.

7. The routing device in a game according to claim 6, wherein, the division module is further configured to divide the game map into a plurality of map blocks, and determine an inter-block moving path between two connected map blocks based on an adjacency relationship of each of the map blocks; the device further comprises: a determination module configured to, if the start map block is not consistent with the end map block, determine all target map blocks corresponding to the pathfinding request, and determine target inter-block moving paths corresponding to all the target map blocks. a path backwriting module, configured to correspond each of the processor modules to a grid node of each of the target map blocks, and determine a target intra-block moving path based on a preset algorithm by using the corresponding processor module, and backwrite the target intra-block moving path to the preset channel; a path determining module, configured to read the target intra-block moving path in the preset channel, and obtain a target moving path corresponding to the pathfinding request according to the target inter-block moving path.

8. The routing device in a game according to claim 7, wherein, The determining module is further configured to determine all target map blocks corresponding to the pathfinding request based on the A-star algorithm if the start map block is inconsistent with the end map block, and determine target inter-block moving paths corresponding to the all target map blocks.

9. A computer device, comprising: A computer readable storage medium, having a computer program stored thereon, which, when executed on a processor, performs the pathfinding method in a game according to any one of claims 1-5.

10. A computer-readable storage medium, characterized in that, A computer readable storage medium, having a computer program stored thereon, which, when executed on a processor, performs the pathfinding method in a game according to any one of claims 1-5.

Citation Information

Patent Citations

  • Method for supporting quantities of units in games to find ways simultaneously

    CN109568959A

  • Path planning method and system in 2D game and electronic equipment

    CN111202985A