A pathfinding method and device based on navigation grid

By adopting a navigation grid-based pathfinding method in the game, the movement speed and congestion index of non-player characters on each path are calculated, and the problem of the existing technology that the pathfinding algorithm has large demand for computing resources and cannot effectively consider dynamic characters is solved, achieving more efficient and accurate path planning, reducing game screen lag.

CN118976248BActive Publication Date: 2025-04-04WUHU DOUZHAOWAN NETWORK TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411034890.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2025-04-04
Estimated Expiration
2044-07-31

AI Technical Summary

Technical Problem

Existing pathfinding algorithms, such as the A-star algorithm, require a lot of computing resources in multiplayer online games, resulting in the inability to effectively consider the real-time situation of dynamic characters on the map, which can easily lead to the characters entering crowded paths and causing the game screen to stutter.

Method used

The pathfinding method based on navigation grid is adopted. By obtaining the game map and generating the navigation grid, traversing the navigation grid to obtain multiple paths of the target character, calculating the movement speed of non-player characters on each path and calculating the congestion index, and sorting each path based on the path length and congestion index to obtain the optimal path.

Benefits of technology

It effectively avoids the short but crowded paths sent to the target character, reduces the situation of stuttering in the game screen, and ensures the calculation accuracy of the congestion index, and avoids real players from affecting the universality of the pathfinding algorithm by blocking bugs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118976248B_ABST
    Figure CN118976248B_ABST
Patent Text Reader

Abstract

The present application belongs to the field of computer technology, and discloses a navigation grid-based pathfinding method and device, the method comprising: obtaining a game map, generating a navigation grid on the game map; determining the current position and target position of a target character in response to a pathfinding instruction; traversing the navigation grid to obtain multiple paths from the current position to the target position; obtaining the moving speed of each non-player character on each path; calculating the congestion index of each path according to the moving speed of each non-player character; sorting each path based on the path length and the congestion index to obtain the optimal path. The present application can avoid the situation where the target character is sent into a short but crowded path, encountering multiple character models and causing the game to freeze.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a navigation grid-based pathfinding method and device. Background Art

[0002] Map pathfinding in 3D games, often referred to as pathfinding or navigation, refers to the process of automatically or semi-automatically calculating a feasible path from the starting point to the end point in the game. This is crucial for the AI ​​of NPCs (non-player characters), the automatic navigation of player characters, and the interactivity of the game world. Among the existing pathfinding algorithms, the A-star algorithm is the most commonly used, which estimates the distance from the current node to the target node by using a heuristic function.

[0003] However, the A-star algorithm has a huge demand for computing resources, which means that in multiplayer online games, the A-star algorithm will not pay attention to other variables except the fixed environment of the map. For example, a path node is narrow and crowded with multiple player models. Therefore, the existing path-finding algorithm pays less attention to the real-time situation of each dynamic character on the map. The path-finding result can easily cause the character to enter a path that already has multiple character models, and each dynamic character must be rendered in real time, causing the game screen to freeze. Summary of the invention

[0004] The present application provides a navigation grid-based pathfinding method and device, which can prevent a target character from being sent into a short but crowded path, encountering multiple character models and causing game lag.

[0005] In a first aspect, an embodiment of the present application provides a navigation grid-based pathfinding method, including:

[0006] Get the game map and generate a navigation mesh on the game map;

[0007] In response to the pathfinding instruction, determining a current position and a target position of the target character;

[0008] Traverse the navigation grid to obtain multiple paths from the current location to the target location;

[0009] Get the movement speed of each non-player character on each path;

[0010] Calculate the congestion index of each path according to the moving speed of each non-player character;

[0011] The paths are sorted based on path length and congestion index to obtain the optimal path.

[0012] Furthermore, the method also includes:

[0013] Before generating the navigation mesh, remove the scene models whose model attributes are obstacle attributes.

[0014] Furthermore, the above-mentioned obtaining of the game map and generating a navigation grid on the game map includes:

[0015] Use quadtree or Voronoi diagram algorithm to generate navigation mesh on the game map.

[0016] Furthermore, the above traversal in the navigation grid obtains multiple paths from the current position to the target position, including:

[0017] The Dijkstra algorithm or breadth-first search algorithm is used to obtain each path in the navigation grid.

[0018] Furthermore, the above-mentioned calculation of the congestion index of each path according to the moving speed of each non-player character includes:

[0019] Get the free flow speed corresponding to each non-player character on the path;

[0020] Calculate the latency of non-player characters based on their free flow speed and movement speed;

[0021] The congestion index is obtained according to the delay speed of each non-player character on the path.

[0022] Furthermore, the congestion index is obtained according to the delay speed of each non-player character on the path, including:

[0023] Remove the maximum and minimum values ​​of each delay speed;

[0024] The average of the remaining delay speeds is calculated and used as the congestion index.

[0025] Furthermore, the above-mentioned sorting of the paths based on the path length and the congestion index to obtain the optimal path includes:

[0026] Get the free flow speed of the target character on the path;

[0027] Add the free flow speed and the congestion index to get the target speed;

[0028] Divide the path length of the path by the target speed to get the moving time;

[0029] The path corresponding to the shortest moving time is selected as the optimal path.

[0030] Furthermore, the method also includes:

[0031] Get the number of corners of each path and normalize the duration of each move;

[0032] Multiply the number of corners by the preset corner weight to obtain the corner weight of each path;

[0033] Multiply the travel time by the preset time weight to get the time weight of each path;

[0034] Add the corner weight and duration weight to get the congestion weight of each path;

[0035] The path corresponding to the smallest congestion weight is selected as the optimal path.

[0036] Furthermore, the method also includes:

[0037] If the pathfinding instruction includes the target duration, and there are multiple target characters with the same current position and target position, remove the paths with a moving time greater than or equal to the target duration;

[0038] Divide the path length of each path by the target duration to obtain the lower limit speed of each path;

[0039] Subtract the target speed from the lower speed limit to obtain the congestion margin of each path;

[0040] The role margin of each path is obtained based on the congestion margin;

[0041] Each role is assigned to each path according to the role surplus.

[0042] Furthermore, the above-mentioned obtaining of the role margin of each path based on the congestion margin includes:

[0043] The historical congestion index of each path and the corresponding historical number of roles are used to train the machine learning model;

[0044] Add the congestion margin and the congestion index to obtain the congestion upper limit value of each path;

[0045] Input the congestion limit value into the trained machine learning model to obtain the upper limit of the number of roles;

[0046] Subtract the current number of characters in the path from the upper limit of the number of characters to get the remaining number of characters.

[0047] Furthermore, the preset angle weight is 0.2, and the preset duration weight is 0.8.

[0048] Furthermore, the method also includes:

[0049] When the pathfinding instruction includes multiple target characters, obtain the rendering batch and the corresponding index information;

