Path Finding Method, Device, Equipment and Storage Medium in Virtual Scenario

By setting offset radius and candidate positions for AI objects in virtual scenes and optimizing path selection, the problem of inefficient pathfinding of AI objects is solved, and a more flexible and efficient pathfinding method is achieved.

CN114377397BActive Publication Date: 2025-07-25TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210074051.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-21
Publication Date
2025-07-25
Estimated Expiration
2042-01-21

AI Technical Summary

Technical Problem

In the prior art, a large number of AI objects are prone to crowding and queuing when searching for the same target object, resulting in inefficient road search.

Method used

By obtaining the offset radius of the target position of the artificial intelligence object relative to the virtual object, determine the target area centered on the virtual object, and select multiple candidate positions in the area, select appropriate target positions and paths, disperse the pathfinding targets of the AI object, and optimize path selection and speed settings.

Benefits of technology

The diversity and efficiency of AI object pathfinding are improved, crowding and queuing are avoided, and the pathfinding efficiency in virtual scenes is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114377397B_ABST
    Figure CN114377397B_ABST
Patent Text Reader

Abstract

The present application provides a pathfinding method, apparatus, device, and computer-readable storage medium in a virtual scenario; the method includes: in response to a pathfinding request of an artificial intelligence object for a virtual object in the virtual scenario, obtaining an offset radius of the target position of the artificial intelligence object relative to the position where the virtual object is located; determining a target area centered on the virtual object with the offset radius as the area radius, and obtaining at least two candidate positions within the target area; selecting a target position corresponding to the artificial intelligence object from the at least two candidate positions; determining a target movement path from the starting position of the artificial intelligence object to the target position, and returning the target movement path to the artificial intelligence object. Through the present application, it is possible to disperse the pathfinding target positions of artificial intelligence objects, achieve pathfinding diversity of artificial intelligence objects, and improve the pathfinding efficiency in the virtual scenario.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical fields of virtualization and human-computer interaction, and in particular, to a pathfinding method, device, equipment, computer-readable storage medium, and computer program product in a virtual scenario. Background Art

[0002] With the development of modern social technology, more and more mobile phone or computer games have entered people's lives. For pathfinding of artificial intelligence (AI) objects in games, the pathfinding algorithms in related game engines often return a fixed shortest path between the starting point and the ending point of the AI object's pathfinding after the starting point and the ending point of the AI object's pathfinding are given, and the game scenario remains unchanged. Then, the AI will move along this fixed path according to its own movement rules, speed, and acceleration configuration.

[0003] However, in related technologies, when a large number of AI objects perform pathfinding towards the same target object, abnormal situations such as congestion and queuing are likely to occur, resulting in low pathfinding efficiency and high pathfinding consumption of the AI objects. Summary of the Invention

[0004] Embodiments of this application provide a pathfinding method, device, equipment, computer-readable storage medium, and computer program product in a virtual scenario, which can disperse the target positions of artificial intelligence object pathfinding, realize the diversity of artificial intelligence object pathfinding, and improve the pathfinding efficiency in the virtual scenario.

[0005] The technical solution of the embodiments of this application is implemented as follows:

[0006] Embodiments of this application provide a method, including:

[0007] In response to a pathfinding request of an artificial intelligence object in a virtual scenario for a virtual object, obtain an offset radius of the target position of the artificial intelligence object relative to the position where the virtual object is located;

[0008] Determine a target area centered on the virtual object with the offset radius as the area radius, and obtain at least two candidate positions within the target area;

[0009] Select a target position corresponding to the artificial intelligence object from the at least two candidate positions;

[0010] Determine a target movement path from the starting position of the artificial intelligence object to the target position, and return the target movement path to the artificial intelligence object.

[0011] Embodiments of this application provide a pathfinding device in a virtual scenario, including:

[0012] A response module, configured to, in response to a pathfinding request of an artificial intelligence object for a virtual object in a virtual scene, obtain an offset radius of a target position of the artificial intelligence object relative to a position where the virtual object is located;

[0013] An obtaining module, configured to determine a target area centered on the virtual object with the offset radius as the area radius, and obtain at least two candidate positions within the target area;

[0014] A selection module, configured to select a target position corresponding to the artificial intelligence object from the at least two candidate positions;

[0015] A determination module, configured to determine a target movement path from a starting position of the artificial intelligence object to the target position, and return the target movement path to the artificial intelligence object.

[0016] In the above solution, the response module is further configured to, when there is at least one unselected idle candidate position among the at least two candidate positions, select one from the at least one idle candidate position as the target position of the artificial intelligence object;

[0017] When there is no unselected idle candidate position among the at least two candidate positions, determine a selection priority of the at least two candidate positions, and select one from the at least two candidate positions as the target position of the artificial intelligence object according to the selection priority.

[0018] In the above solution, the response module is further configured to, for each of the candidate positions, obtain the number of artificial intelligence objects taking the candidate position as the target position;

[0019] Determine a selection priority of the corresponding candidate position according to the number, and the selection priority has a negative correlation with the number.

[0020] In the above solution, the obtaining module is further configured to determine a plurality of scattered positions within the target area;

[0021] Establish a coordinate system with the position where the virtual object is located as the origin according to the map of the virtual scene;

[0022] Determine at least two of the plurality of scattered positions that are between the artificial intelligence object and a plane where the vertical axis of the coordinate system is located as the candidate positions.

[0023] In the above solution, the determination module is further configured to determine a plurality of candidate paths from a starting position corresponding to the artificial intelligence object to a target position corresponding to the virtual object;

[0024] For each of the candidate paths including multiple road segments, obtain the number of objects in each road segment included in the candidate path and the path consumption of each road segment;

[0025] Based on the number of objects in each road segment, determine the weight of the corresponding road segment;

[0026] Based on the path consumption of each road segment included in each candidate path and the weight of the corresponding road segment, determine the path consumption of each candidate path, and based on the path consumption of each candidate path, select the target moving path from the multiple candidate paths.

[0027] In the above solution, the determining module is further configured to perform the following processing for each candidate path respectively:

[0028] Obtain the initial path consumption of each road segment included in the candidate path and the influence coefficient of each road segment;

[0029] For each road segment, perform a multiplication process on the initial path consumption, the corresponding weight, and the influence coefficient to obtain the path consumption of each road segment;

[0030] Perform a summation process on the path consumption of each road segment included in the candidate path to obtain the path consumption of the candidate path.

[0031] In the above solution, the determining module is further configured to obtain the additional path consumption of each candidate path;

[0032] For each candidate path, add the result of performing the summation process to the additional path consumption of the corresponding candidate path to obtain the path consumption of the candidate path.

[0033] In the above solution, the determining module is further configured to select the candidate path with the minimum path consumption from the multiple candidate paths as the target moving path;

[0034] Or,

[0035] Compare the path consumption of each candidate path with a consumption threshold respectively, and when the comparison result indicates that there is a candidate path with a path consumption less than the consumption threshold, randomly select one of the candidate paths with a path consumption less than the consumption threshold as the target moving path.

[0036] In the above solution, the determining module is further configured to obtain the moving speed of the artificial intelligence object corresponding to each road segment for at least two road segments included in the target moving path;

[0037] Return each of the moving speeds to the artificial intelligence object, so that the artificial intelligence object moves on the corresponding section based on each of the moving speeds.

[0038] In the above solution, the determining module is further configured to perform the following processing for each of the sections:

[0039] Obtain the speed preference of the artificial intelligence object corresponding to the section, where the magnitude of the speed preference is the maximum speed at which the artificial intelligence object can move along the section without colliding with other virtual objects in the virtual scene;

[0040] Allocate at least two test speeds to the artificial intelligence object, where the test speeds are different from the speed corresponding to the speed preference;

[0041] Obtain the speed influencing factors, and score at least two of the test speeds based on the speed influencing factors and the speed preference to obtain the scores of each of the test speeds;

[0042] Determine the moving speed of the artificial intelligence object corresponding to the section based on each of the scores.

[0043] In the above solution, the determining module is further configured to respectively obtain the difference between the magnitude of each of the test speeds and the magnitude of the speed preference;

[0044] Respectively obtain the angular deviation between the speed direction of each of the test speeds and the speed direction corresponding to the speed preference;

[0045] Respectively obtain the probability of collision between the artificial intelligence object and other virtual objects in the virtual scene when the artificial intelligence object moves along the corresponding section at each of the test speeds;

[0046] Use at least one of the difference, the angular deviation, and the probability as the speed influencing factor.

[0047] In the above solution, when the number of artificial intelligence objects is at least two, the determining module is further configured to obtain the speed offset angle range when at least two artificial intelligence objects start to move along the target moving path simultaneously;

[0048] Divide the speed offset angle range equally according to the number of artificial intelligence objects to obtain the offset angle;

[0049] Determine the target moving speed of each artificial intelligence object according to the offset angle and the magnitude of the moving speed of each artificial intelligence object, so that each artificial intelligence object moves dispersedly at the corresponding target moving speed.

[0050] In the above solution, the determining module is further configured to generate a navigation mesh corresponding to the virtual scene, and each sub-navigation mesh in the navigation mesh is a convex polygon;

[0051] In the navigation mesh, obtain a starting mesh corresponding to the starting position of the artificial intelligence object and a target mesh corresponding to the target position of the artificial intelligence object;

[0052] Determine a target path mesh between the starting mesh and the target mesh, where the target path mesh includes at least two of the sub-navigation meshes;

[0053] Determine path points corresponding to each of the sub-navigation meshes in the target path mesh, and connect the path points in sequence to obtain a target movement path.

[0054] An embodiment of the present application provides an electronic device, including:

[0055] A memory for storing executable instructions;

[0056] A processor, when executing the executable instructions stored in the memory, implements the path finding method in the virtual scene provided by the embodiment of the present application.

[0057] An embodiment of the present application provides a computer-readable storage medium storing executable instructions for causing a processor to implement the path finding method in the virtual scene provided by the embodiment of the present application when executed.

[0058] An embodiment of the present application provides a computer program product, including a computer program or instructions for causing a processor to implement the path finding method in the virtual scene provided by the embodiment of the present application when executed.

[0059] The embodiment of the present application has the following beneficial effects:

