Non-player character control method and device, storage medium and electronic device
By generating multiple alternative movement directions that match the outline of the virtual cover, and combining them with the movement history of real player characters, the movement direction of NPCs is adjusted in real time, which solves the problem of insufficient intelligence and anthropomorphism of NPCs and improves the game experience and smoothness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2023-03-13
- Publication Date
- 2026-05-29
AI Technical Summary
In existing technologies, non-player characters (NPCs) cannot make full use of virtual items and terrain in games, resulting in low intelligence and anthropomorphism, which affects the player's gaming experience.
By generating multiple alternative movement directions that match the outline of the virtual cover, and adjusting the NPC's movement direction in real time based on the historical movement direction and current position of the real player character, intelligent dodging and human-like behavior can be achieved.
It improves the intelligence and anthropomorphism of NPCs, enhances the smoothness of the game and the player's gaming experience, while reducing the consumption of computing resources and the difficulty of development.
Smart Images

Figure CN116271831B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of game technology, and more particularly to a method for controlling a non-player character, a control device for a non-player character, a computer storage medium, and an electronic device. Background Technology
[0002] In current online games, such as Multiplayer Online Battle Arena (MOBA) and chase / escape games, non-player characters (NPCs) or artificial intelligence players (AIs) are often added to advance the game's plot or reduce matchmaking time. These NPCs or AIs are game characters not controlled by real players and can be of any type. For example, in a chase / escape game, the player controls the pursuer, and the NPC is the survivor. The player wins or receives rewards by hunting down the NPC.
[0003] Currently, when NPCs encounter obstacles while escaping in games, they typically move clockwise or counterclockwise around the edge of the obstacle according to pre-set rules. However, in this technical solution, the NPCs cannot fully utilize various virtual props and terrain to engage in strategic gameplay with the player-controlled character, resulting in a low level of intelligence and anthropomorphism in controlling the NPCs.
[0004] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0005] This disclosure provides a method for controlling a non-player character, a control device for a non-player character, a computer storage medium, and an electronic device, thereby enabling the non-player character to behave similarly to a player-controlled character, improving the intelligence and anthropomorphism of non-player character control.
[0006] In a first aspect, one embodiment of this disclosure provides a method for controlling a non-player character. The method includes: in response to the non-player character's current position in a game scene being less than a first preset distance from a target virtual cover, generating a plurality of preset movement directions corresponding to the current position based on the edge contour of the target virtual cover; determining a first movement direction of the target virtual character at the current moment based on the target virtual character's historical movement direction when chasing the non-player character; in response to the non-player character being within the target virtual character's field of vision, determining the movement direction with the smallest angle to the first movement direction among the plurality of preset movement directions as the non-player character's second movement direction; and controlling the non-player character to move according to the second movement direction.
[0007] Secondly, one embodiment of this disclosure provides a control device for a non-player character. The device includes: a movement direction generation module for generating multiple preset movement directions corresponding to the current position based on the edge contour of the target virtual cover when the distance between the current position of the non-player character and the target virtual cover in the game scene is less than a first preset distance; a first direction determination module for determining the first movement direction of the target virtual character at the current moment based on the historical movement directions of the target virtual character chasing the non-player character; a second direction determination module for determining the movement direction with the smallest angle to the first movement direction among the multiple preset movement directions as the second movement direction of the non-player character when the non-player character is within the field of vision of the target virtual character; and a character control module for controlling the non-player character to move according to the second movement direction.
[0008] Thirdly, one embodiment of this disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described method for controlling a non-player character.
[0009] Fourthly, one embodiment of this disclosure provides an electronic device, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the above-described control method for a non-player character by executing the executable instructions.
[0010] The technical solution disclosed herein has the following beneficial effects:
[0011] The aforementioned non-player character control method, on the one hand, pre-generates multiple alternative movement directions matching the current position of the AI character based on the edge contour of the virtual cover, thereby reducing the high demands on computer performance and improving the overall game performance. Furthermore, it can select from these multiple alternative movement directions based on real-time predictions of the movement direction of the player-controlled character, intelligently adjusting the AI character's movement direction in real time. This fully utilizes the terrain to control the AI character to intelligently evade pursuit by the player-controlled character. This method solves the technical problem of low intelligence and anthropomorphism in controlling NPCs or AI characters, where existing technologies only allow AI characters to move clockwise or counterclockwise around virtual cover according to preset rules. It makes the behavior of non-player characters similar to player-controlled characters, improving the intelligence and anthropomorphism of non-player character control and thus enhancing the player's gaming experience. On the other hand, compared to the long development time, high difficulty, and high computational resource consumption caused by reinforcement learning and transfer learning algorithms used in some related technologies, this method can be implemented more quickly and efficiently, significantly reducing computational resource consumption and ensuring smooth game operation.
[0012] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0013] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0014] Figure 1 This schematically illustrates a system architecture diagram of an application scenario for a control system for a non-player character in this exemplary embodiment.
[0015] Figure 2 This schematic diagram illustrates a flow chart of a control method for a non-player character in this exemplary embodiment;
[0016] Figure 3 This illustration shows a flowchart of a method for generating multiple preset movement directions corresponding to an AI character and its current position in this exemplary embodiment.
[0017] Figure 4 This schematic diagram illustrates a process for obtaining a set of path points on the edge contour of a target virtual shelter in this exemplary embodiment.
[0018] Figure 5This schematic diagram illustrates a plurality of preset movement directions for generating an AI character in this exemplary embodiment.
[0019] Figure 6 This schematic diagram illustrates a method for determining a first movement direction of a target virtual character in this exemplary embodiment.
[0020] Figure 7 This schematic diagram illustrates how a second movement direction of an AI character is determined when the AI character is outside the field of vision of a target virtual character in this exemplary embodiment.
[0021] Figure 8 This schematic diagram illustrates the determination of a second movement direction of an AI character when the AI character is within the field of vision of a target virtual character in this exemplary embodiment.
[0022] Figure 9 This schematic diagram illustrates the determination of a second movement direction of an AI character when the target virtual character has not moved, according to an exemplary embodiment of the present invention.
[0023] Figure 10 This schematic diagram illustrates the structure of a control device for a non-player character in this exemplary embodiment.
[0024] Figure 11 This schematic diagram illustrates the structure of a control device for another non-player character in this exemplary embodiment.
[0025] Figure 12 The schematic diagram illustrates the structure of an electronic device in this exemplary embodiment. Detailed Implementation
[0026] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of exemplary embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0027] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0028] The flowchart shown in the attached diagram is merely an illustrative example and does not necessarily include all steps. For example, some steps may be broken down, while others may be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0029] To help those skilled in the art better understand the technical solutions disclosed herein, the relevant content involved in the technical solutions of this application will be introduced below.
[0030] (1) Non-player character (NPC): This is a type of character in the game, referring to a game character that is not controlled by a real player. This concept originated from single-player games and has gradually been applied to other game fields. NPCs are game characters controlled by computer artificial intelligence and have their own behavior patterns. NPCs in the game are mainly divided into story NPCs and combat NPCs. Story NPCs are used to provide players with key information or trigger the plot, thereby guiding players to quickly understand the game rules or perform specific game tasks. Combat NPCs participate in the game battle at the same time as real players. Usually, in order to increase the game experience and achieve the effect of quick matchmaking in multiplayer mode, developers usually add NPCs or AI to the game to fill the numbers and reduce the waiting time for players at the start of the game.
[0031] (2) Artificial intelligence player (AI): This is a term used in the field of online e-sports. It is also known as human-machine or computer player (Computer Player / Robot Player). It refers to AI players in combat games (especially shooting games) to enhance the gaming experience of real players in multiplayer online mode. They are pseudo-intelligent controlled by game programs and are mostly used as enemies or NPC characters in the process of combat.
[0032] (3) tick (Tickrate): refers to the server refresh rate during the game. During the game, the terminal device used by the player exchanges data with the server in real time. Therefore, the larger the tick rate value, the faster the data exchange frequency between the server and the terminal device, which means the server responds faster. If the tick is slow, game lag and delay will occur.
[0033] The non-player character control method provided in this exemplary embodiment can be applied to game scenarios in any game type that includes non-player characters (NPCs) or AI characters. For example, in MOBA games, to help players quickly understand the game rules and master game skills, developers may add story-type NPC characters to guide players into the game process; or to avoid long waiting times for character matching, developers usually add NPCs or AI characters of different combat strength levels to the battle during the game.
[0034] Since the non-player character control method provided in this disclosure can be applied to any game scenario with NPC or AI characters, this disclosure uses an asymmetrical battle arena game as an example for illustrative purposes.
[0035] For example, a 1v4 chase-and-escape game scenario includes various types of virtual cover or obstacles, one virtual character (the pursuer) and four virtual characters (the survivors). At least one of the pursuer and four survivors is an NPC or AI character. In this type of game, the four survivors win by completing specific tasks while evading the pursuer; otherwise, they lose. Suppose a player-controlled pursuer is chasing an AI survivor. To prolong the pursuit as much as possible and allow the other survivors to complete their tasks, the survivor would typically move around the edge of virtual cover to achieve this effect.
[0036] Currently, controlling the movement of AI characters around virtual shelters typically involves the following two technical solutions:
[0037] In the first technical solution, the AI character moves mechanically clockwise or counterclockwise around the edge of the virtual cover according to the pre-designed program rules of the developers. This first technical solution makes it impossible for the AI character to make full use of the various types of props in the game scene and predict the escape path based on the distribution of each virtual cover. This greatly reduces the intelligence and anthropomorphism of the AI, making it easier for real players to identify the character and thus affecting the player's gaming experience.
[0038] In the second technical solution, to address the technical problem that the first solution cannot fully utilize various types of props in the game scene and predict escape paths based on the distribution of virtual cover, reinforcement learning and transfer learning can be used. However, on the one hand, this method has a long development cycle and weak generalization ability; on the other hand, it consumes huge amounts of computing resources. Therefore, with the increasingly frequent updates to game content, reinforcement learning and transfer learning methods have basically remained in the theoretical and experimental stages.
[0039] This disclosure, through exemplary embodiments, addresses the aforementioned issues and proposes a method for controlling a non-player character. This method pre-generates multiple alternative movement paths offline using the edge contours of virtual cover, thereby reducing the high demands on computer performance and improving overall game performance. Furthermore, it intelligently adjusts the AI character's movement direction in real-time by selecting from multiple alternative movement directions based on real-time predictions of the movement direction controlled by the real player. This avoids the need for developers to formulate a series of cumbersome manual rules, as required by the first technical solution, and the inability to fully utilize the distribution of virtual cover to assist the AI character in evading pursuit by the virtual character controlled by the real player. This improves the intelligence and human-likeness of non-player character control. Moreover, compared to the reinforcement learning and transfer learning algorithms of the second technical solution, this method is simpler and more efficient, significantly reducing the consumption of computing resources and ensuring smooth game operation.
[0040] Figure 1 This schematic diagram illustrates a system architecture of a control system for a non-player character in this exemplary embodiment; the control method and apparatus for a non-player character proposed in this disclosure can be applied to... Figure 1 In the system architecture of the exemplary application environment shown.
[0041] like Figure 1 As shown, system architecture 100 may include one or more of terminal devices 101, 102, 103, and 104, a network 105, and a server 106. Network 105 serves as the medium for providing communication links between terminal devices 101, 102, 103, and 104 and server 106. Network 105 may include various connection types, such as wired or wireless communication links or fiber optic cables. Terminal devices 101, 102, 103, and 104 may be, for example, smartphones, PDAs, laptops, servers, desktop computers, or any other networking computing devices, but are not limited to these.
[0042] It should be understood that Figure 1The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, there can be any number of terminal devices, networks, and servers. For example, server 106 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0043] The non-player character control method provided in this embodiment can be executed on server 106, and correspondingly, the non-player character control device is generally located in server 106. The non-player character control method provided in this embodiment can also be executed on a terminal device, and correspondingly, the non-player character control device can also be located in the terminal device. The non-player character control method provided in this embodiment can also be partially executed on server 106 and partially executed on the terminal device; correspondingly, some modules of the non-player character control device can be located in server 106 and some modules can be located in the terminal device.
[0044] For example, in one exemplary embodiment, a user may play the game through terminal devices 101, 102, 103, or 104, and the server 106 may match the terminal devices into the same game process. Taking any of the terminal devices as the execution subject as an example, the terminal device, in response to the non-player character's current position in the game scene being less than a first preset distance from the target virtual cover, generates multiple preset movement directions corresponding to the current position based on the edge contour of the target virtual cover; the terminal device determines the target virtual character's first movement direction at the current moment based on the target virtual character's historical movement direction when chasing the non-player character; in response to the non-player character being within the target virtual character's field of vision, the terminal device determines the movement direction with the smallest angle to the first movement direction among the multiple preset movement directions as the non-player character's second movement direction; and controls the non-player character to move according to the second movement direction.
[0045] In one embodiment of this disclosure, the control method for a non-player character can run on a local terminal device or a server. When the control method for a non-player character runs on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.
[0046] In one alternative implementation, various cloud applications, such as cloud gaming, can run under the cloud interaction system. Taking cloud gaming as an example, cloud gaming refers to a gaming method based on cloud computing. In the cloud gaming operating mode, the game program's execution and the game screen presentation are separated. The storage and execution of non-player character control methods are completed on the cloud gaming server. The client device is used for data reception, transmission, and game screen presentation. For example, the client device can be a display device with data transmission capabilities located close to the user, such as a mobile terminal, television, computer, or PDA; however, information processing is performed by the cloud gaming server in the cloud. During gameplay, the player operates the client device to send operation commands to the cloud gaming server. The cloud gaming server runs the game according to the operation commands, encodes and compresses game screen data, returns it to the client device via the network, and finally, the client device decodes and outputs the game screen.
[0047] In one alternative implementation, taking a game as an example, the local terminal device stores the game program and is used to display the game screen. The local terminal device is used to interact with the player through a graphical user interface (GUI), i.e., conventionally downloading, installing, and running the game program via an electronic device. The local terminal device can provide the GUI to the player in various ways, such as rendering it on the terminal's display screen or providing it to the player via holographic projection. For example, the local terminal device can include a display screen for displaying the GUI, which includes game screens, and a processor for running the game, generating the GUI, and controlling the display of the GUI on the display screen.
[0048] In one possible implementation, embodiments of the present invention provide a control method for a non-player character, which provides a graphical user interface through a terminal device, wherein the terminal device may be the aforementioned local terminal device or a client device in the aforementioned cloud interaction system.
[0049] However, those skilled in the art will readily understand that the above application scenarios are merely illustrative and are not intended to limit the scope of this exemplary embodiment.
[0050] The following embodiment uses the provided control method for non-player characters applied to a terminal device as an example for explanation. The graphical user interface provided by the terminal device can display a portion of the game scene, as well as virtual cover and virtual characters located within the game scene. The virtual characters include at least non-player characters, which are either NPCs or AI characters.
[0051] Figure 2 This schematic diagram illustrates a flow chart of a control method for a non-player character in this exemplary embodiment. See also: Figure 2The non-player control method provided by the exemplary embodiments of this disclosure includes the following steps 201-204:
[0052] Step 201: In response to the fact that the distance between the current position of the non-player character in the game scene and the target virtual cover is less than the first preset distance, generate multiple preset movement directions corresponding to the current position based on the edge contour of the target virtual cover.
[0053] Step 202: Determine the first movement direction of the target virtual character at the current moment based on the historical movement direction of the target virtual character chasing the non-player character.
[0054] Step 203: In response to the non-player character being within the field of view of the target virtual character, determine the movement direction with the smallest angle to the first movement direction among multiple preset movement directions as the second movement direction of the non-player character.
[0055] Step 204: Control the non-player character to move in the second movement direction.
[0056] In some embodiments of this disclosure, the technical solutions involve generating multiple preset movement directions corresponding to the current position based on the edge contour of the target virtual cover, responding to the non-player character's current position being less than a first preset distance from the target virtual cover's current location; determining the target virtual character's first movement direction at the current moment based on the target virtual character's historical movement direction while chasing the non-player character; determining the non-player character's second movement direction based on the non-player character's current position's position from the multiple preset movement directions, given that the non-player character has the smallest angle with the first movement direction among the multiple preset movement directions; and controlling the non-player character to move according to the second movement direction. On one hand, this method pre-generates multiple alternative movement directions matching the AI character's current position based on the edge contour of the virtual cover, thereby reducing the high demands on computer performance and improving the overall game performance. Furthermore, it allows for selection from these multiple alternative movement directions based on real-time predicted movement directions of the character controlled by the real player, intelligently adjusting the AI character's movement direction in real time, and fully utilizing the terrain to control the AI character to intelligently evade pursuit by the character controlled by the real player. This method addresses the technical problem of low intelligence and anthropomorphism in existing AI characters, which merely move clockwise or counterclockwise around virtual cover according to preset rules. It enables non-player characters to behave similarly to player-controlled characters, improving the intelligence and anthropomorphism of non-player character control and thus enhancing the player's gaming experience. Furthermore, compared to the long development time, high difficulty, and high computational resource consumption associated with reinforcement learning and transfer learning algorithms used in some related technologies, this method allows for faster and more efficient implementation while significantly reducing computational resource consumption and ensuring smooth game operation.
[0057] The following are Figure 2 The specific implementation methods of each step in the illustrated embodiment are described in detail below:
[0058] In step 201, in response to the fact that the distance between the current position of the non-player character in the game scene and the target virtual cover is less than a first preset distance, multiple preset movement directions corresponding to the current position are generated based on the edge contour of the target virtual cover.
[0059] The target virtual cover is the obstacle in the game scene that has the smallest distance to the current position of the NPC or AI character; the edge outline of the target virtual cover is usually a closed outline. The preset movement direction is a number of alternative movement directions that are prepared offline in advance.
[0060] According to some embodiments of this disclosure, game scenes typically include virtual characters controlled by players, AI characters, and various virtual cover objects. These virtual cover objects can be obstacles of any shape and type, such as walls, haystacks, or containers. To reduce computational resource consumption during gameplay and thus minimize latency and lag on terminal devices, the edge contours of each virtual cover object in the game scene can be pre-acquired when the terminal device starts the game process.
[0061] The following will explain the process of identifying the target virtual cover from the various virtual covers contained in the game scene, and then extracting the edge contour of the target virtual cover.
[0062] In one optional embodiment of this disclosure, the edge contours of each virtual cover can be extracted in advance based on the volume pixels of different virtual covers or virtual models, or the size of the virtual cover. After pre-extracting the edge contours of each virtual cover, the terminal device detects the current position of the AI character in real time. When it detects that the distance between the current position of the AI character and a virtual cover in the game scene is less than a first preset distance, the virtual cover is determined as the target virtual cover (that is, the virtual cover closest to the current position of the AI character is determined as the target virtual cover).
[0063] In another optional embodiment of this disclosure, after the target virtual shelter is detected, the edge contour line of the target virtual shelter can be extracted based on the volume element or the size of the target virtual shelter. This process can reduce the computational consumption of the terminal device.
[0064] Next, based on the above-determined edge contour of the target virtual shelter, we will combine... Figure 3 The process of generating multiple preset movement directions corresponding to the current position based on the edge contour of the target virtual shelter is illustrated by way of example.
[0065] Figure 3 This schematic diagram illustrates a process flow diagram of a method for generating multiple preset movement directions corresponding to an AI character and its current position in this exemplary embodiment. See also Figure 3 The non-player control method provided in the exemplary embodiments of this disclosure includes the following steps 301-303:
[0066] Step 301: Obtain the set of path points on the edge contour of the target virtual shelter.
[0067] In some example embodiments of this disclosure, when obtaining a set of path points pre-collected on the edge contour of the target virtual cover, a first path point located on the edge contour of the target virtual cover at the initial moment is pre-collected; a second path point located on the edge contour at the next moment is collected according to the movement speed and refresh frequency of the non-player character, until the distance between the collected path points and the first path point is less than a second preset distance to obtain the set of path points.
[0068] The refresh rate, or tick rate, refers to how frequently the server refreshes during gameplay. During gameplay, the player's device exchanges data with the server in real time. Therefore, a higher tick rate results in faster data exchange between the server and the device, leading to lower latency; conversely, a lower tick rate results in slower data exchange, leading to higher latency.
[0069] The following will combine Figure 4 The process of obtaining the set of path points on the edge contour of the target virtual shelter is described in detail.
[0070] Figure 4 This schematic diagram illustrates a process for obtaining a set of path points on the edge contour of a target virtual shelter according to this exemplary embodiment. (Refer to...) Figure 4 The game scene contains multiple virtual cover. When the target virtual character 401 chases the non-player character 402, the virtual cover with the smallest distance from the non-player character 402 is determined as the target virtual cover 403.
[0071] For example, assuming the AI character's movement speed is V (meters / second), the AI character's tick frequency is t (seconds / tick), and the edge contour of the target virtual cover 403 is a closed region, the edge contour of the target virtual cover 403 is extracted. First, a first path point a1 is randomly collected at the initial moment, and a second path point a2 is collected at the next moment based on the AI character's movement speed and tick frequency; then, based on the second path point a2, a third path point a3 is collected at the next moment based on the AI character's movement speed and tick frequency, until the last path point an is collected.
[0072] By acquiring the set of path points on the edge contour of the target virtual bunker, it is easier to determine the AI character's alternative movement direction based on the AI character's current position and the set of path points, thereby improving the intelligence and anthropomorphism of the controlled AI character.
[0073] In some example embodiments of this disclosure, when collecting the second path point located on the edge contour at the next moment based on the movement speed and refresh frequency of the non-player character, the initial path point located on the edge contour at the next moment can be collected based on the movement speed and refresh frequency of the non-player character; if the distance between the initial path point and the first path point is greater than the third preset distance and less than the fourth preset distance, the initial path point is determined as the second path point; the third preset distance is determined based on the movement speed, refresh frequency and the first parameter, and the fourth preset distance is determined based on the movement speed, refresh frequency and the second parameter.
[0074] For example, since the edge contours of virtual cover in a game scene are usually irregularly shaped, it is necessary to use the first parameter and the second parameter to accurately determine the second path point.
[0075] Similarly, assuming the AI character's movement speed is V (meters / second), the AI character's tick frequency is t (ticks / second), the first parameter is ε1, the second parameter is ε2, and the distance between the first path point and the second path point (or the initial path point) is l, then:
[0076] At time t1, a first path point a1 is randomly selected. If the distance l between the initial path point at the next time t2, determined by the AI character's movement speed and tick frequency, and the first path point a1 satisfies V*t+ε1≤l≤V*t+ε2, then this initial path point is designated as the second path point a2. Then, using a2 as a base, this process continues until the last path point an is determined. The distance l between the last path point an and the first path point a1 must also satisfy V*t+ε1≤l≤V*t+ε2. As can be seen from the above, the second parameter ε2 is greater than the first parameter ε1. Therefore, it can be understood that the values of the first and second parameters can be preset according to actual needs.
[0077] Conversely, if the distance l between the initial path point and the first path point a1 at the next moment t2, determined by the movement speed and tick frequency of the AI character, does not satisfy V*t+ε1≤l≤V*t+ε2, then the initial path point is discarded in order to redetermine the second path point a2.
[0078] By retaining path points that meet the conditions and removing and re-determining path points that do not meet the conditions until the conditions are met, the accuracy of path point collection can be improved, thereby enhancing the intelligence and anthropomorphism of AI character control.
[0079] Step 302: Determine the path point in the path point set that is closest to the current position of the AI character as the target path point for the AI character.
[0080] For example, the target path point can be determined from the set of path points that is closest to the current location of the AI character.
[0081] Step 303: Generate multiple preset movement directions for non-player characters based on the positional relationship between the target path point and adjacent path points.
[0082] The following will combine Figure 5 The process of determining target waypoints and generating multiple preset movement directions for AI characters is illustrated by example.
[0083] Figure 5 This schematic diagram illustrates multiple preset movement directions for generating an AI character in this exemplary embodiment. (Refer to...) Figure 5 , Figure 5 It includes an AI character 501, the edge outline 502 of the target virtual shelter, and multiple path points A1, A2, and A3 collected on the edge outline 502.
[0084] Depend on Figure 5 The current position of AI character 501 can be determined as the target path point A2. The adjacent path points that are adjacent to path point A2 are path points A1 and A3, respectively. Then, based on the relative positional relationship between the target path point A2 and the adjacent path point A1, a preset movement direction dir_ai2 is determined, and based on the relative positional relationship between the target path point A2 and the adjacent path point A3, another preset movement direction dir_ai1 is determined.
[0085] By pre-collecting a set of path points based on the edge contour of the target virtual cover, multiple preset movement directions corresponding to the current position of the AI character are generated. The AI character is then controlled to choose one of the multiple preset movement directions to move in, so that the non-player character can be intelligently controlled according to the distribution of the virtual cover and the position of the target virtual character.
[0086] In step 202, the first movement direction of the target virtual character at the current moment is determined based on the historical movement direction of the target virtual character chasing the non-player character.
[0087] For example, in historical data, during the detection of a target virtual character chasing a non-player character, the terminal device can obtain the position of the target virtual character, and thus determine the first movement direction of the target virtual character within that time interval based on the target virtual character positions collected at two adjacent time points.
[0088] The terminal device can record the position of the target virtual character every preset time interval Δt. For example, if the target virtual character is at position t... i The first position coordinate at time (x) i ,y i ,zi ), and in t i The second position at time +Δt is (x i+Δt ,y i+Δt ,z i+Δt If the first direction of movement of the target virtual character at time t+Δt is given, then the first direction of movement of the target virtual character at time t+Δt is given. As shown in (Formula 1):
[0089]
[0090] In (Formula 1), the first direction of movement Includes the direction of movement and the distance moved; (x i ,y i ,z i ) as the target virtual character in t i The first position coordinate at time (x i+Δt ,y i+Δt ,z i+Δt ) is the second position of the target virtual character at time t+Δt.
[0091] Figure 6 This schematic diagram illustrates a method for determining a first movement direction of a target virtual character in this exemplary embodiment. (Refer to...) Figure 6 The terminal device records the target virtual character's position coordinates G1 (x1, y1, z1) at time t1 and its position coordinates G2 (x1, y1, z1) at time t2. 1+Δt ,y 1+Δt ,z 1+Δt ), where time t2 is (t1+Δt) times based on time t1, then the distance between time t1 and time t2 is determined. As shown in (Formula 2):
[0092]
[0093] In (Formula 2), (x 1+Δt ,y 1+Δt ,z 1+Δt Let G2 be the position coordinates of the target virtual character at time t1+Δt, and let (x1, y1, z1) be the position coordinates of the target virtual character at time t1+Δt.
[0094] In some example embodiments of this disclosure, multiple historical movement directions at different time periods are obtained based on the position of the target virtual character at different historical moments; the direction weights corresponding to each historical movement direction are determined based on the time length between the multiple different historical moments and the current moment; and the first movement direction of the target virtual character at the current moment is determined based on each historical movement direction and its corresponding direction weights.
[0095] For example, since the initial movement direction of the target virtual character controlled by the real player at the current moment is not only affected by the object being chased, but also gradually changed by the player using the joystick to control the target virtual character to change its initial movement direction as the position of the object being chased changes, until the target virtual character's initial movement direction matches the movement direction of the object being chased. Furthermore, the initial movement direction of the target virtual character at the current moment is necessarily more influenced by the movement direction at more recent times, and less influenced by the movement direction at more distant times. Therefore, a directional weight is determined for each historical movement direction at multiple different historical moments.
[0096] The actual first movement direction dir_obj of the target virtual character at the current moment is calculated as shown in (Formula 3):
[0097] dir_obj = γdir i +γ 2 dir i-1 +γ 3 dir i-2 +…+γ n dir i-(n-1) ..........(Formula 3)
[0098] In (Formula 3), dir i dir i-1 …dir i-(n-1) These represent the directions of movement at different time periods, where dir i The one closest in time to the current moment, while dir i-(n-1) The time distance from the current time is the greatest; the parameter γ represents the weight value of the direction of movement in different time periods, where γ is a constant and γ∈(0,1).
[0099] By statistically analyzing multiple historical movement directions of players at different historical moments and assigning different weights to these directions, the importance of historical movement directions with shorter time intervals from the current moment is increased, while the importance of historical movement directions with longer time intervals from the current moment is decreased. This reduces bias and improves the accuracy of predicting the target virtual character's first movement direction at the current moment.
[0100] In step 203, in response to the non-player character being within the field of view of the target virtual character, the movement direction with the smallest angle to the first movement direction among multiple preset movement directions is determined as the second movement direction of the non-player character.
[0101] In an optional embodiment of this disclosure, when the terminal device detects that there are no virtual cover between the target virtual character and the AI character, that is, the AI character is within the field of vision of the target virtual character, it determines the second movement direction of the AI character from a plurality of pre-generated preset movement directions, the movement direction with the smallest angle to the first movement direction.
[0102] In another optional embodiment of this disclosure, when the terminal device detects that there is a virtual cover between the target virtual character and the AI character, in response to the AI character being outside the field of vision of the target virtual character, the movement direction with the largest angle to the first movement direction among a plurality of preset movement directions is determined as the second movement direction of the non-player character.
[0103] Based on the above-mentioned determination of the second movement direction of the AI character, the second movement direction of the AI character can be determined according to the comparison results of the cosine value cosθ between the first movement direction of the target virtual character and multiple preset movement directions.
[0104] by Figure 5 Taking the two generated alternative preset movement directions as an example, the cosθ1 and cosθ2 of the preset movement directions dir_ai1 and dir_ai2 used for AI character selection and the first movement direction dir_obj are determined as follows:
[0105]
[0106] In (Formula 4), dir_ai1 is a preset movement direction for AI character candidates; dir_obj is the first movement direction of the target virtual character.
[0107]
[0108] In (Formula 5), dir_ai2 is another preset movement direction for AI character alternatives; dir_obj is the first movement direction of the target virtual character.
[0109] If the above cosθ1 and cosθ2 satisfy cosθ1>cosθ2, the terminal device selects the second movement direction as dir_ai1 when the AI character is within the field of view of the target virtual character; and selects the second movement direction as dir_ai2 when the terminal device responds to the AI character being outside the field of view of the target virtual character.
[0110] The above-described determination of the second movement direction of the AI character based on the comparison results of the cosine value cosθ between the first movement direction of the target virtual character and multiple preset movement directions is merely an example. It can also be implemented in any other way, such as by comparing the first movement direction of the target virtual character with the sine value sinθ between multiple preset movement directions. This disclosure does not impose any special limitations on this.
[0111] The following will combine Figure 7 , Figure 8 The process of determining the second direction of movement for an AI character is illustrated by example.
[0112] Figure 7 This schematic diagram illustrates how, in this exemplary embodiment, an AI character's second movement direction is determined when the AI character is outside the target virtual character's field of vision. Figure 7 The diagram shows an AI character 701, a target virtual character 702, and a target virtual cover 703. At this point, the AI character 701 is not within the field of view of the target virtual character 702; that is, the target virtual character 702 does not see the AI character 701. Figure 7 The first movement direction of the target virtual character 702 shown is then determined from multiple pre-selected movement directions, such as... Figure 7 The second movement direction of the AI character 701 is shown. At this time, the angle between the determined second movement direction of the AI character 701 and the first movement direction of the target virtual character 702 is the largest (the directions are completely opposite).
[0113] Figure 8 This schematic diagram illustrates how, in this exemplary embodiment, an AI character's second movement direction is determined when the AI character is within the field of view of a target virtual character. Figure 8 The diagram shows an AI character 801, a target virtual character 802, and a target virtual cover 803. At this point, AI character 801 is within the field of view of target virtual character 802, meaning target virtual character 802 can see AI character 801, and... Figure 8 The first movement direction of the target virtual character 802 shown is then determined from multiple pre-selected movement directions, such as... Figure 8 The second movement direction of the AI character is shown. At this time, the angle between the second movement direction of the determined AI character 801 and the first movement direction of the target virtual character 802 is the smallest (the directions are exactly the same).
[0114] This process can intelligently determine the second direction of movement for controlling the AI character based on the current distribution of virtual bunkers, thereby improving the intelligence and anthropomorphism of the AI character control.
[0115] In one optional embodiment of this disclosure, a set of path points pre-collected on the edge contour of the target virtual cover is obtained; if the time interval is greater than a preset time and the position of the target virtual character has not changed, the path point with the largest distance from the position of the target virtual character in the set of path points is taken as the target path point; the second movement direction of the non-player character is determined based on the current position of the non-player character and the target path point.
[0116] For example, if the target virtual cover has not moved within a preset time period, in order to avoid the situation where the denominator in (Formula 4) and (Formula 5) is 0 and the value is meaningless, the path point with the largest distance from the target virtual character in the path point set is taken as the target path point.
[0117] To explain the above situation in detail, we will combine... Figure 9 The process of determining the second movement direction of a non-player character based on its current position and the target waypoint is explained.
[0118] Figure 9 This schematic diagram illustrates how a second movement direction of an AI character is determined when the target virtual character remains stationary, according to this exemplary embodiment. Figure 9 As shown, AI character 901 is currently at path point A1. If the target virtual character 902 does not move for a relatively long period of time (e.g., 1 minute), then the path point A2 with the largest distance from the target virtual character in the path point set is determined as the target path point, so as to control AI character 901 to move towards path point A2. The movement direction from path point A1 to path point A2 is determined as the second movement direction of AI character.
[0119] By selecting the path point with the greatest distance from the target virtual character (the pursuer) from the set of path points as the target path point, the AI character can be made to move towards the target path point. This process can make full use of the obstacles in the game scene and the pursuer's position to intelligently determine the movement direction of the AI character, thereby improving the intelligence and anthropomorphism of controlling the AI character.
[0120] In step 204, the non-player character is controlled to move in the second movement direction.
[0121] For example, once the AI character's second movement direction is determined, the AI character can be controlled to move in that direction.
[0122] This process allows AI characters to intelligently escape pursuers based on the terrain distribution of the current game scene, avoiding the limitation of AI characters mechanically circling virtual cover according to preset rules in related technologies. This improves the intelligence and anthropomorphism of controlling AI characters. At the same time, players are less likely to realize that they are playing with an AI character, thus enhancing the player's gaming experience.
[0123] To implement the above-mentioned control method for non-player characters, one embodiment of this disclosure provides a control device for non-player characters. Figure 10 The schematic diagram illustrates the architecture of the control device for non-player characters.
[0124] The non-player character control device 1000 includes a movement direction generation module 1001, a first direction determination module 1002, a second direction determination module 1003, and a character control module 1004.
[0125] The movement direction generation module 1001 is used to generate multiple preset movement directions corresponding to the current position based on the edge contour of the target virtual cover when the distance between the current position of the non-player character and the target virtual cover in the game scene is less than a first preset distance; the first direction determination module 1002 is used to determine the first movement direction of the target virtual character at the current moment based on the historical movement direction of the target virtual character chasing the non-player character; the second direction determination module 1003 is used to determine the movement direction with the smallest angle with the first movement direction among the multiple preset movement directions as the second movement direction of the non-player character when the non-player character is within the field of vision of the target virtual character; the character control module 1004 is used to control the non-player character to move according to the second movement direction.
[0126] The non-player character control device 1000 provided in this embodiment can execute the technical solution of the non-player character control method in any of the above embodiments. Its implementation principle and beneficial effects are similar to those of the non-player character control method. Please refer to the implementation principle and beneficial effects of the non-player character control method. It will not be repeated here.
[0127] Furthermore, in order to implement the aforementioned control methods for non-player characters, in Figure 10 Based on this, one embodiment of the present disclosure provides another control device for non-player characters. Figure 11 The schematic diagram illustrates the architecture of the control device for non-player characters.
[0128] The non-player character control device 1100, in addition to including the movement direction generation module 1001, the first direction determination module 1002, the second direction determination module 1003 and the character control module 1004, also includes a third direction determination module 1005 and a path determination module 1006.
[0129] In an optional embodiment of this disclosure, the third-party direction determination module 1005 is used to determine the second movement direction of the non-player character as the movement direction with the largest angle to the first movement direction among a plurality of preset movement directions in response to the non-player character being located outside the field of vision of the target virtual character.
[0130] In an optional embodiment of this disclosure, the movement direction generation module 1001 is used to obtain a set of path points pre-collected on the edge contour of the target virtual cover; determine the path point in the path point set that is closest to the current position as the target path point corresponding to the non-player character; and generate multiple preset movement directions for the non-player character based on the positional relationship between the target path point and adjacent path points.
[0131] In an optional embodiment of this disclosure, the movement direction generation module 1001 is used to pre-collect first path points located on the edge contour of the target virtual cover at an initial moment; collect second path points located on the edge contour at the next moment according to the movement speed and refresh frequency of the non-player character, until the distance between the collected path points and the first path points is less than a second preset distance to obtain a path point set.
[0132] In an optional embodiment of this disclosure, the movement direction generation module 1001 is used to collect the initial path point located on the edge contour at the next moment according to the movement speed and refresh frequency of the non-player character; if the distance between the initial path point and the first path point is greater than or equal to a third preset distance and less than or equal to a fourth preset distance, then the initial path point is determined as the second path point; the third preset distance is determined according to the movement speed, refresh frequency and the first parameter, and the fourth preset distance is determined according to the movement speed, refresh frequency and the second parameter respectively.
[0133] In an optional embodiment of this disclosure, the third-party direction determination module 1005 is used to obtain multiple historical movement directions at different time periods based on the position of the target virtual character at different historical moments; determine the direction weight corresponding to each historical movement direction based on the time length between the multiple different historical moments and the current moment; and determine the first movement direction of the target virtual character at the current moment based on each historical movement direction and the corresponding direction weight.
[0134] In an optional embodiment of this disclosure, the path determination module 1006 is used to acquire a set of path points pre-collected on the edge contour of the target virtual cover; if the time interval is greater than a preset time and the position of the target virtual character has not changed, the path point with the largest distance from the position of the target virtual character in the set of path points is determined as the target path point; the third direction determination module 1004 is used to determine the second movement direction of the non-player character based on the current position of the non-player character and the target path point.
[0135] The non-player character control device 1100 provided in this embodiment can execute the technical solution of the non-player character control method in any of the above embodiments. Its implementation principle and beneficial effects are similar to those of the non-player character control method. Please refer to the implementation principle and beneficial effects of the non-player character control method. It will not be repeated here.
[0136] In exemplary embodiments of this disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the methods described above is stored. In some possible embodiments, various aspects of the invention can also be implemented as a program product including program code, which, when the program product is run on a terminal device, causes the terminal device to perform the steps of the various exemplary embodiments of the invention described in the "Exemplary Methods" section above, for example:
[0137] The aforementioned non-player character control method, on the one hand, pre-generates multiple alternative movement directions matching the current position of the AI character based on the edge contour of the virtual cover, thereby reducing the high demands on computer performance and improving the overall game performance. Furthermore, it can select from these multiple alternative movement directions based on real-time predictions of the movement direction of the player-controlled character, intelligently adjusting the AI character's movement direction in real time. This fully utilizes the terrain to control the AI character to intelligently evade pursuit by the player-controlled character. This method solves the technical problem of low intelligence and anthropomorphism in controlling NPCs or AI characters, where existing technologies only allow AI characters to move clockwise or counterclockwise around virtual cover according to preset rules. It makes the behavior of non-player characters similar to player-controlled characters, improving the intelligence and anthropomorphism of non-player character control and thus enhancing the player's gaming experience. On the other hand, compared to the long development time, high difficulty, and high computational resource consumption caused by reinforcement learning and transfer learning algorithms used in some related technologies, this method can be implemented more quickly and efficiently, significantly reducing computational resource consumption and ensuring smooth game operation.
[0138] In some example embodiments of this disclosure, in response to the AI character being outside the field of vision of the target virtual character, the movement direction with the largest angle to the first movement direction among multiple preset movement directions is determined as the second movement direction for the non-player character. This process can intelligently determine the second movement direction for controlling the AI character's movement based on the current distribution of virtual cover, thereby improving the intelligence and anthropomorphism of the AI character control.
[0139] In some example embodiments of this disclosure, a set of path points on the edge contour of the target virtual cover is obtained; the path point in the path point set that is closest to the current position of the AI character is determined as the target path point corresponding to the AI character; and multiple preset movement directions for the non-player character are generated based on the positional relationship between the target path point and adjacent path points. By generating multiple preset movement directions corresponding to the current position of the AI character in advance based on the set of path points collected from the edge contour of the target virtual cover, the AI character can be controlled to select one of the multiple preset movement directions to move in, so that the non-player character can be intelligently controlled subsequently based on the distribution of the virtual cover and the position of the target virtual character.
[0140] In some example embodiments of this disclosure, a first path point located on the edge contour of the target virtual cover at an initial moment is pre-collected; a second path point located on the edge contour at the next moment is collected based on the movement speed and refresh frequency of the non-player character, until the distance between the collected path points and the first path point is less than a second preset distance, thus obtaining a path point set. By obtaining the path point set on the edge contour of the target virtual cover, it is easier to determine the AI character's alternative movement direction based on the AI character's current position and the path point set, thereby improving the intelligence and anthropomorphism of controlling the AI character.
[0141] In some example embodiments of this disclosure, initial path points located on the edge contour at the next moment are collected based on the movement speed and refresh rate of the non-player character. If the distance between the initial path point and the first path point is greater than a third preset distance and less than a fourth preset distance, the initial path point is determined as the second path point. The third preset distance is determined based on the movement speed, refresh rate, and a first parameter, and the fourth preset distance is determined based on the movement speed, refresh rate, and a second parameter. By retaining path points that meet the conditions and discarding and re-determining path points that do not meet the conditions until the above conditions are met, the accuracy of path point collection can be improved, thereby enhancing the intelligence and anthropomorphism of AI character control.
[0142] In some example embodiments of this disclosure, multiple historical movement directions at different time periods are obtained based on the position of the target virtual character at different historical moments; the directional weights corresponding to each historical movement direction are determined based on the time length between the multiple different historical moments and the current moment; and the first movement direction of the target virtual character at the current moment is determined based on each historical movement direction and its corresponding directional weight. By statistically analyzing multiple historical movement directions of the player at different historical moments and adding different weights to the multiple historical movement directions at different moments, the importance of historical movement directions with a short time interval from the current moment is enhanced, while the importance of historical movement directions with a long time interval from the current moment is reduced, thereby reducing deviation and improving the accuracy of predicting the first movement direction of the target virtual character at the current moment.
[0143] In some example embodiments of this disclosure, a set of path points pre-collected on the edge contour of the target virtual cover is obtained; if the time interval is greater than a preset time and the position of the target virtual character does not change, the path point with the largest distance from the target virtual character in the path point set is taken as the target path point; a second movement direction of the non-player character is determined based on the current position of the non-player character and the target path point. By taking the path point with the largest distance from the target virtual character (the pursuer) in the path point set as the target path point to make the AI character move towards the target path point, this process can make full use of the situation of obstacles in the game scene and the position of the pursuer to intelligently determine the movement direction of the AI character, thereby improving the intelligence and anthropomorphism of controlling the AI character.
[0144] According to embodiments of the present invention, a program product for implementing the above-described method may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0145] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0146] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.
[0147] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0148] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0149] In an exemplary embodiment of this disclosure, an electronic device capable of implementing the above-described method is also provided.
[0150] Those skilled in the art will understand that various aspects of the present invention can be implemented as systems, methods, or program products. Therefore, various aspects of the present invention can be specifically implemented in the following forms: entirely hardware implementations, entirely software implementations (including firmware, microcode, etc.), or implementations combining hardware and software aspects, collectively referred to herein as “circuits,” “modules,” or “systems.”
[0151] The following reference Figure 12 To describe an electronic device 1200 according to this embodiment of the present invention. Figure 12 The electronic device 1200 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0152] like Figure 12As shown, the electronic device 1200 is manifested in the form of a general-purpose computing device. The components of the electronic device 1200 may include, but are not limited to: at least one processing unit 1210, at least one storage unit 1220, a bus 1230 connecting different system components (including storage unit 1220 and processing unit 1210), and a display unit 1240.
[0153] The storage unit stores program code, which can be executed by the processing unit 1210, causing the processing unit 1210 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of the present invention. For example:
[0154] In some example embodiments of this disclosure, in response to the distance between the current position of the non-player character and the target virtual cover being less than a first preset distance, multiple preset movement directions corresponding to the current position are generated based on the edge contour of the target virtual cover; the first movement direction of the target virtual character at the current moment is determined based on the historical movement direction of the target virtual character chasing the non-player character; in response to the non-player character being within the field of vision of the target virtual character, the movement direction with the smallest angle to the first movement direction among the multiple preset movement directions is determined as the second movement direction of the non-player character; and the non-player character is controlled to move according to the second movement direction.
[0155] The aforementioned non-player character control method, on the one hand, pre-generates multiple alternative movement directions matching the current position of the AI character based on the edge contour of the virtual cover, thereby reducing the high demands on computer performance and improving the overall game performance. Furthermore, it can select from these multiple alternative movement directions based on real-time predictions of the movement direction of the player-controlled character, intelligently adjusting the AI character's movement direction in real time. This fully utilizes the terrain to control the AI character to intelligently evade pursuit by the player-controlled character. This method solves the technical problem of low intelligence and anthropomorphism in controlling NPCs or AI characters, where existing technologies only allow AI characters to move clockwise or counterclockwise around virtual cover according to preset rules. It makes the behavior of non-player characters similar to player-controlled characters, improving the intelligence and anthropomorphism of non-player character control and thus enhancing the player's gaming experience. On the other hand, compared to the long development time, high difficulty, and high computational resource consumption caused by reinforcement learning and transfer learning algorithms used in some related technologies, this method can be implemented more quickly and efficiently, significantly reducing computational resource consumption and ensuring smooth game operation.
[0156] In some example embodiments of this disclosure, in response to the AI character being outside the field of vision of the target virtual character, the movement direction with the largest angle to the first movement direction among multiple preset movement directions is determined as the second movement direction for the non-player character. This process can intelligently determine the second movement direction for controlling the AI character's movement based on the current distribution of virtual cover, thereby improving the intelligence and anthropomorphism of the AI character control.
[0157] In some example embodiments of this disclosure, a set of path points on the edge contour of the target virtual cover is obtained; the path point in the path point set that is closest to the current position of the AI character is determined as the target path point corresponding to the AI character; and multiple preset movement directions for the non-player character are generated based on the positional relationship between the target path point and adjacent path points. By generating multiple preset movement directions corresponding to the current position of the AI character in advance based on the set of path points collected from the edge contour of the target virtual cover, the AI character can be controlled to select one of the multiple preset movement directions to move in, so that the non-player character can be intelligently controlled subsequently based on the distribution of the virtual cover and the position of the target virtual character.
[0158] In some example embodiments of this disclosure, a first path point located on the edge contour of the target virtual cover at an initial moment is pre-collected; a second path point located on the edge contour at the next moment is collected based on the movement speed and refresh frequency of the non-player character, until the distance between the collected path points and the first path point is less than a second preset distance, thus obtaining a path point set. By obtaining the path point set on the edge contour of the target virtual cover, it is easier to determine the AI character's alternative movement direction based on the AI character's current position and the path point set, thereby improving the intelligence and anthropomorphism of controlling the AI character.
[0159] In some example embodiments of this disclosure, initial path points located on the edge contour at the next moment are collected based on the movement speed and refresh rate of the non-player character. If the distance between the initial path point and the first path point is greater than a third preset distance and less than a fourth preset distance, the initial path point is determined as the second path point. The third preset distance is determined based on the movement speed, refresh rate, and a first parameter, and the fourth preset distance is determined based on the movement speed, refresh rate, and a second parameter. By retaining path points that meet the conditions and discarding and re-determining path points that do not meet the conditions until the above conditions are met, the accuracy of path point collection can be improved, thereby enhancing the intelligence and anthropomorphism of AI character control.
[0160] In some example embodiments of this disclosure, multiple historical movement directions at different time periods are obtained based on the position of the target virtual character at different historical moments; the directional weights corresponding to each historical movement direction are determined based on the time length between the multiple different historical moments and the current moment; and the first movement direction of the target virtual character at the current moment is determined based on each historical movement direction and its corresponding directional weight. By statistically analyzing multiple historical movement directions of the player at different historical moments and adding different weights to the multiple historical movement directions at different moments, the importance of historical movement directions with a short time interval from the current moment is enhanced, while the importance of historical movement directions with a long time interval from the current moment is reduced, thereby reducing deviation and improving the accuracy of predicting the first movement direction of the target virtual character at the current moment.
[0161] In some example embodiments of this disclosure, a set of path points pre-collected on the edge contour of the target virtual cover is obtained; if the time interval is greater than a preset time and the position of the target virtual character does not change, the path point with the largest distance from the target virtual character in the path point set is taken as the target path point; a second movement direction of the non-player character is determined based on the current position of the non-player character and the target path point. By taking the path point with the largest distance from the target virtual character (the pursuer) in the path point set as the target path point to make the AI character move towards the target path point, this process can make full use of the situation of obstacles in the game scene and the position of the pursuer to intelligently determine the movement direction of the AI character, thereby improving the intelligence and anthropomorphism of controlling the AI character.
[0162] Storage unit 1220 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 12201 and / or cache memory 12202, and may further include a read-only memory (ROM) 12203.
[0163] Storage unit 1220 may also include a program / utility 12204 having a set (at least one) of program modules 12205, such program modules 12205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0164] Bus 1230 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.
[0165] Electronic device 1200 can also communicate with one or more external devices 1300 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with electronic device 1200, and / or with any device that enables electronic device 1200 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 1250. Furthermore, electronic device 1200 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 1260. As shown, network adapter 1260 communicates with other modules of electronic device 1200 via bus 1230. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 1200, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0166] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0167] Furthermore, the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of the present invention, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0168] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0169] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
[0170] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is defined only by the appended claims.
Claims
1. A method for controlling a non-player character, characterized in that, The method includes: In response to the fact that the distance between the current position of a non-player character and the target virtual cover in the game scene is less than a first preset distance, a set of path points pre-collected on the edge contour of the target virtual cover is obtained; the path point in the set that is closest to the current position is determined as the target path point corresponding to the non-player character; and multiple preset movement directions of the non-player character are generated according to the positional relationship between the target path point and adjacent path points. The first movement direction of the target virtual character at the current moment is determined based on the historical movement direction of the target virtual character chasing the non-player character; In response to the non-player character being within the field of view of the target virtual character, the movement direction with the smallest angle to the first movement direction among the plurality of preset movement directions is determined as the second movement direction of the non-player character; In response to the non-player character being outside the field of view of the target virtual character, the movement direction with the largest angle to the first movement direction among the plurality of preset movement directions is determined as the second movement direction of the non-player character; The non-player character is controlled to move in the second movement direction, so as to delay the pursuit time of the target virtual character.
2. The method for controlling a non-player character according to claim 1, characterized in that, The step of acquiring a set of path points pre-collected on the edge contour of the target virtual shelter includes: Pre-collect the first path point located on the edge contour of the target virtual shelter at the initial moment; Based on the movement speed and refresh frequency of the non-player character, the second path point located on the edge contour at the next moment is collected until the distance between the collected path point and the first path point is less than a second preset distance to obtain the path point set.
3. The method for controlling a non-player character according to claim 2, characterized in that, The step of acquiring the second path point located on the edge contour at the next moment based on the movement speed and refresh frequency of the non-player character includes: The initial path point located on the edge contour at the next moment is collected based on the movement speed and refresh frequency of the non-player character; If the distance between the initial path point and the first path point is greater than or equal to a third preset distance and less than or equal to a fourth preset distance, then the initial path point is determined as the second path point; The third preset distance is determined based on the movement speed, the refresh frequency, and the first parameter, and the fourth preset distance is determined based on the movement speed, the refresh frequency, and the second parameter.
4. The method for controlling a non-player character according to claim 1, characterized in that, The step of determining the first movement direction of the target virtual character at the current moment based on the historical movement direction of the target virtual character chasing the non-player character includes: Based on the position of the target virtual character at different historical moments, the historical movement directions at multiple different time periods are obtained; The directional weights corresponding to each of the historical movement directions are determined based on the time length between the multiple different historical moments and the current moment. The first movement direction of the target virtual character at the current moment is determined based on each of the historical movement directions and the corresponding direction weights.
5. The method for controlling a non-player character according to claim 1, characterized in that, The method further includes: Obtain a set of path points pre-collected on the edge contour of the target virtual shelter; If the time interval is greater than the preset time and the position of the target virtual character has not changed, then the path point in the set of path points that is furthest from the position of the target virtual character is determined as the target path point; The second movement direction of the non-player character is determined based on the current position of the non-player character and the target waypoint.
6. A control device for a non-player character, characterized in that, The device includes: The movement direction generation module is used to respond to the fact that the distance between the current position of a non-player character in the game scene and the target virtual cover is less than a first preset distance, to obtain a set of path points pre-collected on the edge contour of the target virtual cover; to determine the path point in the set that is closest to the current position as the target path point corresponding to the non-player character; and to generate multiple preset movement directions for the non-player character based on the positional relationship between the target path point and adjacent path points. The first direction determination module is used to determine the first movement direction of the target virtual character at the current moment based on the historical movement direction of the target virtual character chasing the non-player character; The second direction determination module is used to determine the movement direction with the smallest angle to the first movement direction among the plurality of preset movement directions as the second movement direction of the non-player character in response to the non-player character being within the field of vision of the target virtual character. The second direction determination module is further configured to, in response to the non-player character being outside the field of vision of the target virtual character, determine the movement direction with the largest angle to the first movement direction among the plurality of preset movement directions as the second movement direction of the non-player character; The character control module is used to control the non-player character to move in the second movement direction, so as to delay the pursuit time of the target virtual character.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the control method for the non-player character as described in any one of claims 1 to 5.
8. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the non-player character control method according to any one of claims 1 to 5 by executing the executable instructions.