[0050] Read attribute information corresponding to the rendering batch in the first buffer of the GPU according to the index information;

[0051] Apply the attribute information to each particle in the rendering batch to obtain primitives;

[0052] Read the instantiation times and transformation matrix in the second buffer of the GPU according to the index information;

[0053] Transform and adjust the instance corresponding to the primitive according to the instantiation times and the transformation matrix;

[0054] Each pixel of the primitive is illuminated and mapped to obtain a rendered image.

[0055] Furthermore, the method also includes:

[0056] Get multiple particles through 3DS files, and treat particles with the same material as a rendering batch;

[0057] The attribute information of each particle is put into the first buffer, and the corresponding index information is generated.

[0058] Further, the first buffer is a vertex buffer or an index buffer;

[0059] The second buffer is a constant buffer or a uniform buffer.

[0060] In a second aspect, an embodiment of the present application provides a navigation grid-based pathfinding device, comprising:

[0061] A generation module is used to obtain a game map and generate a navigation grid on the game map;

[0062] A location module, for determining a current location and a target location of a target character in response to a pathfinding instruction;

[0063] The traversal module is used to traverse the navigation grid and obtain multiple paths from the current location to the target location;

[0064] An acquisition module, used to obtain the moving speed of each non-player character on each path;

[0065] A calculation module, used for calculating the congestion index of each path according to the moving speed of each non-player character;

[0066] The determination module is used to sort the paths based on the path length and the congestion index to obtain the optimal path.

[0067] Furthermore, the device also includes:

[0068] The obstacle module is used to remove scene models whose model attributes are obstacle attributes before generating the navigation mesh.

[0069] Furthermore, the generation module is used to generate a navigation mesh on the game map using a quadtree or Voronoi diagram algorithm.

[0070] Furthermore, the traversal module is used to obtain each path in the navigation grid by using the Dijkstra algorithm or the breadth-first search algorithm.

[0071] In a third aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of a navigation grid-based pathfinding method as in any of the above embodiments are performed.

[0072] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a navigation grid-based pathfinding method as in any of the above embodiments.

[0073] In summary, compared with the prior art, the technical solution provided in the embodiment of the present application has at least the following beneficial effects:

[0074] The embodiment of the present application provides a navigation grid-based pathfinding method. After obtaining multiple paths from the current position of the target character to the target position based on the navigation grid, the congestion index of each path is calculated based on the non-player characters on each path, and finally the optimal path is determined based on the path length and the congestion index. The above method adds the calculation and consideration of the congestion index after pathfinding, which can avoid the situation where the target character is sent to a short but crowded path and encounters multiple character models, causing the game to freeze; in addition, the congestion index is calculated based on the non-player characters on the path that move according to a fixed program, which can ensure the accuracy of the calculation of the congestion index and avoid real players affecting the universality of the pathfinding algorithm by bugs. BRIEF DESCRIPTION OF THE DRAWINGS

[0075] Figure 1 A flowchart of a navigation grid-based pathfinding method is provided for an exemplary embodiment of the present application.

[0076] Figure 2 A flowchart of the congestion index calculation steps provided for an exemplary embodiment of the present application.

[0077] Figure 3 A flowchart of the optimal path determination steps provided for an exemplary embodiment of the present application.

[0078] Figure 4 A flowchart of the optimal path determination step provided for yet another exemplary embodiment of the present application.

[0079] Figure 5 A flowchart of the path allocation steps under multiple target roles provided for an exemplary embodiment of the present application.

[0080] Figure 6 A flowchart of the steps of calculating the role margin is provided for an exemplary embodiment of the present application.

[0081] Figure 7 A flowchart of rendering batch processing steps provided for an exemplary embodiment of the present application.

[0082] Figure 8 A structural diagram of a navigation grid-based pathfinding device provided as an exemplary embodiment of the present application.

[0083] Fig. 9 A structural diagram of a computing module 105 provided for an exemplary embodiment of the present application.

[0084] Fig.10 A structural diagram of the determination module 106 provided for an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0085] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0086] Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative work shall fall within the scope of protection of this application.

[0087] Terminology explanation:

[0088] 1) Navigation Mesh: A navigation mesh (NavMesh for short) is a polygonal mesh that covers the walkable or movable surfaces in the game world. Navigation meshes are usually automatically generated by terrain, buildings, and other walkable surfaces, or manually created by designers. The polygons in the mesh must be connected to ensure that the path finding algorithm can work effectively on the mesh. In complex scenes, the navigation mesh may have multiple levels, such as a ground layer, a second floor platform, and so on. In some cases, the navigation mesh needs to be updated dynamically to respond to environmental changes, such as the movement or disappearance of obstacles. Each polygon of the navigation mesh may have different properties, such as cost, height limit, or specific type of access rights. The navigation mesh can be integrated with other systems in the game engine (such as AI, physics engine) to achieve more complex behaviors.

[0089] 2) Primitives: They are the basic shape units that make up 3D models. In the rendering process, primitives are the smallest units processed by the GPU. Common types of primitives include: Point: The simplest primitive, with no area or volume. Line: A straight line segment defined by two vertices. Triangle: A polygon defined by three vertices, which is the basic unit that makes up a complex 3D model. Quad: A polygon defined by four vertices, usually used to render planes or curved surfaces. Polygon: A closed figure defined by more than four vertices. Primitives are converted into pixels in the rendering pipeline to form the final image.

[0090] 3) Instances: Instancing is a technique that allows developers to create multiple copies of objects with the same geometry and material in a scene, but each copy can have its own transformation (position, rotation, scale). Advantages of instancing: Improve rendering efficiency by reducing the number of vertices and primitives processed by the GPU. Instances share the same geometric data, reducing memory usage. Managing a small number of object templates is simpler than managing a large number of independent objects. Application scenarios of instancing include: Particle systems, which are used to create a large number of particles with similar appearance. Environmental objects, such as trees, grass, etc., can quickly generate a large number of similar objects through instancing. Object pools, which are used to manage the creation and destruction of objects such as enemies and bullets in the game. In actual applications, primitives are the basis of rendering, and instancing is an optimization technique for efficiently rendering a large number of similar objects. By combining primitives and instancing, developers can create rich and diverse visual effects while maintaining high performance.

[0091] See also Figure 1 , the embodiment of the present application provides a pathfinding method based on a navigation grid, which may specifically include:

[0092] Step S11, obtaining a game map, and generating a navigation grid on the game map.

[0093] Among them, the game map can be a map of a 3D game, and the game map data includes information such as different levels and areas, images of the 3D model surface, height maps, slopes, materials, etc. of the terrain.

[0094] Specifically, this application uses navigation grid pathfinding, which has the advantages of high efficiency, accuracy and flexibility compared to traditional pathfinding methods. It significantly reduces memory and computing overhead by abstracting the game environment into a navigation grid, while being able to accurately express complex scenes of 3D maps. In addition, the navigation grid is easy to implement and dynamically modify, and is suitable for large and complex game environments.

