CN117695652A - Method and device for controlling movement of intelligent body in multi-player online game and electronic equipment - Google Patents

Method and device for controlling movement of intelligent body in multi-player online game and electronic equipment Download PDF

Info

Publication number
CN117695652A
CN117695652A CN202311675617.9A CN202311675617A CN117695652A CN 117695652 A CN117695652 A CN 117695652A CN 202311675617 A CN202311675617 A CN 202311675617A CN 117695652 A CN117695652 A CN 117695652A
Authority
CN
China
Prior art keywords
agent
new
target
tree
node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311675617.9A
Other languages
Chinese (zh)
Inventor
吴江博
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Huya Technology Co Ltd
Original Assignee
Guangzhou Huya Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Huya Technology Co Ltd filed Critical Guangzhou Huya Technology Co Ltd
Priority to CN202311675617.9A priority Critical patent/CN117695652A/en
Publication of CN117695652A publication Critical patent/CN117695652A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Processing Or Creating Images (AREA)

Abstract

The invention provides a method and a device for controlling the movement of an agent in a multiplayer online game and electronic equipment, wherein the method comprises the following steps: instantiating a plurality of agents according to the number of game participants and transmitting the plurality of agents into a virtual game space; constructing a Kd tree according to the position of the target agent in the virtual game space, and searching the nearest neighbor agent positioned in the action range of the agent based on the Kd tree; wherein the target agent is any one of all agents; determining a new speed and a new position of the next movement of the target intelligent agent according to the movement state of the nearest intelligent agent; the new speed is used for the collision-preventing nearest neighbor agent; the control target agent moves to a new location according to the new speed. The invention can realize multiple group simulation and ensure that each intelligent body can be accurately controlled and moved to the corresponding position so as to realize the action and interaction required in the game.

Description