[0060] Applying the above embodiments of the present application, when receiving a path finding request of an artificial intelligence object for a virtual object, obtain the offset radius of the target position of the artificial intelligence object relative to the position of the virtual object. In this way, the target area where the target position of the artificial intelligence object is located can be determined; then, select the target position of the artificial intelligence object from at least two candidate positions determined within the target area. In this way, the target positions for the artificial intelligence object to find a path can be dispersed, making the target positions for the artificial intelligence object to find a path flexible. At the same time, the target movement path determined based on the target position is also flexible. Thus, the diversity of the path finding of the artificial intelligence object is realized, and the path finding efficiency of the artificial intelligence object is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1It is a schematic architecture diagram of the pathfinding system 100 in the virtual scenario provided by the embodiments of the present application;

[0062] Figure 2 It is a schematic structural diagram of the electronic device 500 for implementing the pathfinding method in the virtual scenario provided by the embodiments of the present application;

[0063] Figure 3 It is a schematic flowchart of the pathfinding method in the virtual scenario provided by the embodiments of the present application;

[0064] Figure 4 It is a schematic diagram of the candidate location determination method provided by the embodiments of the present application;

[0065] Figure 5 It is a schematic diagram of the scattered locations provided by the embodiments of the present application;

[0066] Figure 6 It is a schematic diagram of the target location determination method provided by the embodiments of the present application;

[0067] Figure 7 It is a schematic flowchart of the target location determination method provided by the embodiments of the present application;

[0068] Figure 8 It is a schematic diagram of the method for determining the target movement path provided by the embodiments of the present application;

[0069] Figure 9 It is a schematic diagram of the method for determining the path cost provided by the embodiments of the present application;

[0070] Figure 10 It is a schematic diagram of the method for determining the target movement path provided by the embodiments of the present application;

[0071] Figure 11 It is a schematic diagram of the navigation grid provided by the embodiments of the present application;

[0072] Figure 12 It is a schematic flowchart of the method for determining the movement speed of the AI object provided by the embodiments of the present application;

[0073] Figure 13 It is a schematic flowchart of the method for determining the movement speed of the corresponding road segment provided by the embodiments of the present application;

[0074] Figure 14 It is a schematic diagram of the method for determining the speed influencing factors provided by the embodiments of the present application;

[0075] Figure 15 It is a schematic diagram of the scattered movement of the AI object provided by the embodiments of the present application;

[0076] Figures 16A - 16B It is a schematic diagram of the scattered pathfinding of the AI object provided by the embodiments of the present application;

[0077] Figure 17 It is a schematic diagram of the pathfinding speed preference setting interface provided by an embodiment of the present application;

[0078] Figures 18A - 18B It is a schematic diagram of the influence of the offset angle on the speed offset provided by an embodiment of the present application;

[0079] Figures 19A - 19B It is a schematic diagram of the change in the overall pathfinding method of the AI object provided by an embodiment of the present application;

[0080] Figure 20 It is a flowchart of the pathfinding method of the AI object provided in the related art;

[0081] Figure 21 It is a schematic diagram of the decentralized point selection strategy provided by an embodiment of the present application;

[0082] Figure 22A It is a schematic diagram of the speed test provided in the related art;

[0083] Figure 22B It is a schematic diagram of the speed preference of the AI object provided by an embodiment of the present application. Detailed implementation manners

[0084] In order to make the objectives, technical solutions, and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limitations on the present application. All other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the present application.

[0085] In the following descriptions, reference is made to "some embodiments", which describe a subset of all possible embodiments. However, it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments, and can be combined with each other without conflict.

[0086] If similar descriptions such as "first / second" appear in the application documents, the following explanations are added. In the following descriptions, the terms "first\second\third" are only used to distinguish similar objects and do not represent a specific order for the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence when allowed, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.

[0087] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0088] Before further elaborating on the embodiments of the present application, the nouns and terms involved in the embodiments of the present application are described, and the nouns and terms involved in the embodiments of the present application are applicable to the following explanations.

[0089] 1) Responsive to, used to represent the conditions or states on which the executed operations depend. When the dependent conditions or states are met, one or more of the executed operations can be real-time or can have a set delay; without special instructions, there is no limit on the execution order of the multiple executed operations.

[0090] 2) Virtual scene, which is a virtual scene displayed (or provided) when the application runs on the terminal. This virtual scene can be a purely fictional virtual environment. The virtual scene can be any one of a two-dimensional virtual scene, a 2.5D virtual scene, or a three-dimensional virtual scene. The embodiments of the present application do not limit the dimension of the virtual scene. For example, the virtual scene can include the sky, land, ocean, etc. The land can include environmental elements such as deserts and cities. Users can control virtual objects to perform activities in this virtual scene. The activities include but are not limited to at least one of adjusting body posture, crawling, walking, running, cycling, jumping, driving, picking up, shooting, attacking, and throwing. The virtual scene can be displayed from the first-person perspective (for example, playing the virtual object in the game from the player's own perspective); it can also be displayed from the third-person perspective (for example, the player chasing the virtual object in the game to play); it can also be displayed from an aerial bird's-eye view; among them, the above perspectives can be switched arbitrarily.

[0091] Taking the virtual scene displayed from the first-person perspective as an example, the virtual scene displayed in the human-computer interaction interface can include: determining the field-of-view area of the virtual object according to the viewing position and field-of-view angle of the virtual object in the complete virtual scene, and presenting the partial virtual scene in the field-of-view area in the complete virtual scene, that is, the displayed virtual scene can be a partial virtual scene relative to the panoramic virtual scene. Because the first-person perspective is the viewing perspective that can most impact the user, in this way, an immersive perception of the user being on the scene during the operation can be achieved. Taking the virtual scene displayed from an aerial bird's-eye view as an example, the interface of the virtual scene presented in the human-computer interaction interface can include: in response to a zoom operation on the panoramic virtual scene, presenting the partial virtual scene corresponding to the zoom operation in the human-computer interaction interface, that is, the displayed virtual scene can be a partial virtual scene relative to the panoramic virtual scene. In this way, the operability of the user during the operation can be improved, and thus the efficiency of human-computer interaction can be improved.

[0092] 3) Virtual object: The images of various people and objects that can interact in a virtual scene, or movable objects in the virtual scene. The movable object can be a virtual character, a virtual animal, an anime character, etc. For example: the characters, animals, plants, oil drums, walls, stones, etc. displayed in the virtual scene. The virtual object can be a virtual image in the virtual scene used to represent the user. The virtual scene can include multiple virtual objects, and each virtual object has its own shape and volume in the virtual scene, occupying a part of the space in the virtual scene.

[0093] Optionally, the virtual object can be a user role controlled by operations on the client, or an AI set through training in a virtual scene battle, or a non-user role (NPC, Non-Player Character) set in a virtual scene interaction. Optionally, the virtual object can be a virtual character that conducts adversarial interaction in the virtual scene. Optionally, the number of virtual objects participating in the interaction in the virtual scene can be preset, or dynamically determined according to the number of clients joining the interaction.

[0094] Taking a shooting game as an example, the user can control the virtual object to freely fall, glide or open a parachute to fall in the sky of the virtual scene, run, jump, crawl, bend forward, etc. on land, or control the virtual object to swim, float or dive in the ocean. Of course, the user can also control the virtual object to move in the virtual scene by taking a vehicle-type virtual prop. For example, the vehicle-type virtual prop can be a virtual car, a virtual aircraft, a virtual yacht, etc.; the user can also control the virtual object to conduct adversarial interaction with other virtual objects through an attack-type virtual prop. For example, the virtual prop can be a virtual mecha, a virtual tank, a virtual fighter plane, etc. Only the above scenarios are used for illustration here, and the embodiments of the present application do not make specific limitations on this.

[0095] 4) Scene data: indicating various characteristics shown by the objects in the virtual scene during the interaction process. For example, it can include the positions of the objects in the virtual scene. Of course, different types of characteristics can be included according to the type of the virtual scene; for example, in the virtual scene of a game, the scene data can include the time required to wait for various functions configured in the virtual scene (depending on the number of times the same function can be used within a specific time), and can also represent the attribute values of various states of the game characters, such as including health points (also known as red bar), magic points (also known as blue bar), status values, blood volume, etc.

[0096] 5) Player Versus Environment (PVE): The PVE mode is a battle between players and monsters, that is, players battle against the environment. In the game, players challenge NPC monsters and BOSSes controlled by the game program. PvE is sometimes also referred to as PVC (Player Vs Computer), which mainly refers to activities such as challenging powerful BOSSes in online games. The single-player mode and the biochemical mode of the CF mobile game belong to PVE.

[0097] Based on the above explanations of the nouns and terms involved in the embodiments of the present application, the pathfinding system in the virtual scene provided by the embodiments of the present application will be described below. Refer to Figure 1 , Figure 1 FIG. is a schematic architecture diagram of a pathfinding system 100 in a virtual scene provided by an embodiment of the present application. To support an exemplary application, terminals (exemplarily shown as terminals 400-1 and 400-2) are connected to a server 200 through a network 300. The network 300 can be a wide area network, a local area network, or a combination of the two, and uses wireless or wired links to implement data transmission.

[0098] Terminals (such as terminals 400-1 and 400-2) are used to send a request for obtaining the scene data of the virtual scene to the server 200 based on a trigger operation received on the view interface to enter the virtual scene;

[0099] The server 200 is used to receive the request for obtaining the scene data, and in response to the request, return the scene data of the virtual scene to the terminal;

[0100] The server 200 is used to, in response to a pathfinding request of an artificial intelligence object for a virtual object in the virtual scene, obtain an offset radius of the target position of the artificial intelligence object relative to the position where the virtual object is located; determine a target area centered on the virtual object with the offset radius as the area radius, and obtain at least two candidate positions within the target area; select the target position corresponding to the artificial intelligence object from the at least two candidate positions; determine a target movement path from the starting position of the artificial intelligence object to the target position, and return the target movement path to the artificial intelligence object in the virtual scene presented by the terminal;

[0101] Terminals (such as terminals 400-1 and 400-2) are used to receive the scene data of the virtual scene, render the picture of the virtual scene based on the obtained scene data, and present the picture of the virtual scene on a graphical interface (exemplarily shown as graphical interfaces 410-1 and 410-2); wherein, an AI object, a virtual object, an interaction environment, etc. can also be presented in the picture of the virtual scene, and the content presented in the picture of the virtual scene is all rendered based on the returned scene data of the virtual scene.