[0095] When dynamic modification is used here, it refers to dynamic update. When the game is running, the navigation mesh can be dynamically updated to adapt to changes in the environment. For example, when a character in the game destroys a wall or opens a door, the navigation mesh can be automatically updated to reflect these changes, ensuring that the character can correctly find the new path.

[0096] When the navigation grid is used for pathfinding, the optimal path is mainly determined based on the structure and layout of the navigation grid. The navigation grid consists of a series of walkable nodes and edges connecting these nodes. These edges represent the paths that the target character can move. By traversing the navigation grid, the target character can choose to move along the edge of the grid and find a relatively direct and efficient path to reach the target point. This pathfinding method is simple and efficient and is suitable for various scenarios.

[0097] Step S12, in response to the path-finding instruction, determining the current position and the target position of the target character.

[0098] Among them, the pathfinding instructions are input into the computer by the user who controls the target character, and can specifically include keyboard input, mouse input, game controller, touch screen, voice recognition, somatosensory control, eye tracking, brain-computer interface, physical controller, VR controller and other methods to input pathfinding instructions. Keyboard input is to receive the player's instructions through various keys and key combinations on the keyboard. Mouse input is to receive instructions by moving, clicking and dragging the mouse. The left and right clicks of the mouse are often used for selection, attack or interaction. The game controller uses the buttons, joysticks and triggers on the handle to receive the player's operation instructions. The touch screen receives the player's instructions through gestures such as touch, slide, and long press on a mobile device or touch screen display. Voice recognition is to use voice recognition technology to control the game character or perform specific operations through the player's voice commands. Somatosensory control is to use somatosensory devices such as Kinect or VR helmets to control the game through the player's body movements and postures. Eye tracking is to use eye tracking technology to select targets or perform operations through the player's line of sight. Brain-computer interface uses brain wave signals to use the player's thinking and intentions to control the game character or game process. Physical controllers use specialized physical controllers, such as steering wheels and flight sticks, to simulate real driving or flying operations. Virtual reality (VR) controllers use VR helmets and handles in VR games, receiving player commands through buttons, touchpads, and motion sensors on the handles.

[0099] Step S13, traverse the navigation grid to obtain multiple paths from the current position to the target position.

[0100] Step S14, obtaining the moving speed of each non-player character on each path.

[0101] Among them, non-player characters are NPC characters; different NPC characters will have different movement speeds according to the plot settings or character settings; specifically, the movement speed of NPC characters is usually the basic movement speed defined in the script or character configuration file. In many game engines, such as Unity or Unreal Engine, the movement speed of NPCs can also be set through the component system. If the movement of NPCs is achieved through animation, the movement speed can be obtained from the playback speed of the animation. In this case, the speed may be related to the animation frame rate and the distance covered by the character in the animation. If the movement of NPCs is controlled by the physics engine, the movement speed can be obtained through the linear speed attribute of the Rigidbody component in the physics engine.

[0102] In some cases, the NPC's movement speed may be affected by external factors, such as terrain type, weight status, or special game events, which can exist as variables in the script.

[0103] Step S15, calculating the congestion index of each path according to the moving speed of each non-player character.

[0104] Specifically, the reason why the present application uses the movement speed of non-player characters to calculate the congestion index is that the movement speed of player characters is difficult to reflect the degree of congestion of the path. The movement speed of real player characters is not only related to the network speed of the terminal used by the corresponding player, but in the actual game experience, game planners may also provide different movement speeds for different types of real players, such as different types of mounts, light skills, etc.; not only that, real players will also take advantage of bugs in the game map modeling to perform operations such as penetrating the model, so it is not reliable to use the movement speed of real players to judge the congestion index.

[0105] Step S16, sorting the paths based on the path length and the congestion index to obtain the optimal path.

[0106] The above embodiment provides a navigation grid-based pathfinding method. After obtaining multiple paths from the current position of the target character to the target position based on the navigation grid, the congestion index of each path is calculated based on the non-player characters on each path, and finally the optimal path is determined based on the path length and the congestion index. The above method adds the calculation and consideration of the congestion index after pathfinding, which can avoid the situation where the target character is sent into a short but crowded path and encounters multiple character models, causing the game to freeze; in addition, the congestion index is calculated based on the non-player characters on the path that move according to a fixed program, which can ensure the accuracy of the calculation of the congestion index and avoid real players affecting the universality of the pathfinding algorithm by bugs.

[0107] In some embodiments, the method further comprises:

[0108] Step S10: before generating the navigation mesh, remove the scene models whose model attributes are obstacle attributes.

[0109] Specifically, the process of judging the walkable area may include: using the height data of the model to determine which areas have a reasonable slope and are suitable for the character to walk; using the collision detection system to identify which areas are physical obstacles, thereby excluding non-walkable areas. Check the physical properties of the object, such as whether it is marked as "walkable (Navigation Static)" or "obstacle", and judge the walkable area accordingly; in the game editor, use labels or hierarchical systems to distinguish different types of ground and objects, such as grass, roads, buildings, etc.; set maximum slope and height limits to exclude areas that are too steep or have too large height differences. Use accessibility analysis tools to determine which areas can be reached from specific points, usually based on ray casting or similar geometric algorithms; use space segmentation data structures, such as octrees or Voronoi diagrams, to quickly query and analyze walkable areas.

[0110] The above-mentioned embodiment eliminates scene models belonging to obstacles before generating the navigation mesh, so that the algorithm of the present application can be applied to various types of 3D game maps, thereby improving the applicability of the present application.

[0111] In some embodiments, the obtaining of the game map and generating a navigation grid on the game map include:

[0112] Use quadtree or Voronoi diagram algorithm to generate navigation mesh on the game map.

[0113] Specifically, there are many algorithms for creating navigation grids, including quadtrees and Voronoi diagrams, waypoints, grids, Floyd-Warshall algorithms, and recast algorithms. However, the waypoint algorithm requires manual participation and has great limitations. The grid algorithm has high memory and computer overhead, and the larger the map, the more grids are divided. The Floyd-Warshall algorithm and the recast algorithm also require a lot of computation and are not suitable for large-scale maps.

[0114] Considering that pathfinding algorithms are usually used in open world or multiplayer online games, the map data to be processed is usually relatively large, so computational complexity and efficiency are the primary considerations for pathfinding algorithms.

[0115] The quadtree algorithm used in this application provides an efficient way to recursively partition continuous space. The quadtree allows the location of game objects (such as NPCs) in the game world to be quickly determined, and nearby areas to be quickly accessed. It can also dynamically adapt to changes in the game world, for example, when new objects are added to the scene or existing objects are moved. In the process of generating a navigation grid, the quadtree can be used to reduce the number of areas that need to be considered, focusing only on areas related to navigation, thereby reducing the amount of calculation. For large-scale game maps, the quadtree can effectively organize and process large amounts of spatial data;