Method and device for controlling movement of intelligent body in multi-player online game and electronic equipment
Technical Field
The invention relates to the technical field of computers, in particular to an intelligent body motion control method and device in a multi-player online game and electronic equipment.
Background
The multi-player online barrage interactive game is an online game form. In such games, a host will offer a multi-player on-line instant combat strategy game in a live room and interact in real time with spectators participating in the game through a barrage system.
In a game, game participants may be randomly separated into two teams, each of which may recruit players and build teams for the team in which they are located by sending a barrage command. The virtual crowd of two teams will be battle in the game map of the game map. A large number of virtual game participants may be accommodated within the game map, which may move and act in accordance with instructions communicated by the user through the barrage.
In order to realize such a large-scale multi-player online interactive game, the game engine needs to have a strong crowd simulation capability. It must plan reasonable paths and obstacle avoidance behavior for each game participant to achieve their dynamic action. However, most of the current game technical schemes can only simulate intelligent agent groups below 1 ten thousand levels, and it is difficult to meet the requirement of more than thousand users to participate simultaneously. Even if some schemes can realize tens of thousands of level group simulation, when a large number of users send instructions at the same time, it is difficult to ensure the game experience of each user.
Disclosure of Invention
The invention aims to provide a method and a device for controlling the movement of an intelligent agent in a multi-person online game and electronic equipment, which can realize multi-group simulation and ensure the control precision of each intelligent agent. Embodiments of the invention may be implemented as follows:
in a first aspect, the present invention provides a method for controlling movement of an agent in a multiplayer online game, the method comprising: instantiating a plurality of agents according to the number of game participants, and transmitting the plurality of agents into a virtual game space; constructing a Kd tree according to the position of a target intelligent agent in the virtual game space, and searching a nearest neighbor intelligent agent positioned in the action range of the intelligent agent based on the Kd tree; wherein the target agent is any one of the agents; determining a new speed and a new position of the next movement of the target intelligent agent according to the movement state of the nearest intelligent agent; the new speed is used to collision the nearest neighbor agent; and controlling the target intelligent agent to move to the new position according to the new speed.
In a second aspect, the present invention provides an agent motion control device in a multiplayer online game, a simulation module, configured to instantiate a plurality of agents according to a number of players involved in the game, and send the plurality of agents to a virtual game space; the searching module is used for searching nearest neighbor agents in the action range of the agents according to the current position of each agent in the virtual game space; the determining module is used for determining a new speed and a new position of the next movement of the intelligent body; the new speed is used to collision the nearest neighbor agent; and the control module is used for controlling the intelligent body to move to the new position according to the new speed.
In a third aspect, the present invention provides an electronic device comprising a processor and a memory, the memory storing a computer program executable by the processor, the processor being executable to implement the method of controlling the movement of an agent in a multiplayer online game according to any of the preceding embodiments.
The invention provides a method, a device and an electronic device for controlling the movement of an agent in a multiplayer online game, which are used for instantiating a plurality of agents according to the number of players participating in the game and sending the agents to a virtual game space. The method means that the created agent can meet the requirement of more than thousand users to participate simultaneously, and then the Kd tree is built according to the position of the target agent in the virtual game space, so that nearest neighbor agents are efficiently searched in the virtual game space to support subsequent decisions and actions. And determining the new speed and the new position of the next movement of the target agent according to the movement state of the nearest neighbor agent. By analyzing the motion states of nearest neighbor agents, their possible action paths and collision risks can be predicted, and the motion strategies of the target agents can be adjusted accordingly to avoid collisions and maintain safety. The control target agent moves to a new location according to the new speed. Based on the calculated new speed and position, the target agent can be precisely controlled and moved to the corresponding position to achieve the actions and interactions required in the game.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic illustration of a game scenario for a multiplayer online game;
FIG. 2 is a schematic flow chart of an agent motion control method in a multiplayer online game provided by an embodiment of the invention;
FIG. 3 is a schematic diagram of an agent according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the emission of an agent according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a Kd tree constructed based on multiple agents according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of an embodiment of the present invention;
FIG. 7 is a functional block diagram of an intelligent agent motion control device in a multiplayer online game according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. The components of the embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the invention, as presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures.
In the description of the present invention, it should be noted that, if the terms "upper", "lower", "inner", "outer", and the like indicate an azimuth or a positional relationship based on the azimuth or the positional relationship shown in the drawings, or the azimuth or the positional relationship in which the inventive product is conventionally put in use, it is merely for convenience of describing the present invention and simplifying the description, and it is not indicated or implied that the apparatus or element referred to must have a specific azimuth, be configured and operated in a specific azimuth, and thus it should not be construed as limiting the present invention.
Furthermore, the terms "first," "second," and the like, if any, are used merely for distinguishing between descriptions and not for indicating or implying a relative importance.
It should be noted that the features of the embodiments of the present invention may be combined with each other without conflict.
The multi-player online game is a game which can provide a large number of players on a server and simultaneously online, wherein the players are connected with a network through terminals (computers/mobile phones/tablet/other devices), so that the players participate in the same multi-player online game, and each terminal can be online and offline at any time and any place. Referring to fig. 1, fig. 1 is a schematic diagram of a game scenario of a multiplayer online game. The application scenario includes a plurality of game terminals 110, wherein clients of the game terminals 110 that can install a multiplayer online game application can communicate with each other (represented by solid line connections) with the server 120 to participate in the same game play.
The gaming terminal 110 may be an electronic device such as a cell phone, tablet computer, game console, electronic book reader, multimedia playing device, wearable device, PC (Personal Computer ), etc. The server 120 performs group simulation based on the number of game participants, resulting in a large number of agents that are free to move in the game scene, which move and behave according to instructions conveyed by the user through the barrage.
In order to realize large-scale multi-player online interactive games, the game engine needs to have strong crowd simulation capability to meet the dynamic action requirements of participants. However, the current game technical scheme is only suitable for simulating not more than ten thousands of intelligent agents, and is difficult to meet the requirement of participation of thousands of users at the same time. Even though some schemes may implement tens of thousands of community simulations, it is difficult to ensure that each user gets a good gaming experience when a large number of users send instructions at the same time. Thus, there is a need to further enhance crowd simulation and precision control capabilities of game engines to address this problem.
In order to solve the above technical problems, please refer to fig. 2, fig. 2 is a schematic flowchart of an intelligent agent motion control method in a multi-player online game according to an embodiment of the present invention, which can be applied to the server 120 of fig. 1, and includes the following steps:
s210, instantiating a plurality of agents according to the number of the game participants, and sending the agents into a virtual game space;
s220, constructing a Kd tree according to the position of the target agent in the virtual game space, and searching the nearest neighbor agent positioned in the action range of the agent based on the Kd tree; wherein the target agent is any one of all agents;
S230, determining a new speed and a new position of the next movement of the target intelligent agent according to the movement state of the nearest intelligent agent; the new speed is used for the collision-preventing nearest neighbor agent;
s240, controlling the target agent to move to a new position according to the new speed.
In the technical solution of the above steps S210 and S240, by instantiating a plurality of agents according to the number of game participants, and transmitting them into the virtual game space. The method means that the created agent can meet the requirement that thousands of users participate simultaneously, and then the Kd tree is built according to the position of the target agent in the virtual game space. The Kd-tree is a data structure for efficiently organizing and finding points in space. By constructing the Kd-tree, nearest neighbor agents near the target agent can be quickly found to support subsequent decisions and actions. And determining the new speed and the new position of the next movement of the target agent according to the movement state of the nearest neighbor agent. By analyzing the motion states of nearest neighbor agents, their possible action paths and collision risks can be predicted, and the motion strategies of the target agents can be adjusted accordingly to avoid collisions and maintain safety. The control target agent moves to a new location according to the new speed. Based on the calculated new speed and position, the target agent can be precisely controlled and moved to the corresponding position to achieve the actions and interactions required in the game.
In general, the embodiment of the invention can instantiate the intelligent agents on line in real time, is not influenced by the number of simultaneous online users, can simulate tens of thousands of groups, meets the requirement of simultaneous online game interaction of users, utilizes the Kd tree, motion planning and other technologies, can realize the cooperative action among multiple intelligent agents, avoid collision, improve the control precision of each intelligent agent and enhance the interaction experience of the online game of multiple people.
The above steps are explained in detail below.
In step S210, a plurality of agents are instantiated according to the number of game participants, and the plurality of agents are transmitted into the virtual game space.
In the embodiment of the invention, the real-time participation number data can be acquired through the game server interface. The corresponding number of agents is dynamically instantiated by ECS (Entity Component System) based on the number of participants. For each agent, an identification ID and other attributes may be set, such as configuring the initial maximum speed maxseed, target location targetPos, etc. attributes for each agent. And the client renders the corresponding agent entity in the game picture according to the received data.
As shown in fig. 3, fig. 3 is a schematic diagram of an agent according to an embodiment of the present invention. All agents can form an agent queue, in an actual scene, the changes of the number of participants can be monitored in real time, and the agents are dynamically added or reduced in the agent queue according to the changes.
As shown in fig. 4, fig. 4 is an agent emission schematic diagram provided in an embodiment of the present invention, in the embodiment of the present invention, an agent may be taken out through an agent queue of an agent emission system, and emitted to a virtual game space, where a position of each agent in the virtual game space after being emitted may be used as a current position as a starting point of the agent to perform a next movement.
In step S120, a Kd-tree is constructed according to the location of the target agent in the virtual game space, and nearest neighbor agents within the agent' S range of action are found based on the Kd-tree.
In the embodiment of the invention, the nearest neighbor agent of the target agent can be searched by constructing the Kd tree. The Kd tree construction method comprises the following steps:
(1) Selecting a dimension k where the maximum average value is located in a two-dimensional data set of the intelligent agent node, and then selecting an intermediate value m as a plane segmentation value in the dimension to divide the two-dimensional data set to obtain two sub-two-dimensional data sets (the dimension k is smaller than or equal to m is a left subtree set, and otherwise, the dimension k is a right subtree set); meanwhile, a tree node KdNode is created and used for storing node information such as < k, m >, left and right child nodes and the like.
(2) Repeating the step (1) process for both subsets until all two-dimensional data sets cannot be subdivided; if a subset can no longer be divided, the two-dimensional data (node information of the agent) in the subset is saved to the leaf node.
For example, the following is given as an example of a set of two-dimensional data sets: assuming that there are 6 agents, the coordinates of nodes corresponding to the 6 agents are: (6, 6) (1, 4) (3, 2) (4, 5) (7, 3) (9.7), obtaining a Kd tree shown in FIG. 5 according to the Kd tree construction method, wherein FIG. 5 is a schematic diagram of Kd tree construction based on a plurality of agents according to the embodiment of the invention. Wherein (a) in fig. 5 is an agent queue, (b) in fig. 5 is a two-dimensional data set corresponding to all agents in (a), (c) in fig. 5 is a schematic diagram of space division of the two-dimensional data set, and (d) in fig. 5 is a Kd-tree after construction.
It will be appreciated that constructing the Kd-tree results in a permutation array (Permutation Array) based on the fast-ranking results. This array holds the input data points (KdPoints array), i.e., the two-dimensional coordinates of the agent, in the index order after the quick sort. The node information of the tree node KdNode is:
start and end: a range (subscript range) indicating the range of the data point corresponding to this KdNode in the permutation array Permutation Array; for a leaf node, a specific data point coordinate value corresponding to the leaf node can be obtained from the original data KdPoints array through start and end subscripts.
Left and Right represent the Left and Right child nodes of the KdNode;
the partition axis indicates which dimension the KdNode is partitioned in. For convenience of distinction, different dimensions may be distinguished by different labels, and embodiments of the present invention will be illustrated in the following by way of two-dimensional dimensions, but embodiments of the present invention are not precluded from being applied to other higher dimensions.
For example, for two-dimensional data points, the two dimensions of x and y can be distinguished by, but are not limited to, different numbers, characters, and combinations thereof. For example, the x dimension is denoted by 0 and the y dimension is denoted by 1. For a leaf node, the partition axis is-1, indicating that no child nodes have needed to be subdivided.
partition coordinate, which coordinate value the KdNode is divided into;
bound represents the data space range to which the KdNode corresponds.
The node information is used in the subsequent search for the nearest neighbor agent, and therefore is explained and explained herein, and will not be explained later.
It will be appreciated that whenever a new agent is added, the Kd-tree needs to be updated according to the location of the new agent to ensure the accuracy of the control results.
Based on the Kd-tree constructed as described above, an embodiment of the present invention provides an implementation manner for the step S220, that is, the step S220 may include the following steps:
Step a1: determining nearest neighbor coordinate points of the target agent in the Kd tree, and constructing initial query points about the target agent;
the initial query point comprises a root node index which is searched in the Kd tree by utilizing the query point and a distance between the nearest coordinate point and the position of the target intelligent agent;
the embodiment of the invention can be carried out in the following way when an initial query point is constructed:
step a1-1: mapping the position of the target intelligent agent into a root node coordinate range, and taking the mapped point as a nearest neighbor coordinate point; the root node coordinate range is determined according to the positions of all the intelligent agents;
step a1-2: and forming an initial query point by the nearest neighbor coordinate point, the root node index of the Kd tree and the distance between the nearest neighbor coordinate point and the target intelligent agent.
Root node index, rootNode < k, m >, where k is the planar segmentation dimension of the root node and m is the planar segmentation value, for example, in the embodiment of the present invention, the planar segmentation dimensions x and y are denoted by 0 and 1, respectively, and in (d) in fig. 5, the index of root node a is <0,6>, that is, planar segmentation is performed on the x-axis, and the planar segmentation value is 6.
It will be appreciated that during a search using an initial query point, a new query point may be determined for a next search based on the search results, and during each round of searches, a new query point may be determined based on the search results, and a new node index contained within the new query point may be used to guide the next search, as will be described in detail in the subsequent embodiments of determining the new query point.
In the embodiment of the present invention, the purpose of step a1 is to limit the target agent to the boundary range of the root node for searching. The nearest neighbor coordinate point (denoted as P) is one coordinate point obtained by restricting the coordinates of the target agent (denoted as Q) within Bound of the root node. Bound is the boundary of the data set contained by the root node, i.e., the minimum and maximum x and y coordinate values in the two-dimensional data set of all agents.
Step a2: if the distance is smaller than the action range, searching downwards from the Kd tree by using the query point;
in the embodiment of the present invention, as shown in fig. 6, fig. 6 is a schematic diagram provided in the embodiment of the present invention, where the action range is a circular area with the search radius R and the query point as the center, and may be set according to actual needs.
Step a3: in each round of searching process, if the tree node participating in the searching is a leaf node, determining the nearest neighbor agent by utilizing the position of the agent stored in the tree node participating in the searching; otherwise, constructing a new query point by using the tree nodes participating in the search and the query points of the round;
in the embodiment of the invention, in each round of searching, the tree nodes participating in the searching are left and right child nodes of the node corresponding to the node index contained in the query point in the current round of query point.
For example, assuming that in the first round of searching, the query point includes the root node index, the tree nodes participating in the searching are the left and right child nodes of the root node. If the left and right child nodes are not leaf nodes, then in the next round of searching, the tree node participating in the search is the child node of the left and right child nodes, and so on. By the searching mode, the searching subtrees can be continuously determined in the Kd tree, the searching range is reduced, and the searching efficiency is improved. It can be summarized that: the tree nodes participating in the search are the left and right child nodes of the tree node participating in the search in the previous round.
Then there are two cases in the search process:
case one: the tree nodes participating in the search are leaf nodes.
If the tree node participating in the search is a leaf node, the nearest neighbor agent can be directly determined from agents corresponding to the positions stored in the leaf node because the leaf node has no child nodes to be subdivided.
Specifically, a distance between the position of the agent and the position of the target agent may be determined, and an agent corresponding to a distance smaller than the action range may be taken as the nearest neighbor agent. If no other query point exists, the search may be ended, and if so, the step a3 may be continued.
And a second case: the tree nodes participating in the search are not leaf nodes.
If the tree node participating in the search is not a leaf node, a new query node needs to be constructed from the search results of the tree node for the next round of search. Specifically, the coordinate value P [ k ] of the query point on the splitting plane of the tree node can be compared with m corresponding to the tree node, and different query point construction modes can be determined to be executed according to the comparison result, and the method is divided into the following two sub-cases:
sub-case one: p [ k ] <=m, the query point construction mode is as follows: updating the parent node index in the query points to the left child node index of the tree node to obtain a new query point, and updating the partition value and the right child node index of the tree node to obtain another new query point;
sub-case one: p [ k ] > m, the construction mode of the query point is as follows: updating the parent node index in the query points to the right child node index of the tree node to obtain a new query point, and updating the query point by the segmentation value and the left child node index of the tree node to obtain another new query point.
In the two query point construction modes, the process of updating the query point according to the segmentation value and the child node index is involved. Taking a sub-case as an example, the specific way to update the query point is as follows:
And replacing the coordinate value of the query point on the splitting plane of the tree node participating in the search with a splitting value, calculating a new distance between the target intelligent agent by utilizing the replaced coordinate, and forming a new query point by utilizing the replaced coordinate, the new distance and the right child node index.
For convenience of understanding, assuming that the query point is Q, P constitutes a coordinate point of Q, a tree node participating in the search is denoted as KdNode, and a kth dimension coordinate value P [ k ] of P is compared with m of KdNode.
If P [ k ]]M is less than or equal to m, and a query point is formed by the left child node index of KdNode and the Distance between P and Q, which means that onlyThe node index of the cause in Q needs to be replaced with the left child node index, and P and Distance are unchanged. Further, updating the k-th dimensional coordinate of P to m to obtain P new And index the right child node of KdNode, P new P new Distance from Q constitutes a query point, meaning that both the P, distance and node indices within Q need to be updated.
Similarly, if P [ k ]]And when the Distance is larger than m, forming a query point by the right child node index of the KdNode and the distances between P and Q. Meanwhile, updating the k-th dimensional coordinate of P to m to obtain P new And index the left child node of KdNode, P new P new Distance from Q constitutes a query point.
Step a4: and returning to the step of searching downwards from the Kd tree by using the query point if the distance between the query point and the position of the intelligent agent is smaller than the action range according to the updated query point until the query point does not exist.
In the steps a1 to a4, in order to improve the processing efficiency, the query points determined in each searching process may be saved in a small heap queue (denoted as miniHeapQuue), and each time the query points are taken out from the miniHeapQuue, step a3 is performed until the miniHeapQuue is empty. Similarly, a set of neighboring points (denoted as reseMiniHeapQueue) may be provided to store the determined nearest neighbor agent.
The above steps a1 to a4 may also be described from the viewpoint of codes.
(1) And calculating the nearest neighbor coordinate point P of the Q in the Kd tree, and constructing a query point about the Q.
Wherein p=clip (Q, rootNode.Bound.Min, rootNode.Bound.Max); bound represents the data space range in Root Node; min= (minX, min Y), max= (maxX, maxY), and the query point Qnode composed of the Distance between the RootNode index Index, P, P and Q is saved to miniHeapQuue.
(2) Taking out the node Qnode from the miniHeapQueue, wherein P=Qnode.P, if the distance of the Qnode is smaller than R, comparing P with an intermediate node KdNode (k, m), otherwise, repeating the step 2;
(2-1) when KdNODE is not a leaf node, ifP[k]<=m, saving the query point composed of KdNode. Left child node index, P and Q Distance to miniHeapQuue, and updating P [ k ]]=m, yielding P new Indexing KNODE right child node and P new 、P new The query points formed by the Distance and the Q are stored in a minisize HeapQueue; otherwise, the inquiry point composed of KdNode right node index, P and Q Distance is saved to miniHeapQueue, and P [ k ] is updated at the same time]M gives P new Indexing KNODE. Left child node and P new 、P new The query points formed by the Distance and the Q are stored in a minisize HeapQueue;
(2-2) traversing the two-dimensional data node saved by the leaf node when KdNode is the leaf node, and saving D to the resMiniHeapQuue if the distance between the two-dimensional data node D and Q is < =R;
and (3) repeating the step (2) until the miniHeapQuue is empty, and ending the search, obtaining a neighbor point set resMniHeapQuue in the range of the Q point R, and then taking out the resMniHeapQuue data and returning the resMniHeapQuue data to the neighbors.
After determining the nearest neighbor agent of the target agent, the new speed of the target agent can be determined based on the anti-collision principle according to the motion state of the nearest neighbor agent, i.e. step S230 is executed.
In step S130, a new speed of the next movement of the target agent may be determined using an optimal reciprocal collision avoidance algorithm based on the movement state of the nearest neighbor agent.
The optimal reciprocal collision avoidance algorithm is the prior art, and will not be described here again.
After determining the new velocity of the target agent, a movement position within a predetermined time period in the future may be determined based on the new velocity, and a new position may be determined based on the movement position and the current position.
In the above embodiment, the new speed of the target agent is determined by considering the motion state of the nearest neighbor agent by using the optimal reciprocal collision avoidance algorithm, the movement strategy is better planned by considering the motion information of the surrounding agents, collision between agents is effectively avoided, which plays a key role in precise control of millions of agents, once the new speed of the target agent is determined, the movement position in a future period of time can be predicted according to the speed, and the new position of the target agent can be determined by combining the current position and the movement position. This helps the agent to accurately locate and navigate in the environment, thereby better completing tasks and avoiding collisions with other agents.
In step S240, controlling the movement of the target agent toward the target location according to the determined new speed and new location may include the steps of:
Step d1: an expected angle of orientation is determined based on the expected speed of the target agent.
In the embodiment of the invention, the expected speed is obtained by:
(a) And determining a target speed vector according to the target position and the current position of each target intelligent agent. Where the target velocity vector globallowability=target position targetPos-current position curPos.
(b) The predicted speed is calculated using the initial maximum speed of the target agent and the target speed vector. Where predicted speed prefvelocity=target speed globallowability, initial maximum speed maxseed.
It should be noted that the speeds involved in the embodiments of the present invention have both directions and magnitudes. For the predicted speed, the direction of the target speed is toward the target position of the target agent, so when the target agent is controlled to move according to the new speed, the current direction of the target agent needs to be adjusted to be toward the target position, and the target agent always moves toward the target position. Therefore, the embodiment of the invention adopts the mode of the step d2 to adjust the current orientation.
Step d2: and rotating the target intelligent agent from the current orientation according to the expected orientation included angle to obtain a new orientation.
Step d3: the control target agent moves to a new location at a new speed in accordance with the new direction.
The above steps d1 to d3 may also be explained from the code point of view. Such as:
first, the speed vector angle=math.atan2 (prefVecity) of the predicted speed.
Where angle=math.atan2 (prefVelocity) is used to calculate the angle between the velocity vector of the predicted velocity and the current heading. math.atan2 () is a mathematical function used to calculate the included angle.
New heading = math. Slip (current heading, quaternion. Rotation (angle), 0.33 f).
Where math.slip () uses spherical interpolation (Slerp) to calculate the new orientation. math.slirp () is an interpolation function that accepts three parameters: current orientation (currRation), a rotation matrix (rotation) with a pre-speed angle as a rotation angle, and an interpolation factor (0.33 f, representing the weight of interpolation). The function interpolates the current orientation and rotation matrix according to the interpolation factor to obtain a new orientation (newRotation).
New location newpos=current location curpos+newvector
The current location curPos represents the location where the target agent is currently located. newVecity: a speed vector representing a new speed, timeStep representing a time step, may be set according to a game screen rendering time interval by summing the current position and the expected amount of movement to obtain a new position of the target agent within the next time step.
Through the above steps d1 to d3, the orientation of the target agent can be predicted, which enables the agent to navigate and route plan in advance according to the predicted orientation, avoiding collisions and collisions. By rotating the target agent from the current orientation by the desired orientation angle, a new orientation may be obtained. The direction adjustment enables the intelligent body to adjust the moving direction according to the expected direction, reduces position deviation and errors and improves the accuracy of navigation and path planning.
Based on the same inventive concept as fig. 2, the embodiment of the present invention further provides an agent motion control device 300 in a multiplayer online game, referring to fig. 7, fig. 7 is a functional block diagram of the agent motion control device 300 in a multiplayer online game provided in the embodiment of the present invention, where the agent motion control device 200 in a multiplayer online game may include: the simulation module 310, the lookup module 320, the determination module 330, and the control module 340.
A simulation module 310 for instantiating a plurality of agents according to the number of game participants and transmitting the plurality of agents into a virtual game space;
the searching module 320 is configured to construct a Kd tree according to a position of the target agent in the virtual game space, and search a nearest neighbor agent located in an action range of the agent based on the Kd tree; wherein the target agent is any one of all agents;
A determining module 330, configured to determine a new speed and a new position of the next movement of the target agent according to the movement state of the nearest neighbor agent; the new speed is used for the collision-preventing nearest neighbor agent;
and a control module 340 for controlling the target agent to move to a new location according to the new speed.
It will be appreciated that the simulation module 310, the search module 320, the determination module 330 and the control module 340 may cooperatively perform the respective steps in fig. 2 to achieve the corresponding technical effects.
In an alternative embodiment, the search module 320 is specifically configured to: determining nearest neighbor coordinate points of the target agent in the Kd tree, and constructing initial query points about the target agent; the initial query points comprise tree node indexes, nearest neighbor coordinate points and distances between the nearest neighbor coordinate points and the positions of the target intelligent agents, wherein the tree node indexes are searched in the Kd tree by utilizing the query points; if the distance is smaller than the action range, searching downwards from the Kd tree by using the query point; in each round of searching process, if the tree node participating in the searching is a leaf node, determining the nearest neighbor agent by utilizing the position of the agent stored in the tree node participating in the searching; otherwise, constructing a new query point by using the tree nodes participating in the search and the query points of the round; and returning to the step of searching downwards from the Kd tree by using the query point if the distance is smaller than the action range according to the new query point until the query point does not exist.
In an alternative embodiment, the searching module 320 is further specifically configured to: if the coordinate value of the query point on the splitting plane of the tree node participating in the search is smaller than or equal to the splitting value corresponding to the tree node, updating the node index in the query point to the left sub-node index of the tree node to obtain a new query point, and then updating the query point by using the splitting value and the right sub-node index of the tree node to obtain another new query point; otherwise, updating the node index in the query point to the right sub-node index of the tree node to obtain a new query point, and then updating the query point by using the partition value and the left sub-node index of the tree node to obtain another new query point.
In an alternative embodiment, the searching module 320 is further specifically configured to: and replacing the coordinate values by using the segmentation values to obtain updated coordinate points, and forming another new query point by using the updated coordinate points, the right child node indexes and the distances between the updated coordinate points and the positions of the target intelligent agents.
In an alternative embodiment, the searching module 320 is further specifically configured to: mapping the position of the target intelligent agent into a root node coordinate range, and taking the mapped point as a nearest neighbor coordinate point; the root node coordinate range is determined according to the positions of all the intelligent agents;
And forming an initial query point by the nearest neighbor coordinate point, the root node index of the Kd tree and the distance between the nearest neighbor coordinate point and the target intelligent agent.
In an alternative embodiment, the searching module 320 is further specifically configured to: and determining the distance between the position of the intelligent agent and the position of the target intelligent agent, and taking the intelligent agent corresponding to the distance smaller than the action range as the nearest neighbor intelligent agent.
In an alternative embodiment, the determining module 330 is specifically configured to: determining a new speed of the next movement of the target intelligent agent by utilizing an optimal reciprocal collision avoidance algorithm according to the movement state of the nearest intelligent agent; and determining the moving position in a preset time period in the future according to the new speed, and determining the new position according to the moving position and the current position of the target intelligent agent.
In an alternative embodiment, the control module 340 is specifically configured to: determining an expected orientation angle according to the expected speed of the target intelligent agent; rotating the target intelligent agent from the current orientation according to the expected orientation included angle to obtain a new orientation; controlling the target agent to move to a new position at a new speed according to the new direction; the predicted speed is obtained by determining a target speed vector according to the target position and the current position of each target agent, and calculating the predicted speed by using the initial maximum speed of the target agent and the target speed vector.
It should be noted that, in the above embodiments of the present application, the division of the modules is merely schematic, and there may be another division manner in actual implementation, and in addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or may exist separately and physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in part or all or part of the technical solution contributing to the prior art or in the form of a software product stored in a storage medium, including several instructions to cause an electronic device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of the methods of the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Based on the foregoing embodiments, the embodiments of the present application further provide an electronic device, please refer to fig. 8, fig. 8 is a block diagram of an electronic device provided by an embodiment of the present invention, where the electronic device is configured to execute the method for controlling movement of an agent in a multiplayer online game provided by the embodiment of the present invention, and the electronic device 400 includes: the memory 401, the processor 402, the communication interface 403, and the bus 404 are electrically connected directly or indirectly to each other, so as to realize data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines.
Alternatively, bus 404 may be a peripheral component interconnect standard (peripheral component interconnect, PCI) bus, or an extended industry standard architecture (extended industry standard architecture, EISA) bus, among others. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, only one thick line is shown in fig. 8, but not only one bus or one type of bus.
In the embodiments of the present application, the processor 402 may be a general purpose processor, a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, where the methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. The general purpose processor may be a microprocessor or any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be embodied directly in a hardware processor for execution, or in a combination of hardware and software modules in the processor for execution. The software module may be located in the memory 401 and the processor 402 reads the program instructions in the memory 401, in combination with its hardware, to perform the steps of the method described above.
In the embodiment of the present application, the memory 401 may be a nonvolatile memory, such as a hard disk (HDD) or a Solid State Drive (SSD), or may be a volatile memory (RAM). The memory may also be any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. The memory in the embodiments of the present application may also be a circuit or any other device capable of implementing a memory function, for storing instructions and/or data.
The memory 401 may be used to store software programs and modules, such as instructions/modules of the agent motion control apparatus 200 in the multiplayer online game provided in the embodiment of the present invention, may be stored in the memory 401 in the form of software or firmware (firmware) or be solidified in an Operating System (OS) of the electronic device 400, and the processor 402 executes the software programs and modules stored in the memory 401, thereby executing various functional applications and data processing. The communication interface 403 may be used for communication of signaling or data with other node devices.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus and units described above may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again.
It is to be understood that the configuration shown in fig. 8 is merely illustrative, and that the electronic device 400 may also include more or fewer components than those shown in fig. 8, or have a different configuration than that shown in fig. 8. The components shown in fig. 8 may be implemented in hardware, software, or a combination thereof.
The electronic device 400 may be any electronic product that can interact with a user, such as a personal computer, tablet computer, personal digital assistant (Personal Digital Assistant, PDA), etc.
The electronic device 400 may also include network devices and/or user devices. Network devices include, but are not limited to, a single network server, a server group of multiple network servers, or a Cloud based Cloud Computing (Cloud Computing) composed of a large number of hosts or network servers.
The network in which the electronic device 400 is located includes, but is not limited to, the internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (Virtual Private Network, VPN), and the like.
Based on the above embodiments, the present application further provides a computer readable storage medium, in which a computer program is stored, which when executed by a computer, causes the computer to execute the method for controlling the movement of an agent in a multiplayer online game provided in the above embodiments.
Based on the above embodiments, the present application further provides a computer program, which when executed on a computer, causes the computer to execute the method for controlling the movement of an agent in a multiplayer online game provided in the above embodiments.
Based on the above embodiments, the embodiments of the present application further provide a chip, where the chip is configured to read a computer program stored in a memory, and is configured to execute the method for controlling movement of an agent in a multiplayer online game provided in the above embodiments.
Also provided in an embodiment of the present application is a computer program product comprising instructions that, when run on a computer, cause the computer to perform the method for controlling movement of an agent in a multiplayer online game provided in the above embodiment.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by instructions. These instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The present invention is not limited to the above embodiments, and any changes or substitutions that can be easily understood by those skilled in the art within the technical scope of the present invention are intended to be included in the scope of the present invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.