[0102] In practical applications, the server 200 can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The terminals (such as terminals 400-1 and 400-2) can be smartphones, tablets, laptops, desktop computers, smart speakers, smart TVs, smart watches, etc., but are not limited thereto. The terminals (such as terminals 400-1 and 400-2) and the server 200 can be directly or indirectly connected through wired or wireless communication methods, and this application does not make any restrictions in this regard.

[0103] In practical applications, the terminals (including terminals 400-1 and 400-2) are installed with and run application programs that support virtual scenarios. The application program can be any one of a first-person shooting game (FPS), a third-person shooting game, a driving game dominated by steering operations, a multiplayer online battle arena game (MOBA), a two-dimensional (2D) game application, a three-dimensional (3D) game application, a virtual reality application program, a three-dimensional map program, or a multiplayer gunfight survival game. The application program can also be a stand-alone application program, such as a stand-alone 3D game program.

[0104] Taking an electronic game scenario as an exemplary scenario, the user can perform operations on the terminal in advance. After the terminal detects the user's operations, it can download the game configuration file of the electronic game. The game configuration file can include the application program, interface display data, or virtual scene data of the electronic game, etc., so that when the user logs in to the electronic game on the terminal, the game configuration file can be called to render and display the electronic game interface. The user can perform touch operations on the terminal. After the terminal detects the touch operations, it can determine the game data corresponding to the touch operations and render and display the game data. The game data can include virtual scene data, the behavior data of virtual objects in the virtual scene, etc.

[0105] In practical applications, a terminal (including terminal 400-1 and terminal 400-2) receives a trigger operation to enter a virtual scene based on a view interface, and sends a request for obtaining scene data of the virtual scene to server 200; server 200 receives the request for obtaining scene data, and in response to the request, returns the scene data of the virtual scene to the terminal; the terminal receives the scene data of the virtual scene, renders the picture of the virtual scene based on the scene data, and presents at least one AI object and a virtual object controlled by a player in the interface of the virtual scene; when the server receives a pathfinding request from the AI object for the virtual object, it determines the target movement path of the AI object and returns the target movement path to the AI object, and the terminal presents an interface in which the AI object moves along the target movement path.

[0106] The embodiments of the present application can also be implemented with the help of cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or a local area network to achieve data calculation, storage, processing, and sharing.

[0107] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model. It can form a resource pool, be used on demand, and is flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources.

[0108] See Figure 2 , Figure 2 is a schematic structural diagram of an electronic device 500 for implementing the pathfinding method in a virtual scene provided by an embodiment of the present application. In practical applications, the electronic device 500 can be Figure 1 the server or terminal shown in. Taking the electronic device 500 as Figure 1 the terminal shown in as an example, the electronic device for implementing the pathfinding method in the virtual scene of the embodiment of the present application will be described. The electronic device 500 provided by the embodiment of the present application includes: at least one processor 510, a memory 550, at least one network interface 520, and a user interface 530. Each component in the electronic device 500 is coupled together through a bus system 540. It can be understood that the bus system 540 is used to realize the connection and communication between these components. In addition to a data bus, the bus system 540 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clear description, in Figure 2 all kinds of buses are labeled as the bus system 540.

[0109] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0110] The user interface 530 includes one or more output devices 531 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 530 also includes one or more input devices 532, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.

[0111] The memory 550 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 550 may optionally include one or more storage devices that are physically remote from the processor 510.

[0112] The memory 550 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 550 described in the embodiments of the present application is intended to include any suitable type of memory.

[0113] In some embodiments, the memory 550 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.

[0114] Operating system 551, including system programs for processing various basic system services and performing hardware-related tasks, such as framework layer, core library layer, driver layer, etc., for implementing various basic services and processing hardware-based tasks;

[0115] A network communication module 552, for reaching other computing devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 include: Bluetooth, Wireless Compatibility Certification (WiFi), and Universal Serial Bus (USB);

[0116] A presentation module 553 for enabling presentation of information (e.g., a user interface for operating a peripheral device and displaying content and information) via one or more output devices 531 associated with the user interface 530 (e.g., a display screen, a speaker, etc.).

[0117] An input processing module 554 for detecting and translating one or more user inputs or interactions from one of one or more input devices 532.

[0118] In some embodiments, the pathfinding device in the virtual scenario provided by the embodiments of the present application may be implemented in software. Figure 2 A pathfinding device 555 in the virtual scenario stored in the memory 550 is shown, which may be software in the form of a program, a plugin, etc., including the following software modules: a response module 5551, an acquisition module 5552, a selection module 5553, and a determination module 5554. These modules are logical, and thus can be arbitrarily combined or further split according to the implemented functions. The functions of each module will be described below.

[0119] In other embodiments, the pathfinding device in the virtual scenario provided by the embodiments of the present application may be implemented in a combination of software and hardware. As an example, the pathfinding device in the virtual scenario provided by the embodiments of the present application may be a processor in the form of a hardware decoding processor, which is programmed to execute the pathfinding method in the virtual scenario provided by the embodiments of the present application. For example, the processor in the form of a hardware decoding processor may employ one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field programmable gate arrays (FPGAs), or other electronic components.

[0120] Based on the above description of the pathfinding system and electronic device in the virtual scenario provided by the embodiments of the present application, the pathfinding method in the virtual scenario provided by the embodiments of the present application will be described below. In some embodiments, the pathfinding method in the virtual scenario provided by the embodiments of the present application can be implemented independently by the server or the terminal, or jointly implemented by the server and the terminal. In some embodiments, the terminal or the server can implement the pathfinding method in the virtual scenario provided by the embodiments of the present application by running a computer program. For example, the computer program can be a native program or software module in the operating system; it can be a local (Native) application (APP, Application), that is, a program that needs to be installed in the operating system to run, such as a client supporting the virtual scenario, such as a game APP; it can also be a small program, that is, a program that only needs to be downloaded to the browser environment to run; it can also be a small program that can be embedded into any APP. In short, the above computer program can be any form of application program, module or plug-in.

[0121] The pathfinding method in the virtual scenario provided by the embodiments of the present application will be described below by taking the implementation by the server as an example. Refer to Figure 3 , Figure 3 which is a schematic flowchart of the pathfinding method in the virtual scenario provided by the embodiments of the present application. The pathfinding method in the virtual scenario provided by the embodiments of the present application includes:

[0122] In step 101, the server, in response to a pathfinding request of an artificial intelligence object in the virtual scenario for a virtual object, obtains an offset radius of the target position of the artificial intelligence object relative to the position where the virtual object is located.

[0123] In actual implementation, an application client supporting the virtual scenario can be installed on the terminal. When the user opens the application client on the terminal and the terminal runs the application client, the terminal presents an interface of the virtual scenario, and in the interface of the virtual scenario, a virtual object and an AI object are presented. In actual applications, the virtual object can be the virtual image in the virtual scenario corresponding to the user account currently logged in to the application client. For example, the virtual object can be the virtual object controlled by a user who enters a chasing game. The artificial intelligence object can be an object controlled by a robot (in a game scenario, it can be called game AI, which is a general term for non-player controlled units in the game, including monsters, NPCs, intelligent items, etc.) in the game. Of course, other virtual objects or interaction objects can also be included in the virtual scenario and can be controlled by other users.

[0124] In actual applications, when the AI object in the virtual scene moves towards the virtual object, the server can receive a pathfinding request for the virtual object sent by the AI object, and then obtain the offset radius of the target position of the AI object relative to the position of the virtual object, and based on the obtained offset radius and the position of the virtual object, perform the target moving path determination operation.

[0125] The method for obtaining the offset radius of the target position of the AI object relative to the position of the virtual object is described. In some embodiments, the pathfinding request sent by the AI object for the virtual object can directly carry the offset radius of the target position of the AI object relative to the position of the virtual object, that is, the pathfinding request carries a parameter of an offset radius, which is used to specify the random offset radius of the actual pathfinding target position of the AI object relative to the virtual object. In this way, the server parses the pathfinding request sent by the AI object and can directly obtain the offset radius of the target position of the AI object relative to the position of the virtual object.

[0126] In some embodiments, after receiving a pathfinding request sent by an AI object (in this case, the pathfinding request does not carry information related to the offset radius), the server can also automatically determine the offset radius of the target position of the AI object relative to the position of the virtual object according to the attribute information of the virtual object. The attribute information of the virtual object may include the level of the virtual object, the type of the virtual object, etc. In addition, the server can also automatically determine the offset radius according to the attributes of the AI object in the virtual scene, wherein the attributes of the AI object may include the category of the AI object, the damage level, and the number of AI objects, etc.

[0127] Exemplarily, taking a monster pathfinding game as an example (it can also be a monster attacking player game), the server obtains the level of the current virtual object (player level) and sets the corresponding offset radius according to the player level. The higher the player level, the larger the offset radius. When the monster initiates a pathfinding request (the monster is ready to attack the player), the target position corresponding to the monster falls into the interactive range corresponding to the player (i.e., the range with the player's position as the center and the offset radius as the area radius), which can be regarded as the monster's pathfinding success. In this way, the player's user experience can be improved. In addition, when the number of AI objects in the virtual scene is large, a smaller offset radius can be set. At this time, the smaller the distance between the target position of the AI object and the position of the virtual object, the more conducive it is for the virtual object to move safely between many AI objects.

[0128] It should be noted that when there are multiple AI objects and they all move towards the virtual object, in order to ensure that each AI object can move in a decentralized manner to the position where the virtual object is located, it is possible to set a preset number of scattered positions (scattered points) within the interactive range of the virtual object (in an attack game, it can also be regarded as the hit range of the player), and select one of the multiple scattered points as the target position of the AI object. When the AI object moves from the starting point to the target position, that is, when the AI object is at the target position, it can interact with the virtual object.

[0129] Exemplarily, taking an AI pathfinding game as an example, in the virtual scene corresponding to the game, in order for the AI to move to the interactive range where the player is located (which can also be called the hit range in an attack game), the AI object can send a pathfinding request for the virtual object to the game server. When there are multiple AI objects moving towards the same virtual object at the same time point or within a certain period of time (such as 5 seconds), in order to prevent phenomena such as congestion and queuing when the number of monsters in the game scene increases, the pathfinding request sent by the AI object can be for the target position of the AI object, that is, not the actual position where the virtual object is located, but other positions within the interactive range (hit range) of the virtual object.

[0130] In step 102, determine a target area centered on the virtual object with the offset radius as the area radius, and obtain at least two candidate positions within the target area.

[0131] In actual implementation, after the server receives the pathfinding request sent by the AI object, it obtains the offset radius carried in the pathfinding request, and determines at least two candidate positions in the target area centered on the virtual object with the offset radius as the area radius, and disperses the actual pathfinding target position (pathfinding end point) of the AI object to multiple candidate positions in the target area.

[0132] In some embodiments, refer to Figure 4 , Figure 4 is a schematic diagram of the candidate position determination method provided by an embodiment of the present application. The server can also determine the candidate positions through the steps shown in Figure 4 , and will be described in combination with the steps.

[0133] Step 1021, the server determines multiple scattered positions within the target area.

[0134] In actual implementation, the server determines multiple scattered positions in the target area centered on the virtual object with the offset radius as the area radius. Among them, the scattered positions can be scattered in the target area in a random distribution form or in a uniform distribution form.

[0135] In actual implementation, the number of scattered positions can be set according to the number of AI objects in the virtual scene. The server first obtains the maximum number N (N≥1 and N is a positive integer) of AI objects in the virtual scene, and then sets n scattered positions (n≤N, n is a positive integer) in the target area, that is, the number of scattered positions can be set to be less than or equal to the number of AI objects. Additionally, the number of scattered positions can also be preset by the server according to the actual computing power of the device. Step 1022: Based on the map of the virtual scene, establish a coordinate system with the position of the virtual object as the origin.

[0136] In actual implementation, the server can establish a coordinate system with the position of the virtual object as the origin according to the map in the virtual scene. Among them, the map in the virtual scene can use the world coordinate system (also known as the absolute coordinate system). In the world coordinate system, the x-axis (horizontal axis) is to the right, the y-axis (vertical axis) is upward, and the z-axis is forward, and the world coordinate system can be divided into eight quadrants or four quadrants. Additionally, the map in the virtual scene can also use the rectangular coordinate system, in which the horizontal axis is the x-axis and the vertical axis is the y-axis.

[0137] Exemplarily, refer to Figure 5 , Figure 5 is a schematic diagram of the scattered positions provided by the embodiment of the present application. The center of the circle in the figure is the position of the virtual object, and a world coordinate system is constructed with the position of the virtual object as the origin. The gray area in the figure is the target area.

[0138] Step 1023: Determine at least two scattered positions among the multiple scattered positions that are between the artificial intelligence object and the plane where the vertical axis of the coordinate system is located as candidate positions.

[0139] In actual implementation, according to the screening conditions, candidate positions that can be used as the target positions of AI objects are screened from each scattered position scattered in the target area. Among them, the screening conditions can include the following methods. One is that the distance from the scattered position to the position of the virtual object needs to be less than the hit radius of the virtual object (that is, within the target area). The other is that the line segment formed by the starting position of the AI object and the scattered position (which can be regarded as a candidate path) needs to be on the same side of the virtual object, that is, there cannot be a candidate path passing through the virtual object. Described in terms of the world coordinate system, it can be understood that the candidate positions are at least two scattered positions between the artificial intelligence object and the plane where the vertical axis (y-axis) of the coordinate system is located.

[0140] Exemplarily, refer to Figure 5 , in the target area, there are multiple scattered positions where the candidate path does not pass through the target area of the virtual object.

[0141] In step 103, select the target position corresponding to the artificial intelligence object from at least two candidate positions.

[0142] In some embodiments, the server may implement the operation of selecting the target position of the corresponding artificial intelligence object in the following manner: when there is at least one idle candidate position among at least two candidate positions that has not been selected, select one from the at least one idle candidate position as the target position of the artificial intelligence object.

[0143] In actual implementation, after determining at least two candidate positions, when there is an idle candidate position that has not been selected, a random idle candidate position may be selected as the target position of the AI object.

[0144] Exemplarily, referring to Figure 5 , when there is an idle candidate position (the position indicated by the white dot in the figure) among the candidate positions, a random idle candidate position may be selected from the idle candidate positions as the actual target position of the AI object.

[0145] In some embodiments, referring to Figure 6 , Figure 6 is a schematic diagram of the target position determination method provided by an embodiment of the present application. The server may also implement the operation of selecting the target position for the artificial intelligence object through the Figure 6 steps shown.

[0146] Step 1031, when there is no idle candidate position among at least two candidate positions that has not been selected, the server determines the selection priority of the at least two candidate positions.

[0147] In actual implementation, if none of the candidate positions determined through step 1023 are idle candidate positions, the server may determine the target position of the AI object according to the selection priority of the candidate positions.

[0148] The method for determining the selection priority of the candidate positions will be described. In some embodiments, referring to FIG. 7, Figure 7 is a schematic flowchart of the target position determination method provided by an embodiment of the present application. The server may also determine the selection priority of the candidate positions through the Figure 7 steps shown.

[0149] Step 201, for each candidate position, the server obtains the number of artificial intelligence objects that use the candidate position as the target position.

[0150] In actual implementation, for the determined multiple candidate positions, the server may obtain the number of AI objects that use each candidate position as the target position for pathfinding, and determine the selection priority of each candidate position based on the number.

[0151] Step 202, according to the number, determine the selection priority of the corresponding candidate position, and the selection priority has an inverse correlation with the number.

[0152] In actual implementation, for each candidate location, if the number of AI objects with this candidate location as the pathfinding target location is larger, the selection priority of the candidate location can be set to a low priority, that is, the selection priority of the candidate location is negatively correlated with the number of AI objects using this candidate location as the pathfinding target location.

[0153] Step 1032: The server selects one from at least two candidate locations as the target location of the AI object according to the selection priority.

[0154] In actual implementation, the server can determine the target location of the AI object according to the selection priorities of the candidate locations, and can select in the order from high to low selection priority.

[0155] In step 104, determine the target movement path from the starting location of the AI object to the target location, and return the target movement path to the AI object.

[0156] In actual implementation, after determining the target location of the AI object, various pathfinding algorithms can be used to perform path planning on the pathfinding path between the starting location of the AI object and the corresponding target location, determine the target movement path of the AI object, and return the found target movement path to the AI object, so that the AI object moves from the starting location to the target location along the target movement path.

[0157] In practical applications, different pathfinding algorithms have different effects when planning the pathfinding path. The server can use the A* pathfinding algorithm (A-star Algorithm), B* pathfinding algorithm (B-star Algorithm), greedy pathfinding algorithm, Dijkstra pathfinding algorithm (Dijkstra Algorithm), etc. for path planning.

[0158] Exemplarily, taking the A* pathfinding algorithm as an example, the A* pathfinding algorithm is a most effective direct search method for solving the shortest path in a static road network. Among them, the formula for the pathfinding cost corresponding to the A* pathfinding algorithm is expressed as:

[0159] f(n) = g(n) + h(n) Formula (1)

[0160] Among them, f(n) is the estimated distance from the starting point via the intermediate point n to the end point, g(n) is the actual distance from the starting point to the intermediate point n, and h(n) is the estimated distance from the intermediate point n to the end point.

[0161] In some embodiments, refer to Figure 8 , Figure 8 is a schematic diagram of the method for determining the target movement path provided by the embodiments of the present application. Based on Figure 3, step 104 can be implemented through steps 1041a to 1045a.

[0162] Step 1041a, the server determines multiple candidate paths from the starting position corresponding to the artificial intelligence object to the target position corresponding to the virtual object.

[0163] In actual implementation, there can be multiple candidate paths from the starting position of the AI object to the target position of the virtual object. Among them, each candidate path includes multiple road segments. When performing path planning, it starts from the starting position and calculates the consumption of each possible road segment (which can be called the road segment consumption) in sequence, and selects the road segment with the smallest road segment consumption as the constituent road segment of the target movement path.

[0164] Step 1042a, for each candidate path including multiple road segments, obtain the number of objects in each road segment included in the candidate path and the path consumption of each road segment.

[0165] In actual implementation, in order to avoid obvious congestion on each road segment at the same moment or in the same time period and reduce the path finding time of each AI object, when selecting possible road segments, the number of objects on each road segment and the path consumption of each road segment can be used as reference indicators for road segment selection.

[0166] Step 1043a, based on the number of objects in each road segment, determine the weight of the corresponding road segment.

[0167] In actual implementation, the server obtains the number of objects on each road segment and sets weights for the corresponding road segments according to the number of objects. That is, a higher weight is set for the road segment with a large number of objects. In this way, when a new AI object performs path finding, it can avoid the road segments with higher weights and instead select the road segments with lower weights. In this way, the path consumption can be reduced.

[0168] Step 1044a, based on the path consumption of each road segment included in each candidate path and the weight of the corresponding road segment, determine the path consumption of each candidate path.

[0169] In actual implementation, the server can determine the path consumption of the path according to the path consumption of each road segment and the weight of the corresponding road segment.

[0170] In some embodiments, refer to Figure 9 , Figure 9 is a schematic diagram of the method for determining path consumption provided by the embodiments of the present application. Based on Figure 8 , step 1044 can implement the determination of the path consumption of each candidate path through steps 301 to 303.

[0171] Step 301, the server obtains the initial path consumption of each road segment included in the candidate path and the influence coefficient of each road segment.

[0172] In actual implementation, the server can use a pathfinding algorithm (A* pathfinding algorithm) to determine the initial path cost of each road segment and the influence coefficient of each road segment. Among them, the initial path cost can be regarded as the path cost without considering the number of objects on the current road segment, and the influence coefficient of each road segment is a number greater than 1 to reduce the influence of the heuristic term in the A* algorithm.

[0173] Step 302, for each road segment, multiply the initial path cost, the corresponding weight, and the influence coefficient to obtain the path cost of each road segment.

[0174] In actual implementation, the server can multiply the initial path cost, the corresponding weight, and the influence coefficient to obtain the path cost corresponding to each road segment. Among them, the weight of the road segment is positively correlated with the number of AI objects on the current road segment (i.e., the occupancy of the current road segment), that is, the more AI objects on the current road segment, the higher the weight of the current road segment, and the lower the probability that the current road segment is selected by the next AI object.

[0175] Step 303, perform a summation process on the path costs of the road segments included in the candidate path to obtain the path cost of the candidate path.

[0176] In actual implementation, sum the path costs of the road segments included in the candidate path to determine the path cost (total cost) of the candidate path. It can be determined from the above steps 301 to 303 that the path cost of each road segment is equal to the result of multiplying the initial path cost, the corresponding weight, and the influence coefficient of each road segment, and the path cost of the candidate path is the result of adding the path costs of each road segment.

[0177] In some embodiments, the server can also determine the path cost of the candidate path in the following manner: The server obtains the additional path cost of each candidate path; for each candidate path, add the result of the summation process to the additional path cost of the corresponding candidate path to obtain the path cost of the candidate path.

[0178] In actual implementation, when the server uses the pathfinding algorithm for pathfinding, some additional path costs will also be generated. At this time, the path cost obtained in step 303 can be added to the additional path cost to obtain the final cost of the candidate path.

[0179] Step 1045a, based on the path costs of the candidate paths, select a target movement path from multiple candidate paths.

[0180] In some embodiments, the server can determine the target movement path in the following manner: The server selects the candidate path with the minimum path cost from multiple candidate paths as the target movement path.

[0181] In actual implementation, when the path costs of each candidate path are obtained, the candidate path with the minimum path cost value can be directly selected as the target movement path of the AI object.

[0182] In some other embodiments, the server can also determine the target movement path in the following manner: The server compares the path costs of each candidate path with a consumption threshold respectively; when the comparison result indicates that there is a candidate path with a path cost less than the consumption threshold, a candidate path is randomly selected from the candidate paths with path costs less than the consumption threshold as the target movement path.

[0183] In actual implementation, a consumption threshold corresponding to the path cost can be set, and the path costs of each candidate path are compared with the consumption threshold, and a candidate path is randomly selected from the candidate paths with path costs less than the consumption threshold as the target movement path.

[0184] In some embodiments, refer to Figure 10 , Figure 10 is a schematic diagram of the method for determining the target movement path provided by the embodiments of the present application. Based on Figure 3 , step 104 can be implemented through steps 1041b to 1044b.

[0185] Step 1041b, the server generates a navigation mesh corresponding to the virtual scene, and each sub-navigation mesh in the navigation mesh is a convex polygon;

[0186] In actual implementation, the pathfinding process can be divided into two stages. The first stage is to generate navigation mesh (Navigation Mesh) data for pathfinding according to the virtual scene (such as a game scene); the second stage is to perform pathfinding based on the navigation mesh data generated in the first stage.

[0187] Explaining the navigation mesh data, the navigation mesh data is a polygon mesh data structure used for navigating and pathfinding in a complex space and marking the walkable areas. Refer to Figure 11 , Figure 11 is a schematic diagram of the navigation mesh provided by the embodiments of the present application. The navigation mesh data includes the mesh data of multiple navigation meshes, and each navigation mesh can be a convex polygon (Convex Polygon, Poly Mesh). In Figure 11In it, the convex polygon is represented by a triangle formed by dotted lines. The starting point and the ending point in the same navigation grid can be reached directly; if the starting point and the ending point are in different navigation grids, the navigation grid data and a preset pathfinding algorithm (such as the A* algorithm) can be used to calculate the navigation grids to be passed through, so as to calculate the specific pathfinding path. When pathfinding on this navigation grid, first, the A* algorithm is used to search and find a path composed of convex polygons (Poly, the smallest unit on the navigation grid), and then the inflection points (Corner, the inflection points passed through when navigating on the path composed of Poly) are found on this path composed of Poly to obtain the final pathfinding path, that is, the target movement path of the AI object.

[0188] Step 1042b, in the navigation grid, obtain the starting grid corresponding to the starting position of the artificial intelligence object and the target grid corresponding to the target position of the artificial intelligence object.

[0189] In actual implementation, in the navigation grid corresponding to the virtual scene, the server determines the starting grid where the starting position of the AI object is located and the target grid (also called the ending grid) corresponding to the corresponding target position.

[0190] Step 1043b, determine the target path grids between the starting grid and the target grid, where the target path grids include at least two sub-navigation grids;

[0191] In actual implementation, when using the pathfinding algorithm to determine the target path grids between the starting grid and the target grid, it should be noted that the target path grids include multiple sub-navigation grids.

[0192] Step 1044b, determine the path points corresponding to each sub-navigation grid in the target path grids, and connect the path points in sequence to obtain the target movement path.

[0193] In actual implementation, find the inflection points (or called path points) on each sub-navigation grid in the target path grids, and connect the inflection points in sequence to obtain the target movement path of the AI object from the starting grid to the ending grid.

[0194] In some embodiments, refer to Figure 12 , Figure 12 is the schematic flowchart of the method for determining the movement speed of the AI object provided by the embodiment of the present application. Based on Figure 3 , after step 104, steps 105 to 106 can also be executed to determine the movement speed of the AI object on each section included in the target movement path.

[0195] In step 105, for at least two sections included in the target movement path, obtain the movement speed of the artificial intelligence object corresponding to each section.

[0196] In actual implementation, the target movement path consists of at least two road segments, and the server obtains the movement speeds of the AI object on each road segment so that the AI object moves on each road segment based on the corresponding movement speeds.

[0197] In some embodiments, referring to Figure 13 , Figure 13 is a schematic flowchart of the method for determining the movement speed of the corresponding road segment provided by the embodiments of the present application. For Figure 12 the steps 105 shown, determining the movement speeds of each road segment can also be achieved by executing steps 1051 to 1054, and will be described in combination with each step.

[0198] In step 1051, the server obtains the speed preference of the artificial intelligence object for the corresponding road segment. The magnitude of the speed preference is the maximum speed at which the artificial intelligence object can move along the road segment without colliding with other virtual objects in the virtual scene.

[0199] In actual implementation, obtaining the speed preference of the AI object on the current road segment, the speed preference can be regarded as a standard speed including magnitude and direction. When the AI object moves at the speed corresponding to the speed preference, it directly moves towards the target object and will not collide with other virtual objects in the virtual scene during the entire movement process.

[0200] In step 1052, at least two test speeds are assigned to the artificial intelligence object, and the test speeds are different from the speed corresponding to the speed preference.

[0201] In actual implementation, when the AI object moves along the target movement path towards the target object (or a target position within the hit radius of the target object), the movement speed adopted is tested according to the speed preference of the current road segment at regular intervals to prevent collisions with other virtual objects in the virtual scene and adjust the movement speed of the AI object at any time. In order to make the speed of the AI object on the current road segment closer to the speed preference of the current road segment without colliding with other virtual objects in the virtual scene, at least two test speeds can be obtained in real time for testing, so as to determine a test speed closer to the speed preference as the movement speed of the AI object on the current road segment.

[0202] In step 1053, speed influencing factors are obtained, and based on the speed influencing factors and the speed preference, the at least two test speeds are scored to obtain the scores of each test speed.

[0203] In actual implementation, speed influencing factors can be obtained, and taking the speed preference of the current road segment as a standard, the selected multiple test speeds are scored. Among them, the closer the test speed is to the speed preference, the higher the score.

[0204] In some embodiments, referring to Figure 14 , Figure 14 which is a schematic diagram of the method for determining speed influencing factors provided by the embodiments of the present application. The acquisition method for speed influencing factors can be implemented through the steps shown in Figure 14 , and will be described in conjunction with each step.

[0205] Step 401, the server respectively obtains the difference between the speed magnitude of each test speed and the speed magnitude of the speed preference.

[0206] In actual implementation, the server randomly obtains a preset number of test speeds of the AI object on the current road section, and determines the difference between the speed magnitude of each test speed and the speed magnitude of the speed preference of the AI object on the current road section. Each determined difference is used as one of the speed influencing factors. Without considering other speed influencing factors, the smaller the difference, the closer the speed magnitude of the test speed is to the speed magnitude of the speed preference. At this time, the score corresponding to the test speed is higher.

[0207] It should be noted that if there are no other static or dynamic obstacles (other virtual objects) in the current virtual scene, the moving speed of the AI object on the current road section can be the speed corresponding to the speed preference on the current road section.

[0208] Step 402, respectively obtain the angular deviation between the speed direction of each test speed and the speed direction corresponding to the speed preference.

[0209] In actual implementation, the server determines the angular deviation between the speed directions of the multiple test speeds obtained in step 401 and the speed direction of the speed preference of the AI object on the current road section. Each determined angular deviation is also used as one of the speed influencing factors. Without considering other speed influencing factors, the smaller the angular deviation, the closer the speed direction of the test speed is to the speed direction of the speed preference. At this time, the score corresponding to the test speed is higher.

[0210] Step 403, respectively obtain the probability of collision between the artificial intelligence object and other virtual objects in the virtual scene when moving along the corresponding road section at each test speed.

[0211] In actual implementation, the server obtains the probability of collision between the AI object and other virtual objects in the virtual scene when moving on each road section at each test speed, and uses the probability of collision as one of the speed influencing factors. Without considering other speed influencing factors, the smaller the probability of collision, the higher the score of the test speed.

[0212] And at least one of the difference obtained through step 401, the angular deviation obtained through step 402, and the probability of collision obtained through step 403 is used as the speed influencing factor.

[0213] In actual implementation, the moving speed of the AI object on the corresponding road section can be determined according to various speed influencing factors, or various speed influencing factors can be comprehensively considered to score each test speed, so as to determine the moving speed of the AI object on the corresponding road section.

[0214] In step 1054, based on each score, determine the moving speed of the artificial intelligence object on the corresponding road section.

[0215] In actual implementation, select the test speed with a high score as the moving speed of the AI object on the corresponding road section. It should be noted that without colliding with other virtual objects in the virtual scene, the speed preference of the AI object on the current road section can be directly used as the moving speed of the AI object on the current road section.

[0216] In step 106, return each moving speed to the artificial intelligence object, so that the artificial intelligence object moves on the corresponding road section based on each moving speed.

[0217] In actual implementation, the server returns the moving speeds of each road section included in the target moving path to the AI object, so that the AI object moves on the corresponding road section using each moving speed.

[0218] In some embodiments, refer to Figure 15 , Figure 15 is a schematic diagram of the decentralized movement of the AI object provided by the embodiment of the present application. When the number of artificial intelligence objects is at least two, after the server returns the target moving path corresponding to the artificial intelligence object, steps 501 to 503 can also be executed.

[0219] Step 501, when at least two artificial intelligence objects start to move along the target moving path simultaneously, obtain the speed offset angle range.

[0220] In actual implementation, when at least two AI objects move along the target moving path from the same starting position, in order to enable each AI object to move dispersedly, different speed directions can be set for each AI object, that is, the direction from the starting position to the ending position is set as the standard direction of the moving speed of the AI object. To ensure the dispersed movement of each AI object, after determining the speed magnitude of the AI object along the target moving path, the direction of the moving speed can be set. The server presets a speed offset angle range for each AI object, and the speed offset angle is used to indicate the offset angle of the speed direction of the AI object relative to the standard direction.

[0221] Step 502, divide the speed offset angle range equally according to the number of artificial intelligence objects to obtain the offset angle.

[0222] In actual implementation, at least two AI objects that track the same virtual object are assigned an offset angle within a set range, and the overall offset angle range will change as the number of AI objects at the same time increases. The influence of the offset angle on the speed direction of the movement speed of the AI object will decrease as the AI object approaches the virtual object. In this way, it can effectively prevent the situation where the target is within reach but the AI object always circles around.

[0223] Exemplarily, the server sets the speed offset angle range to [-30, 30]. When there are 4 AI objects moving towards the virtual object at the same time, after determining the magnitudes of the movement speeds of each AI object, the 60° offset angle from [-30, 30] can be evenly distributed to the 4 AI objects. Taking the direction in which the AI object points to the virtual object as the standard direction corresponding to the speed preference, for the 4 AI objects, their respective corresponding speed offset angles are obtained, that is, an offset of -30° relative to the standard direction, an offset of -15° relative to the standard direction, an offset of 15° relative to the standard direction, and an offset of 30° relative to the standard direction.

[0224] Step 503: Determine the target movement speeds of each artificial intelligence object according to the offset angle and the magnitude of the movement speed of each artificial intelligence object, so that each artificial intelligence object moves dispersedly at the corresponding target movement speed.

[0225] In actual implementation, after evenly dividing the offset angle range, the offset angles corresponding to each AI object are obtained, and the movement speeds of each AI object are controlled to perform an offset of the corresponding offset angle, so as to obtain the movement speeds suitable for each section included in the target movement path.

[0226] In the embodiment of the present application, through the path finding request carrying the offset radius sent by the AI object, the target positions of each AI object within the target area centered on the virtual object with the offset radius as the area radius are determined. In this way, the target positions for the AI object to find the path can be dynamically allocated, and in the virtual scene, according to the number of AI objects, the path weights can be dynamically planned. In this way, the target movement path with the lowest path consumption from the starting position to the target position of the AI object can be determined. At the same time, after determining the target movement path of the AI object, through the speed influencing factors, multiple test speeds for each section included in the target movement path are scored to obtain the target speed corresponding to each section. In this way, the AI object can move along the target movement path at a speed close to the speed preference, and can reduce the probability of collision with other virtual objects in the virtual scene, and can ensure the dispersed movement of each AI object.

[0227] Next, an exemplary application of the embodiment of the present application in an actual application scenario will be described.

[0228] First, before describing the pathfinding method provided by the embodiments of the present application, relevant nouns and terms used later are explained.

[0229] 1) Recast&Detour: An open-source AI pathfinding algorithm library that follows the zlib protocol. The AI pathfinding algorithms in common commercial game engines such as Unity and UE4 are currently based on this open-source library.

[0230] 2) Game AI: A general term for non-player controlled units in a game, including monsters, NPCs, intelligent objects, etc. in the game.

[0231] 3) AI pathfinding algorithm: In a game, when an AI hopes to move from point A to point B, the pathfinding algorithm plans a fixed path for it, usually returning a set of navigation patch sequences or point sequences to represent this path.

[0232] 4) NavLink: A passage connecting different surfaces in the navigation mesh constructed by Recast, which can be used as a path for AI movement.

[0233] After the pathfinding algorithm in the relevant game engine is given the starting and ending positions of pathfinding, and when the game scene does not change, generally, based on the navigation mesh information pre-generated in the game scene, a fixed shortest path between the starting point and the ending point is calculated through the pathfinding algorithm (such as the A* algorithm). Subsequently, the AI object will configure its speed, acceleration, etc. according to the movement rules that suit its own conditions and move along this fixed path.

[0234] From the above description, it can be seen that when monsters born from the same spawn point chase the same target point (usually the player), the paths returned by the pathfinding algorithms in the relevant game engines are uniquely determined. When multiple AI objects (such as monsters) want to walk the same path, it will inevitably lead to congestion or queuing. Even if the roads arranged in the level are very wide, all AI objects will still crowd onto one line and move forward, showing a very unnatural performance.

[0235] Based on this, the embodiments of the present application propose the following pathfinding method in the game scene for the above problems: First, when multiple AI objects gather to attack the virtual object controlled by the player, avoid setting the same pathfinding target point; Second, by dynamically allocating the path weights of the AI object's movement, affect the return results of the A* algorithm at different times, so that the AI object selects different paths; Finally, during the process of the AI object moving along the planned path, by allocating different speed trends (including magnitude and direction) to the AI object, the goal of scattered movement is achieved. Through the pathfinding method provided by the embodiments of the present application, the pathfinding of AI objects can be made as scattered as possible, avoiding congestion or queuing.

[0236] In actual implementation, to avoid setting consistent pathfinding target points, it can be achieved by dispersing the pathfinding target points of AI objects. The specific implementation method can be to add a radius parameter (also called offset radius) to the native pathfinding request. This radius parameter is used to specify the random offset radius of the actual pathfinding target point of the AI object. And add a global pathfinding data component (global NavLink component) to record the occupancy of the pathfinding path. This data component can count the number of people occupying each pathfinding path (NavLink) in real time, and use the number of occupied people as a calculation parameter for pathfinding consumption during actual operation.

[0237] Exemplarily, Figures 16A - 16B is a schematic diagram of AI object dispersed pathfinding provided by an embodiment of the present application. Refer to Figure 16A In it, when no dynamic weights are set for each pathfinding path, when multiple AI objects gather together to pathfind towards the target, they all concentrate at the middle Navlink, and situations such as queuing and crowding are likely to occur. Refer to Figure 16B By calculating the number of people occupying each pathfinding path in real time and using the number of occupied people as a calculation parameter for pathfinding consumption, after adding dynamic weights to each NavLink, all AI objects can disperse to the pre-baked 5 NavLinks and will not queue at the nearest middle Navlink.

[0238] In addition, in actual implementation, a global third-party system (such as the Flank system) can also be added to modify the pathfinding speed preference of AI objects. The third-party system mainly includes the following configurations: Refer to Figure 17 , Figure 17 is a schematic diagram of the pathfinding speed preference setting interface provided by an embodiment of the present application. In the figure, the Flank ing Angle Weight Curve is a configuration item of the "angle weight curve" (related to distance) provided by the Flank system. The input curve corresponding to this configuration item has the horizontal axis representing distance and the vertical axis representing the weight coefficient of the influence of the offset angle (Ar cAngle) on speed offset; as an example, refer to Figure 18A , Figure 18A is a schematic diagram of the influence of the offset angle on speed offset provided by an embodiment of the present application. In the figure, multiple AI objects (monsters) start to disperse and move within 30m. Among them, after 5m, the moving speeds of each AI object are not affected by ArcAngle. Figure 17The Flank Angel Default Curve in Chinese is a configuration item of the "angle range curve" provided by the Flank system (related to the number of AI objects), which is used to reflect the change of the overall offset angle (ArcAngle) range with the total number of AI objects (such as monsters). The horizontal axis represents the number of AI objects (such as monsters), and the vertical axis represents the total offset angle bisected by these AI objects (such as monsters); for example, see Figure 18B , in the figure, 6 AI objects track the player simultaneously to reach the maximum angle, and the offset angle range is [-30°, 30°]. Figure 17 The AI Flanking Angel Config in Chinese is other configuration items provided by the Flank system, which can be used to support more refined configuration tables and configure the default configurations of the above two curves, namely the angle weight curve and the angle range curve, for different types of AI objects (such as monsters) respectively. Figure 17 The Angle Weight Update Interval in Chinese is a configuration item of the "angle update interval" provided by the Flank system. The direction corresponding to the moving speed shown in the figure is offset by the angle every 0.1 second.

[0239] In actual implementation, Figures 19A - 19B is a schematic diagram of the change in the overall pathfinding method of the AI object provided by the embodiment of the present application. Through the above three custom modifications, it is finally possible to change the overall pathfinding movement method of the AI object from Figure 19A to Figure 19B .

[0240] In actual implementation, see Figure 20 , Figure 20 is a flowchart of the pathfinding method for AI objects provided in the related art. The pathfinding framework shown in the figure can be divided into three stages: pathfinding request, path planning, and pathfinding implementation. The pathfinding method provided by the embodiment of the present application is optimized based on Figure 20 shown in the pathfinding process.

[0241] First, the optimization method for the pathfinding request in the first stage is described. The pathfinding method provided by the embodiment of the present application introduces a strategy of decentralized point selection in the stage of the AI object sending a pathfinding request. When the incoming pathfinding target is a specific object (a virtual object controlled by a player), the decentralized point selection strategy is adopted. The server counts the number of AI objects targeting the current virtual object and distributes the actual pathfinding end points into eight quadrants around the current virtual object. For example, see Figure 21 , Figure 21It is a schematic diagram of the decentralized point selection strategy provided by the embodiments of the present application. In the figure, the actual end points corresponding to the AI objects are polled and stuffed into the eight quadrants of the world coordinate system of the target player. The actual end point positions corresponding to the AI objects satisfy two conditions: (1) The distance from the actual end point to the player needs to be less than the hit radius of the player; (2) The line segment formed by the starting point and the actual end point of the AI object needs to be on the same side of the player, that is, there should be no path passing through the target player.

[0242] Secondly, the optimization method for the path planning in the second stage will be described. In the pathfinding method provided by the embodiments of the present application, the optimized A* algorithm is used in the path planning stage. The path cost calculation item in the A* algorithm is mainly optimized. The specific path cost function is as follows:

[0243] NewAreaCost = OldAreaCost * OccupiedNum * Factor + EnterCost

[0244] Among them, NewAreaCost is the path cost determined by the improved A* algorithm, OldAreaCost is the path cost of the native A* algorithm, OccupiedNum is the number of people occupying the Navlink, Factor is the influence coefficient, and EnterCost can be regarded as other path costs of the native A* algorithm.

[0245] In actual implementation, when calculating the pathfinding cost NewAreaCost for each pathfinding path, by judging whether the path is a Navlink (i.e., a line segment path), if so, the number of people OccupiedNum of the current Navlink is read through the global data component (Navlink component) and multiplied by the influence coefficient Factor, and this coefficient is a number greater than 1 to reduce the influence of the heuristic term in the A* algorithm, so that the pathfinding algorithm can use more Navlink nodes as calculation nodes during the calculation process.

[0246] Thirdly, the optimization method for the path implementation in the third stage will be described. Refer to Figure 22A, Figure 22A is a schematic diagram of speed test provided in the related art. In the figure, during the path implementation phase, the Recast system constructs a preset number (such as 10) of test speeds with different magnitudes and directions. Among them, the test speed V0 represents the current speed preference of the AI object. By default in the native Recast, V0 points to the next pathfinding point. When the AI object does not collide with the dynamic objects in the virtual scene (game scene), V0 is usually the optimal speed, that is, the AI object will choose the speed pointing to the next path point to move. The optimization method for the path implementation phase provided by the embodiments of the present application can achieve the goal of changing the actual moving direction of the AI object by adding a differential offset angle to V0 of different AI objects. As an example, see Figure 22B. Figure 22B is a schematic diagram of the speed preference of the AI object provided by the embodiments of the present application. In the figure, the AI object moves along an arc towards the target object, so as to prevent collisions with dynamic objects in the virtual scene.

[0247] In addition, during actual implementation, the pathfinding method provided by the embodiments of the present application can allocate an offset angle (ArcAngle) within a set range for the same type of AI objects (such as monsters) that track the same target. It should be noted that the overall offset angle range will change with the increase in the number of AI objects at the same time. The influence of ArcAngle on the speed direction will decrease as the AI object approaches the player, so as to effectively prevent the situation where the target object (player) is close at hand but the AI object always circles around.

[0248] The pathfinding method provided by the embodiments of the present application is an optimization of the related pathfinding algorithm (Recast&Detour). Through the pathfinding method provided by the embodiments of the present application, the diversity of pathfinding of AI objects (monsters) in the PVE mode can be increased, and abnormal situations such as congestion and queuing can be prevented when the number of AI objects in the virtual scene (game scene) increases. The pathfinding method provided by the embodiments of the present application is optimized in three stages: early target selection, path planning, and path implementation. In this way, on the basis of ensuring the efficiency of the pathfinding algorithm, a more natural and diverse moving performance of the AI object can be obtained through the dynamic parameter configuration in the virtual scene.

[0249] In actual implementation, the dynamic allocation of the navigation patch weight can also be performed according to the density of AI objects in a virtual scenario (such as a game). In this way, it is possible to avoid the areas where AI objects gather at the path planning level, preventing problems such as extrusion caused by multiple AI objects sharing the same path. In actual implementation, for the irregularity of the triangular navigation mesh generated by related technologies, in some corner areas, especially in narrow patch areas, it may lead to abnormal paths and the problem of getting AI objects stuck. This problem can be solved by normalizing the mesh or adding a regular weighted overlay area to ensure the normal movement of AI objects in the corner area.

[0250] Applying the embodiments of the present application can make the pathfinding method of AI objects in the virtual scenario more diverse, avoiding the common problems of aggregation, pushing, and queuing in related PVE games. The pathfinding method provided by the embodiments of the present application dynamically allocates the pathfinding target end point of the AI object according to the input configuration, and automatically performs dynamic planning of the path weight according to the number of AI objects (pathfinding density) performing pathfinding in the current entire virtual scenario. Finally, a relatively simple configuration method for the speed offset factor is provided, and different movement speed preferences can be formulated for different types of AI objects in the virtual scenario.

[0251] It can be understood that in the embodiments of the present application, data related to user information, etc. is involved. When the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of related data need to comply with the relevant laws, regulations, and standards of relevant countries and regions.

[0252] Next, the implementation of the pathfinding device 555 in the virtual scenario provided by the embodiments of the present application as a software module will be further described. In some embodiments, as Figure 2 shown, the software module in the pathfinding device 555 in the virtual scenario stored in the memory 550 may include:

[0253] A response module 5551, configured to obtain the offset radius of the target position of the artificial intelligence object relative to the position of the virtual object in response to a pathfinding request of the artificial intelligence object for the virtual object in the virtual scenario;

[0254] An acquisition module 5552, configured to determine a target area centered on the virtual object with the offset radius as the area radius, and acquire at least two candidate positions within the target area;

[0255] A selection module 5553, configured to select the target position corresponding to the artificial intelligence object from the at least two candidate positions;

[0256] A determination module 5554 is configured to determine a target movement path from the starting position of the artificial intelligence object to the target position, and return the target movement path to the artificial intelligence object.

[0257] In some embodiments, the response module is further configured to, when there is at least one unselected idle candidate position among the at least two candidate positions, select one from the at least one idle candidate position as the target position of the artificial intelligence object; when there is no unselected idle candidate position among the at least two candidate positions, determine the selection priority of the at least two candidate positions, and select one from the at least two candidate positions as the target position of the artificial intelligence object according to the selection priority.

[0258] In some embodiments, the response module is further configured to, for each of the candidate positions, obtain the number of artificial intelligence objects with the candidate position as the target position; determine the selection priority of the corresponding candidate position according to the number, and the selection priority has a negative correlation with the number.

[0259] In some embodiments, the acquisition module is further configured to determine a plurality of scattered positions within the target area; establish a coordinate system with the position of the virtual object as the origin according to the map of the virtual scene; determine at least two of the plurality of scattered positions that are between the artificial intelligence object and the plane where the vertical axis of the coordinate system is located as the candidate positions.

[0260] In some embodiments, the determination module is further configured to determine multiple candidate paths from the starting position corresponding to the artificial intelligence object to the target position corresponding to the virtual object; for each of the candidate paths including multiple road segments, obtain the number of objects in each road segment included in the candidate path and the path consumption of each road segment; determine the weight of the corresponding road segment based on the number of objects in each road segment; determine the path consumption of each candidate path based on the path consumption of each road segment included in each candidate path and the weight of the corresponding road segment, and select the target movement path from the multiple candidate paths based on the path consumption of each candidate path.

[0261] In some embodiments, the determination module is further configured to perform the following processing for each of the candidate paths: obtain the initial path consumption of each road segment included in the candidate path and the influence coefficient of each road segment; for each road segment, perform a multiplication process on the initial path consumption, the corresponding weight, and the influence coefficient to obtain the path consumption of each road segment; perform a summation process on the path consumption of each road segment included in the candidate path to obtain the path consumption of the candidate path.

[0262] In some embodiments, the determining module is further configured to obtain the additional path consumption of each of the candidate paths; for each of the candidate paths, add the result of the summing process to the additional path consumption of the corresponding candidate path to obtain the path consumption of the candidate path.

[0263] In some embodiments, the determining module is further configured to select, from the multiple candidate paths, the candidate path with the minimum path consumption as the target movement path; or, compare the path consumption of each of the candidate paths with a consumption threshold respectively, and when the comparison result indicates that there is a candidate path with a path consumption less than the consumption threshold, randomly select one of the candidate paths with a path consumption less than the consumption threshold as the target movement path.

[0264] In some embodiments, the determining module is further configured to, for at least two road segments included in the target movement path, obtain the movement speed of the artificial intelligence object corresponding to each of the road segments; return each of the movement speeds to the artificial intelligence object, so that the artificial intelligence object moves on the corresponding road segment based on each of the movement speeds.

[0265] In some embodiments, the determining module is further configured to, for each of the road segments, perform the following processing: obtain the speed preference of the artificial intelligence object corresponding to the road segment, where the magnitude of the speed preference is the maximum speed at which the artificial intelligence object can move along the road segment without colliding with other virtual objects in the virtual scene; allocate at least two test speeds to the artificial intelligence object, where the test speeds are different from the speed corresponding to the speed preference; obtain speed influencing factors, and score the at least two test speeds based on the speed influencing factors and the speed preference to obtain the scores of each of the test speeds; determine the movement speed of the artificial intelligence object corresponding to the road segment based on each of the scores.

[0266] In some embodiments, the determining module is further configured to respectively obtain the difference between the magnitude of each of the test speeds and the magnitude of the speed preference; respectively obtain the angular deviation between the speed direction of each of the test speeds and the speed direction corresponding to the speed preference; respectively obtain the probability that the artificial intelligence object collides with other virtual objects in the virtual scene when moving along the corresponding road segment at each of the test speeds; use at least one of the difference, the angular deviation, and the probability as the speed influencing factor.

[0267] In some embodiments, when the number of the artificial intelligence objects is at least two, the determining module is further configured to, when at least two of the artificial intelligence objects start to move along the target movement path simultaneously, obtain a speed offset angle range; divide the speed offset angle range equally by the number according to the number of the artificial intelligence objects to obtain an offset angle; and determine the target movement speed of each of the artificial intelligence objects according to the offset angle and the magnitude of the movement speed of each of the artificial intelligence objects, so that each of the artificial intelligence objects dispersedly moves at the corresponding target movement speed.

[0268] In some embodiments, the determining module is further configured to generate a navigation grid corresponding to the virtual scene, where each sub-navigation grid in the navigation grid is a convex polygon; in the navigation grid, obtain a starting grid corresponding to the starting position of the artificial intelligence object and a target grid corresponding to the target position of the artificial intelligence object; determine a target path grid between the starting grid and the target grid, where the target path grid includes at least two of the sub-navigation grids; determine path points corresponding to each of the sub-navigation grids in the target path grid, and sequentially connect the path points to obtain a target movement path.

[0269] An embodiment of the present application provides a computer program product or a computer program, where the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the path finding method in the virtual scene in the embodiment of the present application.

[0270] An embodiment of the present application provides a computer-readable storage medium storing executable instructions, where the executable instructions are stored, and when the executable instructions are executed by a processor, the processor is caused to execute the path finding method in the virtual scene provided in the embodiment of the present application. For example, as Figure 3 shown in the path finding method in the virtual scene.

[0271] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disc, or CD-ROM; or may be various devices including one or any combination of the above memories.

[0272] In some embodiments, the executable instructions may be in the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including being deployed as a stand-alone program or being deployed as a module, component, subroutine, or other unit suitable for use in a computing environment.

[0273] As an example, the executable instructions may or may not correspond to a file in the file system, may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, stored in a single file dedicated to the program being discussed, or, stored in multiple cooperating files (such as files that store one or more modules, subroutines, or portions of code).

[0274] As an example, the executable instructions may be deployed to execute on one computing device, or on multiple computing devices located at one location, or, on multiple computing devices distributed across multiple locations and interconnected by a communication network.

[0275] In summary, through the embodiments of the present application, the target position of AI object pathfinding can be dynamically allocated, and in a virtual scene, according to the number of AI objects, the path weights can be dynamically planned. In this way, the target movement path with the lowest path consumption from the starting position to the target position of the AI object can be determined. At the same time, after determining the target movement path of the AI object, by the speed influencing factors, scores are given to multiple test speeds for each section included in the target movement path to obtain the target speed corresponding to each section. In this way, the AI object can move along the target movement path at a speed close to the speed preference, and the probability of collision with other virtual objects in the virtual scene can be reduced, and the scattered movement of each AI object can be ensured.

[0276] The above is only the embodiments of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent replacements, and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims

1. A pathfinding method in a virtual scenario, characterized in that, The method includes: In response to a pathfinding request of an artificial intelligence object for a virtual object in a virtual scene, obtaining an offset radius of the target position of the artificial intelligence object relative to the position of the virtual object, where the offset radius is determined based on the attributes of the artificial intelligence object, and the attributes of the artificial intelligence object include at least one of the following: the category of the artificial intelligence object, the damage level, the number of the artificial intelligence objects; Determining a target area centered on the virtual object with the offset radius as the area radius, and determining a plurality of scattered positions within the target area; Establishing a coordinate system with the position of the virtual object as the origin according to the map of the virtual scene; Selecting at least two candidate positions from at least two of the scattered positions that are between the artificial intelligence object and the plane where the vertical axis of the coordinate system is located; Selecting a target position corresponding to the artificial intelligence object from the at least two candidate positions; Determining a target movement path from the starting position of the artificial intelligence object to the target position, and returning the target movement path to the artificial intelligence object; Performing the following processing for each section of the target movement path: obtaining the speed preference of the artificial intelligence object corresponding to the section, where the magnitude of the speed preference is the maximum speed at which the artificial intelligence object can move along the section without colliding with other virtual objects in the virtual scene; Assigning at least two test speeds to the artificial intelligence object, where the test speeds are different from the speed corresponding to the speed preference; Obtaining speed influencing factors, and scoring the at least two test speeds based on the speed influencing factors and the speed preference to obtain the scores of the test speeds, and determining the movement speed of the artificial intelligence object corresponding to the section based on the scores; Returning the movement speeds of the sections to the artificial intelligence object, so that the artificial intelligence object moves along the corresponding sections based on the movement speeds of the sections.

2. The method according to claim 1, wherein The selecting a target position corresponding to the artificial intelligence object from the at least two candidate positions includes: When there is at least one idle candidate position that has not been selected among the at least two candidate positions, selecting one from the at least one idle candidate position as the target position of the artificial intelligence object; When there is no idle candidate position that has not been selected among the at least two candidate positions, determining the selection priorities of the at least two candidate positions, and selecting one from the at least two candidate positions as the target position of the artificial intelligence object according to the selection priorities.

3. The method according to claim 2, wherein The determining the selection priorities of the at least two candidate positions includes: For each candidate position, obtaining the number of artificial intelligence objects taking the candidate position as the target position; According to the number, determining the selection priority of the corresponding candidate position, where the selection priority is negatively correlated with the number.

4. The method according to claim 1, wherein The determining a target movement path from the starting position of the artificial intelligence object to the target position includes: Determine multiple candidate paths from the starting position corresponding to the artificial intelligence object to the target position corresponding to the virtual object; For each of the candidate paths including multiple road segments, obtain the number of objects in each road segment included in the candidate path and the path consumption of each road segment; Based on the number of objects in each road segment, determine the weight of the corresponding road segment; Based on the path consumption of each road segment included in each candidate path and the weight of the corresponding road segment, determine the path consumption of each candidate path, and based on the path consumption of each candidate path, select the target movement path from the multiple candidate paths.

5. The method according to claim 4, wherein The determining the path consumption of each candidate path based on the path consumption of each road segment included in each candidate path and the weight of the corresponding road segment includes: Perform the following processing for each candidate path respectively: Obtain the initial path consumption of each road segment included in the candidate path and the influence coefficient of each road segment; For each road segment, perform a multiplication process on the initial path consumption, the corresponding weight, and the influence coefficient to obtain the path consumption of each road segment; Perform a summation process on the path consumption of each road segment included in the candidate path to obtain the path consumption of the candidate path.

6. The method according to claim 5, wherein The performing a summation process on the path consumption of each road segment included in the candidate path to obtain the path consumption of the candidate path includes: Obtain the additional path consumption of each candidate path; For each candidate path, add the result of performing the summation process to the additional path consumption of the corresponding candidate path to obtain the path consumption of the candidate path.

7. The method according to claim 4, wherein The selecting the target movement path from the multiple candidate paths based on the path consumption of each candidate path includes: From the multiple candidate paths, select the candidate path with the minimum path consumption as the target movement path; Or, Compare the path consumption of each candidate path with a consumption threshold respectively, and when the comparison result indicates that there is a candidate path with a path consumption less than the consumption threshold, randomly select one of the candidate paths with a path consumption less than the consumption threshold as the target movement path.

8. The method according to claim 1, wherein Obtain speed influencing factors, including: Respectively obtain the difference between the speed magnitude of each test speed and the speed magnitude of the speed preference; Respectively obtain the angular deviation between the speed direction of each test speed and the speed direction corresponding to the speed preference; Respectively obtain the probability of collision with other virtual objects in the virtual scene when the artificial intelligence object moves along the corresponding road segment at each test speed; Use at least one of the difference, the angular deviation, and the probability as the speed influencing factor.

9. The method according to claim 1, wherein When the number of artificial intelligence objects is at least two, after returning the target movement path to the artificial intelligence objects, the method further includes: When at least two artificial intelligence objects start to move along the target movement path simultaneously, obtain the speed offset angle range; According to the number of artificial intelligence objects, evenly divide the speed offset angle range by the number to obtain the offset angle; Determine the target moving speed of each of the artificial intelligence objects according to the offset angle and the magnitude of the moving speed of each of the artificial intelligence objects, so that each of the artificial intelligence objects moves dispersedly at the corresponding target moving speed.

10. The method according to claim 1, characterized in that, The determining the target moving path from the starting position of the artificial intelligence object to the target position includes: Generate a navigation grid corresponding to the virtual scene, where each sub-navigation grid in the navigation grid is a convex polygon; In the navigation grid, obtain the starting grid corresponding to the starting position of the artificial intelligence object and the target grid corresponding to the target position of the artificial intelligence object; Determine the target path grid between the starting grid and the target grid, where the target path grid includes at least two of the sub-navigation grids; Determine the path points corresponding to each of the sub-navigation grids in the target path grid, and connect the path points in sequence to obtain the target moving path.

11. A pathfinding device in a virtual scenario, characterized in that, The device includes: A response module, configured to, in response to a path finding request of an artificial intelligence object in a virtual scene for a virtual object, obtain an offset radius of the target position of the artificial intelligence object relative to the position of the virtual object, where the offset radius is determined based on the attributes of the artificial intelligence object, and the attributes of the artificial intelligence object include at least one of the following: the category of the artificial intelligence object, the damage level, the number of the artificial intelligence objects; An acquisition module, configured to determine a target area centered on the virtual object with the offset radius as the area radius, and determine a plurality of scattered positions within the target area; establish a coordinate system with the position of the virtual object as the origin according to the map of the virtual scene; screen at least two candidate positions from at least two of the scattered positions that are between the artificial intelligence object and the plane where the vertical axis of the coordinate system is located; A selection module, configured to select the target position corresponding to the artificial intelligence object from the at least two candidate positions; A determination module, configured to determine the target moving path from the starting position of the artificial intelligence object to the target position, and return the target moving path to the artificial intelligence object; Perform the following processing on each section of the target moving path respectively: obtain the speed preference of the artificial intelligence object corresponding to the section, where the magnitude of the speed preference is the maximum speed at which the artificial intelligence object can move along the section without colliding with other virtual objects in the virtual scene; Allocate at least two test speeds to the artificial intelligence object, where the test speeds are different from the speed corresponding to the speed preference; obtain speed influencing factors, and score the at least two test speeds based on the speed influencing factors and the speed preference to obtain the scores of the test speeds, and determine the moving speed of the artificial intelligence object corresponding to the section based on the scores; Return the moving speeds of the sections to the artificial intelligence object, so that the artificial intelligence object moves on the corresponding sections based on the moving speeds of the sections.

12. An electronic device, characterized in that, The electronic device includes: A memory for storing executable instructions; A processor for implementing the pathfinding method in the virtual scenario according to any one of claims 1 to 10 when executing the executable instructions stored in the memory.

13. A computer-readable storage medium stores executable instructions, characterized in that, The executable instructions, when executed by the processor, implement the pathfinding method in the virtual scenario according to any one of claims 1 to 10.

14. A computer program product comprising a computer program or instructions, characterized in that, The computer program or instructions, when executed by the processor, implement the pathfinding method in the virtual scenario according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Method and device for controlling objects

    CN106814966A