[0116] The Voronoi diagram algorithm defines the walkable area through its naturally formed boundaries, which can naturally adapt to complex terrain and obstacle layouts, providing more accurate terrain adaptability for the navigation grid. Secondly, the navigation grid generated using the Voronoi diagram can optimize the path, reduce unnecessary detours, and improve path efficiency.

[0117] In some embodiments, the above-mentioned traversal in the navigation grid to obtain multiple paths from the current position to the target position includes:

[0118] The Dijkstra algorithm or breadth-first search algorithm is used to obtain each path in the navigation grid.

[0119] In addition to the two algorithms mentioned above, there are also some algorithms for calculating paths, such as the Floyd algorithm and the depth-first search algorithm. However, the Floyd algorithm has a high time complexity and is not suitable for calculating large amounts of data. It also requires an adjacency matrix to store edges, which takes up a lot of storage space. This is obviously not suitable for 3D games where map model resources take up a lot of storage space. The depth-first search may fall into an infinite loop and is not suitable for weighted graphs.

[0120] The Dijkstra algorithm adopted in this application can be applied to weighted graphs, and the breadth-first search algorithm (BFS) usually uses a queue as its main data structure, which helps to use memory more efficiently, and BFS does not require backtracking. Once a node is visited, it will not be visited again, which reduces unnecessary calculations.

[0121] Specifically, the "calculation path" in Unity's navigation mesh pathfinding system can be completed through the built-in NavMeshAgent component and the NavMesh system, which includes the following processes:

[0122] 1. NavMeshAgent component: The NavMeshAgent component is a key component used to implement automatic pathfinding in Unity. When the component is added to a game object (such as a character, NPC), a series of properties need to be specified for the object, such as the radius to avoid collision, etc. These properties affect the way the target character moves in the scene.

[0123] 2. Set the target position: Once the NavMeshAgent component is added to a game object, the target position of the object can be set through the script. This is usually done by calling the SetDestination method of the NavMeshAgent and passing in the Vector3 coordinates of the target position.

[0124] 3. Path calculation: When the target position is set, NavMeshAgent will automatically start calculating the paths from the current position to the target position. First, the navigation mesh is queried to determine which areas are feasible. Then an attempt is made to find a path from the current position to the target position on the navigation mesh. This process involves the various algorithms and techniques mentioned above; when calculating the path, the NavMesh system takes into account the presence of dynamic obstacles (such as other moving characters or objects). If an area is occupied by a dynamic obstacle, an attempt is made to find another path to bypass the obstacle.

[0125] In addition, in order to make the movement of the target character look more natural and smooth, the NavMesh system will also smooth the calculated path. For example, some additional points are added to the path so that the target character can move along a smoother trajectory. The following are some common path smoothing methods: 1. Use simplification algorithms such as the Douglas-Peucker algorithm to reduce the number of path points while trying to maintain the shape of the path. 2. Use Catmull-Rom splines to generate smooth curves through given control points. 3. Use Bezier curves, especially quadratic and cubic Bezier curves, to interpolate path points to generate smooth transitions. 4. Apply specific curve smoothing algorithms such as Kochanek-Bartels splines, which can provide more control over the shape of the curve. 5. Perform linear or nonlinear interpolation between path points to generate intermediate path points to make the curve smoother. 6. Use physical simulations, such as spring-mass systems, to guide the connection between path points to achieve natural movement. 7. Use Spline curves, such as Hermite curves, to generate smooth paths. This type of curve can well control the tangent direction. 8. Subdivide the path, especially in the curve segment, by adding more path points to achieve a smooth effect.

[0126] See also Figure 2In some embodiments, the above-mentioned calculation of the congestion index of each path according to the moving speed of each non-player character may specifically include the following steps:

[0127] Step S151, obtaining the free flow speed corresponding to each non-player character on the path.

[0128] Specifically, the free flow speed of non-player characters refers to the speed at which NPCs move in the game world without external interference or obstruction. The free flow speed of NPCs is affected by many factors, such as: the NPC's basic speed attributes, such as agility, stamina, etc.; different terrains may affect the NPC's movement speed, for example, muddy ground may slow down the speed; carrying heavy objects or wearing heavy armor will reduce the NPC's movement speed; environmental factors such as weather conditions (rain, snow), lighting or terrain slope, etc., which are set in the NPC's script in the early stage of development, so they can be directly obtained here.

[0129] Step S152, calculating the delay speed of the non-player character according to the free flow speed and the moving speed.

[0130] Specifically, the delay speed is obtained by subtracting the current moving speed from the free flow speed.

[0131] Step S153, obtaining a congestion index according to the delay speed of each non-player character on the path.

[0132] The above embodiment determines the delay speed based on the free flow speed of each non-player character, and uses the delay speed of the non-player character as reference data for the path congestion degree, so that the congestion index has good real-time performance and lower calculation cost.

[0133] In some embodiments, the congestion index is obtained according to the delay speed of each non-player character on the path, including:

[0134] Step S1531, removing the maximum and minimum values ​​of each delay rate.

[0135] Before executing step S1531, it is first determined whether the number of non-player characters on this path is greater than 3. If so, step S1531 is executed, otherwise step S1532 is directly executed.

[0136] Step S1532, calculating the average value of the remaining delay speeds and using it as the congestion index.

[0137] Specifically, on a certain path, due to the different congestion levels of different sections, for example, the straight area on the path is not prone to congestion, but multiple role models are easily crowded at corners and places with dense obstacles. Therefore, on this path, the delay speeds of different non-player characters will also be different. This application takes the average as the congestion index after removing the extreme value, making the representation of the congestion level more stable and reliable. In addition, this application has a small amount of calculation and requires less computing resources. It is suitable for 3D games that consume a lot of computer computing power due to multiplayer online, real-time rendering interface and large amount of 3D model data.

[0138] See also Figure 3 In some embodiments, the above-mentioned sorting of paths based on path length and congestion index to obtain the optimal path may specifically include the following steps:

[0139] Step S161, obtaining the free flow speed of the target character on the path.

[0140] Specifically, the free-flow speed here also refers to the speed of the target character in the absence of external interference or obstacles. It is also obtained by combining variables such as character attributes and environmental factors. At the same time, considering that changes in the terrain environment of the path may cause the target orange to have different free-flow speeds on different sections, there can be multiple free-flow speeds, corresponding to different sections.

[0141] Step S162, adding the free flow speed to the congestion index to obtain a target speed.

[0142] When there are multiple free flow speeds, there are also multiple corresponding target speeds obtained here.

[0143] Step S163, dividing the path length by the target speed to obtain the moving time.

[0144] Specifically, if the target speed of the target character on different sections of the path is different, the length of each section is divided by the free flow speed corresponding to the environment of the section, and then the sum is calculated to obtain the total moving time. The formula is:

[0145]

[0146] Among them, T a is the moving time of the target character on path a, L i is the length of the i-th segment on path a, v i is the target speed of the target character on the i-th road segment, and n is the number of road segments cut by path a.

[0147] Step S164: Select the path corresponding to the shortest moving time as the optimal path.

[0148] After the above calculations, the final moving time is the time cost of each path after considering the congestion index, and the path with the smallest time cost is selected as the optimal path; in this way, among the traversed paths, the one with the smallest length is not necessarily the optimal path, and the path time cost calculated by adding the congestion index is the actual time cost spent on the move.

[0149] See also Figure 4 In some embodiments, the method further comprises:

[0150] Step S171, obtaining the number of corners of each path and normalizing each moving duration.

[0151] The turning angle of the path may be determined as being greater than a certain angle threshold.

[0152] Specifically, since the units of the moving duration and the number of corners are different, the moving duration needs to be normalized.

[0153] Step S172, multiplying the number of corners by the preset corner weight to obtain the corner weight of each path.

[0154] Step S173, multiplying the travel duration by the preset duration weight to obtain the duration weight of each path.

[0155] Among them, the preset turning angle weight can be 0.2, and the preset duration weight can be 0.8.

[0156] Step S174: Add the turning angle weight and the duration weight to obtain the congestion weight of each path.

[0157] Specifically, in addition to the congestion index calculated based on non-player characters, the number of corners can be one of the criteria for selecting the optimal path in this application; because in the actual movement of the target character, corners are places where congestion and collision are very likely to occur; assuming that when the target character is turning a corner, there is a character with a model diameter close to the corner width at the corner, and the speed is slower than the target character, then it is very easy to collide with the model of the character, resulting in a stuck model; in addition, the player's perspective after turning the corner may change significantly, and multiple corners can easily increase the pressure on the real-time screen rendering system and cause screen freezes.

[0158] Step S175: Select the path corresponding to the smallest congestion weight as the optimal path.

[0159] The above embodiment also adds the number of corners to the process of selecting the optimal path, further reducing the probability of the target character encountering congestion or collision, while reducing the content that needs to be changed for real-time image rendering and reducing the probability of image freeze.

[0160] Furthermore, in the specific implementation process, considering that the congestion index on the path changes in real time, the NPC characters refreshed anytime and anywhere are likely to cause sudden changes in the congestion levels of different paths. Therefore, the above process of determining the optimal path, in addition to being executed when the path-finding instruction is received, can also be executed while controlling the target character to move along the optimal path; that is, every time the target character moves a preset distance, the real-time position is used as the current position (the target position remains unchanged), and the above process of traversing the navigation grid and determining the optimal path (steps S13-S16) is re-executed to achieve real-time avoidance of congested sections during movement.

[0161] See also Figure 5 In some embodiments, the method further comprises:

[0162] Step S21, if the path-finding instruction includes a target duration, and multiple target characters with the same current position and target position, remove the paths with a moving duration greater than or equal to the target duration.

[0163] Step S22, dividing the path length of each path by the target duration to obtain the lower speed limit of each path.

[0164] Specifically, the player can control multiple target characters; for example, in a tower defense game, the player controls multiple NPC characters of different attack types from the exit point to the attack point. The current positions and target positions of these target characters are the same, and there is a requirement for the time to reach the target position (target duration); at this time, in order to prevent these target characters from flooding into the same optimal path, thereby causing new congestion and failing to meet the target duration requirements of the path-finding instructions, the degree of congestion needs to be considered as an upper limit when allocating paths.

[0165] Step S23, subtracting the target speed from the lower speed limit to obtain the congestion margin of each path.

[0166] Step S24, obtaining the role margin of each path based on the congestion margin.

[0167] Specifically, the lower speed limit is the minimum speed required to meet the target duration when the target character moves on the corresponding path, so that the congestion upper limit of the corresponding path is determined according to the lower speed limit to obtain the character margin that can be accommodated.

[0168] Step S25, allocating each role to each path according to the role surplus.

[0169] Specifically, if the pathfinding instruction requires that each target character can only reach the target position at the target time corresponding to the target duration, a path is randomly selected and the target character fills the role surplus corresponding to the path; if the pathfinding instruction only requires reaching the target position within the target duration and can arrive in advance, the weight of each path is calculated according to the role surplus, and these target characters are allocated according to the weight; for example: the role surplus of path A is 20, the role surplus of path B is 10, and the role surplus of path C is 15, and there are 9 target characters in total, then the weight of path A is 20 / (20+10+15)=4 / 9, and the target characters allocated to path A are 9×(4 / 9)=4. Similarly, path B is allocated 2 target characters and path C is allocated 3 target characters; when the product of the weight and the target role is not an integer, round it up.

[0170] The above-mentioned embodiment realizes the path allocation when multiple target characters are finding paths at the same time and there is a target time limit, so that the present application can be applied to more different types of game path-finding scenarios.

[0171] See also Figure 6 In some embodiments, the step of obtaining the role margin of each path based on the congestion margin includes:

[0172] Step S241, using the historical congestion index of each path and the corresponding historical number of roles to train the machine learning model.

[0173] Among them, the machine learning model can use deep learning convolutional neural networks, recurrent neural networks, long short-term memory networks, or supervised learning support vector machines, decision trees, random forest models, etc.

[0174] Specifically, a large model can be used to learn the relationship between the congestion index and the number of roles on different types of paths.

[0175] Step S242: Add the congestion margin to the congestion index to obtain the congestion upper limit value of each path.

[0176] Step S243: input the congestion upper limit value into the trained machine learning model to obtain the upper limit of the number of roles.

[0177] In addition to the congestion limit value, the input to the trained machine learning model can also include path data, including path length, environment of different sections of the path, corner location and number, etc., so that the corresponding role number limit is more accurate.

[0178] Step S244, subtract the current number of characters in the path from the upper limit of the number of characters to obtain the remaining number of characters.

[0179] This application constructs the relationship between the congestion index and the number of characters through a machine learning model, so that when determining the congestion upper limit, the corresponding character upper limit is obtained, and the character margin that can be supported on the path is calculated under the limit of the target time. The machine learning model has high computational efficiency and can still guarantee a certain accuracy and stability when processing large-scale data sets. It is very suitable for application scenarios such as 3D game maps that can construct tens of millions of different paths.

[0180] See also Figure 7 In some embodiments, the method further comprises:

[0181] Step S31, when the pathfinding instruction includes multiple target characters, obtain the rendering batch and the corresponding index information.

[0182] Among them, the rendering batch includes particles required for rendering the current game screen, and the materials of these particles are the same.