Claims (11)

1. A method for controlling movement of an agent in a multiplayer online game, the method comprising:
instantiating a plurality of agents according to the number of game participants, and transmitting the plurality of agents into a virtual game space;
constructing a Kd tree according to the position of a target intelligent agent in the virtual game space, and searching a nearest neighbor intelligent agent positioned in the action range of the intelligent agent based on the Kd tree; wherein the target agent is any one of the agents;
determining a new speed and a new position of the next movement of the target intelligent agent according to the movement state of the nearest intelligent agent; the new speed is used to collision the nearest neighbor agent;
and controlling the target intelligent agent to move to the new position according to the new speed.
2. The method for controlling the movement of an agent in a multiplayer online game according to claim 1, wherein searching for nearest neighbor agents within the action range of the agent based on a Kd-tree comprises:
determining nearest neighbor coordinate points of the target agent in the Kd tree, and constructing initial query points about the target agent; the initial query points comprise tree node indexes searched in the Kd tree by utilizing the query points, the nearest coordinate points and the distances between the nearest coordinate points and the positions of the target intelligent agents;
If the distance is smaller than the action range, searching downwards from the Kd tree by utilizing the query point;
in each searching process, if the tree node participating in the searching is a leaf node, determining the nearest neighbor agent by utilizing the position of the agent stored in the tree node participating in the searching; otherwise, constructing a new query point by using the tree nodes participating in the search and the query points of the round;
and returning to the step of searching downwards from the Kd tree by utilizing the query point if the distance is smaller than the action range according to the new query point until the query point does not exist.
3. The method for controlling the movement of an agent in a multiplayer online game according to claim 2, wherein constructing a new query point using the tree node participating in the search and the current round of query points comprises:
if the coordinate value of the query point on the splitting plane of the tree node participating in the search is smaller than or equal to the splitting value corresponding to the tree node, updating the node index in the query point to the left child node index of the tree node to obtain a new query point, and then updating the query point by using the splitting value and the right child node index of the tree node to obtain another new query point; otherwise the first set of parameters is selected,
And updating the node index in the query point to the right sub-node index of the tree node to obtain a new query point, and updating the query point by using the segmentation value and the left sub-node index of the tree node to obtain another new query point.
4. The method of claim 3, wherein updating the query point using the partition value and the index of the right child node of the tree node to obtain another new query point comprises:
and replacing the coordinate value by the segmentation value to obtain an updated coordinate point, and then forming the other new query point by using the updated coordinate point, the right child node index and the distance between the updated coordinate point and the position of the target intelligent agent.
5. The method of claim 2, wherein determining nearest neighbor coordinate points of the target agent in the Kd-tree and constructing an initial query point for the target agent, comprises:
mapping the position of the target intelligent agent into a root node coordinate range, and taking the mapped point as the nearest neighbor coordinate point; the root node coordinate range is determined according to the positions of all the agents;
And forming the initial query point by the nearest neighbor coordinate point, the root node index of the Kd tree and the distance between the nearest neighbor coordinate point and the target intelligent agent.
6. The method for controlling the movement of agents in a multiplayer online game according to claim 2, wherein determining the nearest neighbor agent using the positions of the agents stored in the tree nodes participating in the search, comprises:
and determining the distance between the position of the intelligent agent and the position of the target intelligent agent, and taking the intelligent agent corresponding to the distance smaller than the action range as the nearest intelligent agent.
7. The method for controlling the movement of an agent in a multiplayer online game according to claim 1, wherein determining a new speed and a new position of the next movement of the target agent comprises:
determining a new speed of the next movement of the target intelligent agent by utilizing an optimal reciprocal collision avoidance algorithm according to the movement state of the nearest intelligent agent;
and determining a moving position in a preset time period in the future according to the new speed, and determining the new position according to the moving position and the current position of the target intelligent agent.
8. The method of claim 1, wherein controlling the target agent to move to the new location according to the new speed comprises:
determining an expected orientation angle according to the expected speed of the target intelligent agent;
rotating the target intelligent agent from the current direction according to the expected direction included angle to obtain a new direction;
and controlling the target intelligent agent to move to the new position at the new speed according to the new direction.
9. The method for controlling the movement of an agent in a multiplayer online game as recited in claim 8, wherein the predicted speed is obtained by:
and determining a target speed vector according to the target position and the current position of each target intelligent agent, and calculating the expected speed by utilizing the initial maximum speed of each target intelligent agent and the target speed vector.
10. An intelligent body movement control device in a multi-player online game is characterized in that,
the simulation module is used for instantiating a plurality of agents according to the number of game participants and sending the agents to the virtual game space;
the searching module is used for searching nearest neighbor agents in the action range of the agents according to the current position of each agent in the virtual game space;
The determining module is used for determining a new speed and a new position of the next movement of the intelligent body; the new speed is used to collision the nearest neighbor agent;
and the control module is used for controlling the intelligent body to move to the new position according to the new speed.
11. An electronic device comprising a processor and a memory, the memory storing a computer program executable by the processor, the processor executable by the computer program to implement the method of controlling the movement of an agent in a multiplayer online game as claimed in any one of claims 1 to 9.
CN202311675617.9A 2023-12-07 2023-12-07 Method and device for controlling movement of intelligent body in multi-player online game and electronic equipment Pending CN117695652A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311675617.9A CN117695652A (en) 2023-12-07 2023-12-07 Method and device for controlling movement of intelligent body in multi-player online game and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311675617.9A CN117695652A (en) 2023-12-07 2023-12-07 Method and device for controlling movement of intelligent body in multi-player online game and electronic equipment