[0183] The index information includes two addresses, which are used to obtain corresponding data in two buffers respectively.

[0184] Step S32, reading attribute information corresponding to the rendering batch in the first buffer of the GPU according to the index information.

[0185] The first buffer may be a vertex buffer or an index buffer of a GPU.

[0186] Step S33, applying the attribute information to each particle in the rendering batch to obtain a primitive.

[0187] Specifically, first initialize the state of the particle according to the attribute information; in each rendering frame, the state of the particle needs to be updated, including position, rotation, size, color, etc., which is usually implemented through the update function of the particle system; generate vertex data according to the current state of the particle, including the particle's position, color and texture coordinates, and then use the vertex data to construct primitives.

[0188] Step S34, reading the instantiation times and transformation matrix in the second buffer of the GPU according to the index information.

[0189] The parameters required for instanced rendering, such as the number of instances and the transformation matrix of each instance, are set on the CPU side. After these parameters are set, they are usually sent to the second buffer of the GPU, namely the constant buffer or the uniform buffer.

[0190] Among them, the transformation matrix is ​​a mathematical tool that allows the geometric transformation of graphics objects to be represented and manipulated in a concise way. In GPU instantiation, each instance may have an associated transformation matrix that defines the specific position, rotation angle, and scale of the instance in the scene. A transformation matrix can correspond to many instances.

[0191] Instantiation is a process. Depending on the specific project situation, the same object may be instantiated, deleted, and then instantiated again. The number of instantiations is how many times the object needs to be instantiated.

[0192] Step S35, transform and adjust the instance corresponding to the primitive according to the instantiation times and the transformation matrix.

[0193] Specifically, before rendering, the instantiation times and transformation matrices need to be uploaded to the second buffer, which can be done using Unity's ComputeBuffer class or a similar mechanism. Use materials and shaders to render GameObjects during the rendering process. When encountering a material that supports GPU instancing, it will read the corresponding instantiation times and transformation matrices from the second buffer and apply them to the corresponding instance. This is usually done by calling a Unity API similar to Graphics.DrawMeshInstanced or Graphics.DrawMeshInstancedIndirect. In the shader code, use this index information to read the transformation matrix and times of the instance from the second buffer and apply them to the vertex data.

[0194] Step S36, performing illumination and mapping processing on each pixel of the primitive to obtain a rendered image.

[0195] Specifically, lighting is determined by the lighting information in the current scene that the primitive receives, and texture is determined by the texture of the model itself. During the lighting processing stage, the GPU will use different lighting models and techniques to simulate the influence of light sources.

[0196] Texture mapping is the process of mapping a two-dimensional image (texture) onto the surface of a three-dimensional object. In the GPU, texture mapping is usually implemented through texture coordinates and texture samplers.

[0197] Specifically, when there are multiple target characters moving towards the target position, it means that the game system needs to render the multiple target characters in real time to show the effect of movement, but this also puts higher requirements on the computer system.

[0198] During instanced rendering, the GPU receives instructions from the CPU and distributes them to multiple cores for processing. Each core can execute commands independently and has its own memory to store instructions and data. In this way, the GPU can render multiple objects at the same time without having to perform a complete rendering process for each object. In general, GPU instancing technology achieves efficient rendering of a large number of objects by merging similar objects or particles into a rendering batch and processing their vertices and fragments in parallel on the GPU. This technology significantly reduces the data transmission and rendering overhead between the CPU and the GPU, allowing the same set of model resources to be efficiently and quickly applied to the rendering of a large number of objects.

[0199] In some embodiments, the method further comprises:

[0200] Step S301, obtaining a plurality of particles through a 3DS file, and treating particles with the same material as a rendering batch.

[0201] Among them, 3DS files are built by art modelers. In particle systems, materials are used to define the appearance of particles, which can be simple colors or more complex textures and shader effects.

[0202] Step S302: putting the attribute information of each particle into the first buffer and generating corresponding index information.

[0203] Among them, the attribute information of particles includes normals, texture coordinates, vertex colors and other data.

[0204] This application merges particles of the same material to form a rendering batch, and stores the position, color and other attribute information of these particles in a first buffer accessible by the GPU, such as a vertex buffer, an index buffer, etc.

[0205] The merged rendering batch is sent to the GPU. The rendering batch contains the number of draw calls, index information of the vertex buffer or index buffer, etc. After the GPU completes the rendering, it transmits the picture to the display or other output device to form a visible image. GPU instancing technology reduces the number of draw calls and improves rendering efficiency by merging particles with the same material.

[0206] The material-based particle merging rendering method proposed in the above embodiment can reduce the number of drawing calls required for real-time rendering when controlling the movement of multiple target characters of the same model, thereby avoiding screen delays and freezes caused by excessive speed.

[0207] Here is a simplified way to estimate how much memory GPU instancing can save:

[0208] Basic assumption: Assume there is a scene containing N identical objects (or very similar objects that can share the same material and attribute data). Each object requires M bytes of memory to store its unique attribute data (such as position, rotation, scale, etc.). Shared material and attribute data requires S bytes of memory.

[0209] Traditional method: Without GPU instancing, each object needs to store its unique attribute data and shared material data. Therefore, the total memory requirement is N×(M+S) bytes.

[0210] Using GPU instancing: Shared material and attribute data only needs to be stored once, which is S bytes. Each object only needs to store its unique attribute data, which is M bytes. Therefore, the total memory requirement is M×N+S bytes.

[0211] Memory saved: Memory saved = (N×(M+S))-(M×N+S).

[0212] After simplification, we get: saved memory = N × S bytes.

[0213] This calculation is based on a simplifying assumption, and the actual amount of memory saved may vary depending on a number of factors. In real applications, the amount of memory saved may be affected by other factors, such as the rendering engine implementation, hardware specifications, etc.

[0214] To give a concrete example: suppose you are rendering a large outdoor scene that contains a large number of trees (e.g., 10,000), each of which is a similar model.

[0215] Benchmark (without GPU instancing): Since each tree is a separate model, each rendering requires 10,000 draw calls without GPU instancing. Due to the large number of draw calls and data transfers, rendering a frame may take a long time, such as 1.5 seconds.

[0216] Use GPU instancing: By using GPU instancing, all trees can be merged into one rendering batch. This means that although there are still 10,000 trees in the scene, only one draw call is required for rendering. Rendering time: Due to the significant reduction in the number of draw calls and the parallel processing capabilities of the GPU, rendering time can be greatly reduced after using GPU instancing. Assume that the rendering time is reduced to 0.3 seconds. Efficiency improvement calculation: The reduction ratio of the number of draw calls: from 10,000 to 1, the reduction ratio is (10,000-1) / 10,000=99.99%.

[0217] The rendering time is shortened from 1.5 seconds to 0.3 seconds, and the shortening ratio is (1.5-0.3) / 1.5=80%.

[0218] In the example above, you can see that by using GPU instancing technology, the number of draw calls can be reduced from 10,000 to 1, a reduction of up to 99.99%. At the same time, the rendering time is also reduced from 1.5 seconds to 0.3 seconds, a reduction of 80%. This significantly improves rendering efficiency, making it more efficient and faster to render a large number of similar objects.

[0219] The method of this application is to use C# to implement the basic logic framework and use Lua to implement specific business needs. This code language structure can effectively break through the Lua access bottleneck. The following are some strategies and methods to break through the bottleneck:

[0220] Reduce the number of calls between Lua and C#: Avoid calling C# functions frequently in Lua, as this will cause additional overhead. Try to combine multiple operations into one call, or perform more logic in Lua to reduce the number of interactions.

[0221] Cache frequently used data: If Lua often needs to access data in C#, you can consider caching this data on the Lua side to reduce the cost of accessing C#. When the data is updated, it is synchronized to the Lua side.

[0222] Use efficient data exchange formats: When you need to pass data between Lua and C#, choose an efficient data exchange format, such as binary data or JSON (if the performance is good enough). Avoid using complex or inefficient formats.

[0223] Asynchronous and parallel processing: If possible, process Lua logic in parallel with C# logic to avoid blocking. Use asynchronous programming techniques to ensure that both Lua and C# can fully utilize system resources.

[0224] Reduce the use of global variables: In Lua, global variables are usually slower to access than local variables. Try to use local variables to store temporary data to reduce performance overhead.

[0225] Memory management optimization: Pay attention to memory management between Lua and C#. Make sure to release memory when data is no longer needed to avoid memory leaks. Use appropriate garbage collection strategies to help manage memory.

[0226] See also Figure 8 Another embodiment of the present application provides a navigation grid-based pathfinding device, including:

[0227] The generation module 101 is used to obtain a game map and generate a navigation grid on the game map.

[0228] The position module 102 is used to determine the current position and the target position of the target character in response to the path-finding instruction.

[0229] The traversal module 103 is used to traverse the navigation grid to obtain multiple paths from the current position to the target position.

[0230] The acquisition module 104 is used to acquire the moving speed of each non-player character on each path.

[0231] The calculation module 105 is used to calculate the congestion index of each path according to the moving speed of each non-player character.

[0232] The determination module 106 is used to sort the paths based on the path length and the congestion index to obtain the optimal path.

[0233] Furthermore, the device also includes:

[0234] The obstacle module is used to remove scene models whose model attributes are obstacle attributes before generating the navigation mesh.

[0235] Furthermore, the generation module is used to generate a navigation mesh on the game map using a quadtree or Voronoi diagram algorithm.

[0236] Furthermore, the traversal module is used to obtain each path in the navigation grid by using the Dijkstra algorithm or the breadth-first search algorithm.

[0237] For further information, see Fig. 9 , the calculation module 105 includes:

[0238] The free flow unit 51 is used to obtain the free flow speed corresponding to each non-player character on the path.

[0239] The delay unit 52 is used to calculate the delay speed of the non-player character according to the free flow speed and the moving speed.

[0240] The index calculation unit 53 is used to obtain a congestion index according to the delay speed of each non-player character on the path.

[0241] Furthermore, the index calculation unit 53 is used to remove the maximum value and the minimum value of each delay speed; calculate the average value of the remaining delay speeds and use it as the congestion index.

[0242] For further information, see Fig.10 , the above-mentioned determination module 106 includes:

[0243] The target free flow unit 61 is used to obtain the free flow speed of the target character on the path.

[0244] The target speed unit 62 is used to add the free flow speed and the congestion index to obtain a target speed.

[0245] The duration calculation unit 63 is used to divide the path length of the path by the target speed to obtain the moving duration.

[0246] The path determination unit 64 is used to select the path corresponding to the minimum moving time as the optimal path.

[0247] Furthermore, the device also includes:

[0248] The corner acquisition module is used to obtain the number of corners on each path and normalize the duration of each movement.

[0249] The transfer weight module is used to multiply the number of corners by the preset corner weight to obtain the corner weight of each path.

[0250] The duration weight module is used to multiply the travel duration by the preset duration weight to obtain the duration weight of each path.

[0251] The congestion weight module is used to add the corner weight and the duration weight to obtain the congestion weight of each path.

[0252] The path determination unit is further configured to select the path corresponding to the smallest congestion weight as the optimal path.

[0253] Furthermore, the device also includes:

[0254] The path removal module is used to remove paths whose moving duration is greater than or equal to the target duration when the path-finding instruction includes the target duration and multiple target characters with the same current position and target position.

[0255] The lower limit calculation module is used to divide the path length of each path by the target time to obtain the lower limit speed of each path.

[0256] The congestion margin module is used to obtain the congestion margin of each path by subtracting the target speed from the lower speed limit.

[0257] The role margin module is used to obtain the role margin of each path based on the congestion margin.

[0258] The role allocation module is used to allocate each role to each path according to the role margin.

[0259] Furthermore, the above role margin module includes:

[0260] The training unit is used to train the machine learning model by using the historical congestion index of each path and the corresponding historical number of roles.

[0261] The congestion upper limit unit is used to add the congestion margin to the congestion index to obtain the congestion upper limit value of each path.

[0262] The role upper limit unit is used to input the congestion upper limit value into the trained machine learning model to obtain the upper limit of the number of roles.

[0263] The surplus calculation unit is used to subtract the current number of characters in the path from the upper limit of the number of characters to obtain the character surplus.

[0264] Furthermore, the device also includes:

[0265] The batch acquisition module is used to obtain rendering batches and corresponding index information when the pathfinding instruction includes multiple target characters.

[0266] The first reading module is used to read the attribute information corresponding to the rendering batch in the first buffer of the GPU according to the index information.

[0267] The primitive construction module is used to apply attribute information to each particle in the rendering batch to obtain primitives.

[0268] The second reading module is used to read the instantiation times and the transformation matrix in the second buffer of the GPU according to the index information.

[0269] The instantiation module is used to transform and adjust the instance corresponding to the primitive according to the instantiation times and the transformation matrix.

[0270] The mapping module is used to perform lighting and mapping processing on each pixel of the primitive to obtain a rendered image.

[0271] For the specific limitations of a navigation grid-based pathfinding device provided in this embodiment, please refer to the above embodiment of a navigation grid-based pathfinding method, which will not be repeated here. Each module in the above-mentioned navigation grid-based pathfinding device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0272] An embodiment of the present application provides a computer device, which may include a processor, a memory, a network interface and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, the processor executes the steps of a navigation grid-based pathfinding method as in any of the above embodiments.

[0273] The working process, working details and technical effects of the computer device provided in this embodiment can be found in the above embodiment of a navigation grid-based pathfinding method, which will not be described in detail here.

[0274] An embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of a navigation grid-based pathfinding method as in any of the above embodiments are implemented. The computer-readable storage medium refers to a carrier for storing data, which may include but is not limited to a floppy disk, an optical disk, a hard disk, a flash memory, a USB flash drive and / or a memory stick (Memory Stick), etc. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The working process, working details and technical effects of the computer-readable storage medium provided in this embodiment can be found in the above embodiment of a navigation grid-based pathfinding method, which will not be repeated here.

[0275] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0276] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0277] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A navigation grid-based pathfinding method, characterized in that: include: Obtaining a game map, and generating a navigation grid on the game map; In response to the pathfinding instruction, determining a current position and a target position of the target character; Traversing the navigation grid to obtain multiple paths from the current position to the target position; Obtaining the movement speed of each non-player character on each of the paths; Calculating the congestion index of each of the paths according to the moving speed of each of the non-player characters; Specifically, the free flow speed corresponding to each non-player character on the path is obtained; the delay speed of the non-player character is calculated according to the free flow speed and the moving speed; and the maximum value and the minimum value of each delay speed are removed; Calculating an average value of the remaining delay speeds and using it as the congestion index; Sorting the paths based on the path length and the congestion index to obtain the optimal path; Specifically, obtaining a free flow speed of the target character on the path; adding the free flow speed to the congestion index to obtain a target speed; Dividing the path length of the path by the target speed to obtain the moving time; The path corresponding to the minimum movement duration is selected as the optimal path.

2. The navigation grid-based pathfinding method according to claim 1, characterized in that: Also includes: Before generating the navigation mesh, scene models whose model attributes are obstacle attributes are eliminated.

3. The navigation grid-based pathfinding method according to claim 1, characterized in that: The obtaining of the game map and generating a navigation grid on the game map includes: The navigation grid is generated on the game map using a quadtree or Voronoi diagram algorithm.

4. The navigation grid-based pathfinding method according to claim 1, characterized in that: The traversing in the navigation grid to obtain multiple paths from the current position to the target position includes: The paths in the navigation grid are obtained by using a Dijkstra algorithm or a breadth-first search algorithm.

5. The navigation grid-based pathfinding method according to claim 1, characterized in that: Also includes: Obtaining the number of corners of each of the paths and normalizing the duration of each movement; Multiplying the number of corners by a preset corner weight to obtain a corner weight of each path; Multiplying the moving time by a preset time weight to obtain a time weight of each path; Adding the turning angle weight and the duration weight to obtain the congestion weight of each path; The path corresponding to the smallest congestion weight is selected as the optimal path.

6. The navigation grid-based pathfinding method according to claim 1, characterized in that: Also includes: If the pathfinding instruction includes a target duration, and multiple target characters whose current positions and target positions are the same, remove the paths whose moving duration is greater than or equal to the target duration; Dividing the path length of each path by the target duration to obtain the lower speed limit of each path; Subtract the target speed from the lower speed limit to obtain the congestion margin of each path; Obtaining a role margin for each of the paths based on the congestion margin; The roles are allocated to the paths according to the role margins.

7. The navigation grid-based pathfinding method according to claim 6, characterized in that: The obtaining the role margin of each of the paths based on the congestion margin includes: Training a machine learning model using the historical congestion index of each of the paths and the corresponding historical number of roles; Adding the congestion margin to the congestion index to obtain the congestion upper limit value of each path; Inputting the congestion upper limit value into the trained machine learning model to obtain an upper limit of the number of roles; The role surplus is obtained by subtracting the current role number of the path from the role number upper limit.

8. The navigation grid-based pathfinding method according to claim 5, characterized in that: The preset turning angle weight is 0.2, and the preset duration weight is 0.

8.

9. The navigation grid-based pathfinding method according to claim 6, characterized in that: Also includes: When the pathfinding instruction includes a plurality of the target characters, obtaining a rendering batch and corresponding index information; Reading attribute information corresponding to the rendering batch in the first buffer of the GPU according to the index information; Applying the attribute information to each particle in the rendering batch to obtain a primitive; Read the instantiation times and transformation matrix in the second buffer of the GPU according to the index information; Performing transformation adjustment on the instance corresponding to the primitive according to the instantiation number and the transformation matrix; Each pixel of the primitive is illuminated and mapped to obtain a rendered image.

10. The navigation grid-based pathfinding method according to claim 9, characterized in that: Also includes: Obtain multiple particles through the 3DS file, and treat the particles with the same material as a rendering batch; The attribute information of each particle is placed in the first buffer, and the corresponding index information is generated.

11. The navigation grid-based pathfinding method according to claim 9, characterized in that: The first buffer is a vertex buffer or an index buffer; the second buffer is a constant buffer or a uniform buffer.

12. A navigation grid-based pathfinding device, characterized in that: include: A generation module, used for acquiring a game map and generating a navigation grid on the game map; A location module, for determining a current location and a target location of a target character in response to a pathfinding instruction; A traversal module, used to traverse the navigation grid to obtain multiple paths from the current position to the target position; An acquisition module, used for acquiring the moving speed of each non-player character on each of the paths; A calculation module, for calculating the congestion index of each of the paths according to the moving speed of each of the non-player characters; specifically comprising: a free flow unit, for obtaining the free flow speed corresponding to each of the non-player characters on the path; a delay unit, for calculating the delay speed of the non-player character according to the free flow speed and the moving speed; an index calculation unit, for removing the maximum and minimum values ​​of each of the delay speeds; and calculating the average value of the remaining delay speeds as the congestion index; A determination module is used to sort the paths based on the path length and the congestion index to obtain the optimal path; specifically includes: a target free flow unit, used to obtain the free flow speed of the target character on the path; a target speed unit, used to add the free flow speed to the congestion index to obtain the target speed; a duration calculation unit, used to divide the path length of the path by the target speed to obtain the moving duration; a path determination unit, used to select the path corresponding to the minimum moving duration as the optimal path.

13. The navigation grid-based pathfinding device according to claim 12, characterized in that: Also includes: The obstacle module is used to remove the scene model whose model attribute is an obstacle attribute before generating the navigation mesh.

14. The navigation grid-based pathfinding device according to claim 12, characterized in that: The generation module is used to generate the navigation grid on the game map by using a quadtree or Voronoi diagram algorithm.

15. The navigation grid-based pathfinding device according to claim 12, characterized in that: The traversal module is used to obtain each path in the navigation grid by using a Dijkstra algorithm or a breadth-first search algorithm.

16. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the navigation grid-based pathfinding method according to any one of claims 1 to 11 are implemented.

17. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the navigation grid-based pathfinding method according to any one of claims 1 to 11 are implemented.

Citation Information

Patent Citations

  • Map navigation method and device, storage medium and computer equipment

    CN112742030A

  • Game role moving path determination method and device and electronic equipment

    CN113082714A