Publications (1)

Publication Number Publication Date
CN117695652A true CN117695652A (en) 2024-03-15

Family

ID=90149066

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311675617.9A Pending CN117695652A (en) 2023-12-07 2023-12-07 Method and device for controlling movement of intelligent body in multi-player online game and electronic equipment

Country Status (1)

Country Link
CN (1) CN117695652A (en)

Similar Documents

Publication Publication Date Title
EP2425602B1 (en) Position tracking in a virtual world
US7537523B2 (en) Dynamic player groups for interest management in multi-character virtual environments
JP5887458B1 (en) A game system for searching for a route of a non-player character based on a player&#39;s movement history
US6801930B1 (en) Method and apparatus for maintaining information about users sharing the cells partitioning a computer-generated environment
CN110755848B (en) Path finding method in game, terminal and readable storage medium
CN110812844A (en) Path finding method in game, terminal and readable storage medium
CN109529338A (en) Object control method, apparatus, Electronic Design and computer-readable medium
JP2017144234A (en) Battlefield online game for achieving expansion reality by utilizing iot equipment
CN112057858B (en) Virtual object control method, device, equipment and storage medium
CN111921195B (en) Three-dimensional scene generation method and device, storage medium and electronic device
CN110716766A (en) Game scene loading method and device, computer readable medium and electronic equipment
CN111389007B (en) Game control method and device, computing equipment and storage medium
CN117695652A (en) Method and device for controlling movement of intelligent body in multi-player online game and electronic equipment
Chen et al. A path-assisted dead reckoning algorithm for distributed virtual environments
KR20190108512A (en) Apparatus and method for improving the processing speed of a game implementing multi-threaded
CN114288662A (en) NPC behavior control method and device and electronic equipment
JP7408213B2 (en) Virtual application object output method, device and computer program
KR101492248B1 (en) Method and apparatus for targeting object appeared in on-line game
CN115212575B (en) Continuous state space intelligent agent construction method
CN116797769B (en) Data processing method, device, computer equipment and readable storage medium
CN113590334B (en) Method, device, medium and electronic equipment for processing character model
KR20180094370A (en) Mobile puzzle game system and smart device for improving creativity by a chain of simple rule based on touch action, and computer-readable recording medium with providing of improving creativity by a chain of simple rule based on touch action
CN117753004A (en) Message display method, device, equipment, medium and program product
Toshimori et al. A perfect play in 4× 12 board of Othello
CN115337645A (en) Virtual robot action determining method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination