Behavior control method, device, electronic device and computer-readable storage medium

By using the first blackboard variable to pass input parameters in the target behavior tree, the problem of reducing development efficiency caused by the construction of different behavior trees is solved, and the reuse of the target behavior tree and the improvement of development efficiency is achieved.

CN114307159BActive Publication Date: 2025-05-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210008857.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-06
Publication Date
2025-05-27
Estimated Expiration
2042-01-06

AI Technical Summary

Technical Problem

Different behaviors require the construction of different behavior trees, resulting in reduced development efficiency.

Method used

The input parameters are passed to the target node on the target behavior tree through the first blackboard variable in the target behavior tree, and the target node is run based on the input parameters to control the target role to perform the corresponding target behavior.

Benefits of technology

The reuse rate of the target behavior tree is improved, and the need for different behaviors to build different behavior trees is reduced, thereby improving development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114307159B_ABST
    Figure CN114307159B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a behavior control method, apparatus, electronic device, and computer-readable storage medium; in the embodiments of the present application, input parameters for a target behavior of a target role are obtained; the input parameters are passed to a first blackboard variable in a target behavior tree corresponding to the target role, and the target behavior tree includes different behaviors of the target role; the input parameters are passed to a target node on the target behavior tree through the first blackboard variable; based on the input parameters, the target node is run to control the target role to execute the target behavior corresponding to the input parameters. The embodiments of the present application can improve the reuse rate of the target behavior tree, and thus improve the development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and particularly to a behavior control method, apparatus, electronic device, and computer-readable storage medium. Background Art

[0002] With the development of artificial intelligence technology, the application of artificial intelligence technology is becoming more and more extensive. For example, artificial intelligence technology is applied to control non-player characters in games.

[0003] For the sake of convenience in implementation, the execution logic of the behavior of non-player characters is encapsulated in a behavior tree. However, currently, a single behavior tree can only execute specific behaviors, resulting in the need to construct different behavior trees for different behaviors, which is rather troublesome and reduces the development efficiency. Summary of the Invention

[0004] Embodiments of this application provide a behavior control method, apparatus, electronic device, and computer-readable storage medium, which can solve the technical problem of reduced development efficiency caused by the need to construct different behavior trees for different behaviors.

[0005] A behavior control method includes:

[0006] Obtaining input parameters for a target behavior of a target character;

[0007] Transmitting the input parameters to a first blackboard variable in a target behavior tree corresponding to the target character, where the target behavior tree includes different behaviors of the target character;

[0008] Transmitting the input parameters to a target node on the target behavior tree through the first blackboard variable;

[0009] Based on the input parameters, running the target node to control the target character to execute the target behavior corresponding to the input parameters.

[0010] Correspondingly, embodiments of this application provide a behavior control apparatus, including:

[0011] An obtaining module, configured to obtain input parameters for a target behavior of a target character;

[0012] A first transmission module, configured to transmit the input parameters to a first blackboard variable in a target behavior tree corresponding to the target character, where the target behavior tree includes different behaviors of the target character;

[0013] A second transmission module, configured to transmit the input parameters to a target node on the target behavior tree through the first blackboard variable;

[0014] A running module, configured to run the above-mentioned target node based on the above-mentioned input parameters, so as to control the above-mentioned target character to execute the target behavior corresponding to the above-mentioned input parameters.

[0015] Optionally, the above-mentioned first transmission module is specifically configured to execute:

[0016] Transmit the above-mentioned input parameters to the target conversion class in the above-mentioned target behavior tree through the above-mentioned first blackboard variable;

[0017] Convert the format of the above-mentioned input parameters through the above-mentioned target conversion class to obtain target parameters, and transmit the above-mentioned target parameters to the target node on the above-mentioned target behavior tree;

[0018] Correspondingly, the above-mentioned running module is specifically configured to execute:

[0019] Run the target node based on the target parameters, so as to control the target character to execute the target behavior corresponding to the input parameters.

[0020] Optionally, the above-mentioned target behavior tree is a subtree of an external behavior tree.

[0021] Correspondingly, the above-mentioned first transmission module is specifically configured to execute:

[0022] Load the above-mentioned target behavior tree through a pre-constructed loading class node in the external behavior tree;

[0023] Transmit the above-mentioned input parameters to the above-mentioned loading class node;

[0024] Transmit the above-mentioned input parameters to the first blackboard variable in the target behavior tree corresponding to the target character through the above-mentioned loading class node.

[0025] Optionally, the above-mentioned behavior control device further includes:

[0026] A construction and encapsulation module, configured to:

[0027] Construct a target blackboard, the target blackboard includes a first target blackboard, and the first target blackboard includes a first blackboard variable for storing and transmitting input parameters;

[0028] Construct a behavior tree class;

[0029] Encapsulate the codes of different behaviors by using the behavior tree class and the target blackboard to obtain a target behavior tree.

[0030] Optionally, the above-mentioned behavior control device further includes:

[0031] A display module, configured to display a control corresponding to the first blackboard variable on an electronic device including the target behavior tree.

[0032] Correspondingly, the acquisition module is configured to execute:

[0033] Obtain the input parameters corresponding to the target behavior for the target role through the above-mentioned controls.

[0034] The construction encapsulation module is specifically used to execute:

[0035] Construct a target conversion class;

[0036] Use the above-mentioned behavior tree class, the above-mentioned target blackboard, and the above-mentioned target conversion class to encapsulate the code of different behaviors to obtain a target behavior tree.

[0037] Optionally, the variable types of the above first blackboard variables include a selection blackboard variable type and an editable blackboard variable type.

[0038] Correspondingly, the above first transfer module is specifically used to execute:

[0039] Determine the variable type of the above input parameters;

[0040] If the variable type of the above input parameters is the above selection blackboard variable type, then pass the above input parameters to the first blackboard variable corresponding to the selection blackboard variable type in the target behavior tree corresponding to the target role;

[0041] If the variable type of the above input parameters is the above editable blackboard variable type, then pass the above input parameters to the first blackboard variable corresponding to the editable blackboard variable type in the target behavior tree corresponding to the target role.

[0042] In addition, an embodiment of the present application further provides an electronic device, including a processor and a memory. The above memory stores a computer program, and the above processor is used to run the computer program in the above memory to implement the behavior control method provided by the embodiment of the present application.

[0043] In addition, an embodiment of the present application further provides a computer-readable storage medium. The above computer-readable storage medium stores a computer program, and the above computer program is suitable for being loaded by a processor to execute any one of the behavior control methods provided by the embodiment of the present application.

[0044] In addition, an embodiment of the present application further provides a computer program product, including a computer program, and the computer program implements any one of the behavior control methods provided by the embodiment of the present application when executed by a processor.

[0045] In the embodiment of the present application, first obtain the input parameters of the target behavior for the target role. Then pass the input parameters to the first blackboard variable in the target behavior tree corresponding to the target role. The target behavior tree includes different behaviors of the target role. Then pass the input parameters to the target node on the target behavior tree through the first blackboard variable. Finally, based on the input parameters, run the target node to control the target role to execute the target behavior corresponding to the input parameters.

[0046] That is, in the embodiments of the present application, since the input parameters of the target behavior of the target role can be passed to the target node on the target behavior tree through the first blackboard variable in the target behavior tree, and finally, based on the input parameters, the target node is run to control the target role to execute the target behavior corresponding to the input parameters. Therefore, different behaviors of the target role can be included in the target behavior tree, and then different input parameters can enable the target role to execute different behaviors in the target behavior tree, thereby improving the reuse rate of the target behavior tree and further improving the development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0048] Figure 1 is a schematic diagram of the scenario of the behavior control process provided by the embodiments of the present application;

[0049] Figure 2 is a schematic flowchart of the behavior control method provided by the embodiments of the present application;

[0050] Figure 3 is a schematic diagram of the loading class provided by the embodiments of the present application;

[0051] Figure 4 is a schematic diagram of the target blackboard provided by the embodiments of the present application;

[0052] Figure 5 is a schematic diagram of the behavior tree class provided by the embodiments of the present application;

[0053] Figure 6 is a schematic diagram of the first target blackboard provided by the embodiments of the present application;

[0054] Figure 7 is a schematic flowchart of passing the input parameters to the first blackboard variable provided by the embodiments of the present application;

[0055] Figure 8 is a schematic diagram of the target behavior tree provided by the embodiments of the present application;

[0056] Figure 9 is a schematic diagram of the encapsulation of the target behavior tree provided by the embodiments of the present application;

[0057] Figure 10 is a schematic diagram of another target behavior tree provided by the embodiments of the present application;

[0058] Figure 11 It is a schematic flowchart of another behavior control method provided by an embodiment of the present application;

[0059] Figure 12 A schematic diagram of another target behavior tree provided by an embodiment of the present application;

[0060] Figure 13 It is a schematic structural diagram of a behavior control device provided by an embodiment of the present application;

[0061] Figure 14 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0062] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application.

[0063] An embodiment of the present application provides a behavior control method, device, and computer-readable storage medium. Among them, the behavior control device can be integrated in an electronic device, and the electronic device can be a server or a terminal device, etc.

[0064] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and big data and artificial intelligence platforms.

[0065] Moreover, multiple servers can form a blockchain, and the server is a node on the blockchain.

[0066] The terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal and the server can be directly or indirectly connected through wired or wireless communication methods, and the present application does not limit this here.

[0067] For example, as Figure 1As shown in the figure, the terminal can obtain the input parameters of the target behavior for the target character; pass the input parameters to the first blackboard variable in the target behavior tree corresponding to the target character, where the target behavior tree includes different behaviors of the target character; pass the input parameters to the target node on the target behavior tree through the first blackboard variable; and based on the input parameters, run the target node to control the target character to execute the target behavior corresponding to the input parameters.

[0068] In addition, "multiple" in the embodiments of the present application means two or more. "First", "second", etc. in the embodiments of the present application are used for distinguishing descriptions and should not be construed as implying relative importance.

[0069] The following will be described in detail respectively. It should be noted that the description order of the following embodiments does not limit the preferred order of the embodiments.

[0070] For the convenience of implementation, the execution logic of the behavior of non-player characters is encapsulated in the behavior tree. However, currently, a behavior tree can only execute specific behaviors, resulting in the need to construct different behavior trees for different behaviors, which is rather troublesome and reduces the development efficiency.

[0071] For example, Behavior Tree 1 is to control a non-player character to move from position A to position B, and during the process of moving from position A to position B, the probability of the non-player character sliding is 0.5 and the probability of jumping is 0.2. If during the process of moving from position A to position B, the probability of the non-player character sliding is 0.7 and the probability of jumping is 0.1, then another behavior tree needs to be constructed, that is, Behavior Tree 2, where Behavior Tree 2 is to control a non-player character to move from position A to position B, and during the process of moving from position A to position B, the probability of the non-player character sliding is 0.7 and the probability of jumping is 0.1.

[0072] That is, the parameters of the current behavior tree are fixed and cannot be modified. When the parameters of the behavior tree need to be modified, another behavior tree needs to be constructed, which is rather troublesome and reduces the development efficiency.

[0073] To solve the technical problem of reduced development efficiency caused by the need to construct different behavior trees for different behaviors, the present application provides a behavior control method. In this method, first, obtain the input parameters of the target behavior for the target character. Then pass the input parameters to the first blackboard variable in the target behavior tree corresponding to the target character, where the target behavior tree includes different behaviors of the target character. Next, pass the input parameters to the target node on the target behavior tree through the first blackboard variable. Finally, based on the input parameters, run the target node to control the target character to execute the target behavior corresponding to the input parameters.

[0074] That is, in the embodiments of the present application, since the input parameters of the behavior of the target role can be passed to the target node on the target behavior tree through the first blackboard variable in the target behavior tree, and finally, based on the input parameters, the target node is run to control the target role to execute the target behavior corresponding to the input parameters. Therefore, the target behavior tree can include different behaviors of the target role, and then different input parameters can enable the target role to execute different behaviors in the target behavior tree, thereby improving the reuse rate of the target behavior tree and further improving the development efficiency.

[0075] In this embodiment, a description will be made from the perspective of the behavior control device. The behavior control device can be specifically integrated in devices such as a server or a terminal. For the convenience of explaining the behavior control method of the present application, the following will take the behavior control device integrated in the terminal as an example for detailed description, that is, the terminal is used as the execution subject for detailed description.

[0076] Please refer to Figure 2 , Figure 2 which is a schematic flowchart of the behavior control method provided by an embodiment of the present application. The behavior control method may include:

[0077] S201. Obtain the input parameters for the target behavior of the target role.

[0078] When it is necessary for the target role to execute the target behavior, the input parameters of the target behavior can be input into the terminal, and the terminal thus obtains the input parameters for the target behavior of the target role.

[0079] The target role can be a non-player character (NPC) in a game. The target behavior is the behavior that the target role needs to execute. For example, the target behavior can be the behavior of the target role moving from position A to position B, or the target behavior can be the behavior of the target role picking up something.

[0080] The input parameters refer to the parameters that need to be input when the target role executes the target behavior. For example, when the target behavior is the behavior of the target role moving from the current position to the target position and during the process of moving from the current position to the target position, the probability of the target role performing a slide tackle is 0.5 and the probability of jumping is 0.2, then the input parameters can be the target position, the probability of slide tackle 0.5, and the probability of jumping 0.2.

[0081] S202. Pass the input parameters to the first blackboard variable in the target behavior tree corresponding to the target role. The target behavior tree includes different behaviors of the target role.

[0082] After the terminal obtains the input parameters, it then passes the input parameters to the blackboard variables in the target behavior tree corresponding to the target role. Different behaviors of the target role include various behaviors of the target role, such as the moving position of the target role, picking up things, climbing over the wall, and turning around, etc.

[0083] The first blackboard variable is the blackboard variable of the first target blackboard in the target behavior tree, which can be used to pass and store input parameters, that is, the first target blackboard can store and pass input parameters through the first blackboard variable.

[0084] The blackboard refers to a component in the behavior tree, which can be used to store variables in the artificial intelligence system.

[0085] It should be noted that the target behavior tree may include a second target blackboard in addition to the first target blackboard. The first target blackboard is used to store and pass the input parameters obtained from outside the target behavior tree, that is, the first target blackboard is used to store and pass the external data of the target behavior tree, and the second target blackboard is used to store and pass the internal data of the target behavior tree.

[0086] When the target behavior tree is a subtree of the external behavior tree, if different behaviors need to construct different behavior trees, it will cause many target behavior trees to be included in the external behavior tree, resulting in a larger volume of the external behavior tree, a higher probability of errors in the external behavior tree, and a higher cost of maintaining the external behavior tree.

[0087] Therefore, in some embodiments, a loading class node is pre-constructed on the external behavior tree so that the target behavior tree can be loaded through the loading class node. Therefore, passing the input parameters to the first blackboard variable in the target behavior tree corresponding to the target role includes:

[0088] Loading the target behavior tree through the pre-constructed loading class node in the external behavior tree;

[0089] Passing the input parameters to the loading class node;

[0090] Passing the input parameters to the first blackboard variable in the target behavior tree corresponding to the target role through the loading class node.

[0091] Among them, the loading class corresponding to the loading class node can Figure 3 As shown, Run Behavior Class represents the loading class in the related art, Run Behavior Package Class represents the loading class in this embodiment, Behavior TreeClass represents the behavior tree class in the related art, and Behavior Tree Packagable Class represents the behavior tree class in this embodiment.

[0092] In this embodiment, the target behavior tree is loaded through a pre-constructed loading class node in the external behavior tree, and the input parameters are passed to the loading class node, so as to pass the input parameters to the first blackboard variable in the target behavior tree corresponding to the target character. Since the target behavior tree includes different behaviors, the external behavior tree does not need to include many target behavior trees, thereby reducing the volume of the external behavior tree, reducing the probability of errors in the external behavior tree, and reducing the maintenance cost of the external behavior tree.

[0093] S203. Pass the input parameters to the target node on the target behavior tree through the first blackboard variable.

[0094] After the terminal obtains the transfer parameters, it can view the target node corresponding to the input parameters, and then pass the input parameters to the target node corresponding to the input parameters on the target behavior tree through the first blackboard variable.

[0095] For example, when the input parameters are the target position, the probability of sliding 0.5, and the probability of jumping 0.2, the target position can be input to the target node that controls the movement of the target character, 0.5 can be input to the target node that controls the target character to slide, and 0.2 can be input to the target node that controls the target character to jump.

[0096] It should be noted that the target node corresponding to the input parameters can include at least one, that is, one behavior can be implemented through multiple nodes on the behavior tree. For example, jumping can be implemented through multiple nodes.

[0097] S204. Based on the input parameters, run the target node to control the target character to execute the target behavior corresponding to the input parameters.

[0098] After the terminal passes the input parameters to the target node, it then runs the target node based on the input parameters, thereby controlling the target character to execute the target behavior corresponding to the input parameters.

[0099] When passing the input parameters to the target node on the target behavior tree through the first blackboard variable, if the format of the input parameters is not the format recognizable by the target node, the format of the input parameters needs to be converted.

[0100] Therefore, in some embodiments, passing the input parameters to the target node on the target behavior tree through the first blackboard variable includes:

[0101] Pass the input parameters to the target conversion class in the target behavior tree through the first blackboard variable;

[0102] Convert the format of the input parameters through the target conversion class to obtain target parameters, and pass the target parameters to the target node on the target behavior tree;

[0103] Accordingly, based on the input parameters, the target node is run to control the target character to perform the target behavior corresponding to the input parameters, including:

[0104] Based on the target parameters, the target node is run to control the target character to perform the target behavior corresponding to the input parameters.

[0105] Among them, the target conversion class can pass the target parameters to the target node on the target behavior tree through the pin interface.

[0106] The formats recognizable by the target node include integer Int, floating-point Float, string type String, attribute name Name, boolean type Bool, vector type Vector, and rotation type Rotator, etc.

[0107] It should be noted that after the terminal obtains the input parameters, it can also determine the variable type of the input parameters. When the variable type of the input parameters is the preset type, the input parameters are passed to the target conversion class through the first blackboard variable. When the variable type of the input parameters is not the preset type, the input parameters are passed to the target node through the first blackboard variable.

[0108] For example, when the preset type is the editable blackboard variable type, that is, when the variable type of the input parameters is the editable blackboard variable type, the input parameters are passed to the target conversion class through the first blackboard variable.

[0109] In this embodiment, the target behavior tree also includes a target conversion class to convert the format of the input parameters into a format recognizable by the target node.

[0110] In some other embodiments, before obtaining the input parameters for the target behavior of the target character, it also includes:

[0111] Construct a target blackboard, where the target blackboard includes a first target blackboard, and the first target blackboard includes a first blackboard variable for storing and passing input parameters;

[0112] Construct a behavior tree class;

[0113] Use the behavior tree class and the target blackboard to encapsulate the code of different behaviors to obtain the target behavior tree.

[0114] In the related art, there is a corresponding initial blackboard for the behavior tree, and this initial blackboard is used to store and pass the internal data of the behavior tree. For example, the initial blackboard (Blackboard Class) corresponding to the behavior in the related art can be as Figure 4 shown, where Blackboard key represents the blackboard variable, Class represents the class name, Enum represents the enumeration type, and object represents the parent class.

[0115] In this application, the target blackboard includes a first target blackboard and a second target blackboard. The first target blackboard includes a first blackboard variable for storing and transmitting input parameters, and the second target blackboard includes internal data for storing and transmitting the behavior tree. For example, the first target blackboard and the second target blackboard in the embodiments of this application can be as Figure 4 shown. BlackboardClass(Inherited) represents the target blackboard.

[0116] Construct a behavior tree class so that the behavior tree class can load the first target blackboard and the second target blackboard, and read the input parameters from the first target blackboard and the internal data from the second target blackboard, that is, the input parameters can be passed to the target node in the behavior tree class through the first blackboard variable in the first target blackboard. The constructed behavior tree class can be as Figure 5 shown.

[0117] Among them, Behavior Tree Class represents the behavior tree class in the related art, Behavior TreePackagable Class represents the behavior tree class in this embodiment, Blackboard4Package Class represents the first target blackboard, and Blackboard Class Reference(Inherited) represents the second target blackboard.

[0118] It should be noted that the variable type of the first blackboard variable in the first target blackboard can include at least one. For example, when the variable type of the first blackboard variable includes a selection blackboard variable type and an editable blackboard variable type, the first target blackboard can be as Figure 6 shown.

[0119] Among them, Transit Type Blackboard Key represents the first blackboard variable corresponding to the selection blackboard variable type, and Editable Type Blackboard Key represents the first blackboard variable corresponding to the editable blackboard variable type.

[0120] The selection blackboard variable type refers to the type that displays all the values of the first blackboard variable, and then when the terminal receives a selection instruction, the value corresponding to the selection instruction is used as the input parameter. The editable blackboard variable type refers to the type in which the value of the first blackboard variable can be customized by the user, and then when the terminal receives the user-customized value, the user-customized value is used as the input parameter.

[0121] When the variable type of the first blackboard variable includes a selection blackboard variable type and an editable blackboard variable type, passing the input parameter to the first blackboard variable in the target behavior tree corresponding to the target role includes:

[0122] Determine the variable type of the input parameter;

[0123] If the variable type of the input parameter is the selected blackboard variable type, pass the input parameter to the first blackboard variable corresponding to the selected blackboard variable type in the target behavior tree corresponding to the target role;

[0124] If the variable type of the input parameter is the editable blackboard variable type, pass the input parameter to the first blackboard variable corresponding to the editable blackboard variable type in the target behavior tree corresponding to the target role.

[0125] When the variable type of the first blackboard variable includes the selected blackboard variable type and the editable blackboard variable type, after the terminal obtains the input parameter, first determine the variable type of the input parameter, and then pass the input parameter to the first blackboard variable corresponding to the variable type of the input parameter (refer to Figure 7 ).

[0126] After constructing the target blackboard and the behavior tree class, the terminal then uses the behavior tree class and the target blackboard to encapsulate the codes of different behaviors to obtain the target behavior tree. After encapsulation, the different behavior codes are in the behavior tree class, and the encapsulated target behavior tree can be as Figure 8 shown.

[0127] In this embodiment, a target blackboard is constructed. The target blackboard includes a first target blackboard, and the first target blackboard includes a first blackboard variable for storing and passing input parameters. A behavior tree class is constructed so that the input parameters of the first blackboard variable can be passed to the target nodes in the behavior tree class, enabling the terminal to have the ability to encapsulate the behavior tree, that is, enabling the terminal to use the target blackboard and the behavior tree class to encapsulate the codes of different behaviors to obtain the target behavior tree. Finally, the input parameters can be passed to the target nodes of the behavior tree class in the target behavior tree through the first blackboard variable, realizing that different input parameters result in different outputs of the target behavior tree, that is, realizing that different input parameters result in different behaviors executed by the target role.

[0128] Moreover, since the target behavior tree includes different behaviors, even if the user does not understand the relevant knowledge of the behavior tree, the user can still control the target role to execute the target behavior. For example, the target behavior tree can be provided for game level planners to use, thereby reducing the user's knowledge burden.

[0129] In other embodiments, after using the behavior tree class and the target blackboard to encapsulate the codes of different behaviors to obtain the target behavior tree, a control corresponding to the first blackboard variable can also be displayed on the electronic device of the target behavior tree, and then the input parameter corresponding to the target behavior of the target role can be obtained through the control.

[0130] Among them, the electronic device in this embodiment may refer to a terminal, that is, a control for the first blackboard variable is displayed on the terminal. The control can be set according to the number of the first blackboard variables. For example, if the first blackboard variables include three, namely the target position, the slide tackle probability, and the jump probability, then three controls can be displayed on the terminal.

[0131] It should be understood that when the target behavior tree is a subtree of an external behavior tree, the control corresponding to the first blackboard variable can be displayed on the property panel corresponding to the loaded class node. When the target behavior tree is not a subtree of an external behavior tree, the control corresponding to the first blackboard variable can be displayed on the property panel corresponding to the target behavior tree.

[0132] When the target behavior tree includes a target conversion class, before encapsulating the codes of different behaviors by using the behavior tree class and the target blackboard to obtain the target behavior tree, it further includes:

[0133] Constructing the target conversion class;

[0134] Correspondingly, encapsulating the codes of different behaviors by using the behavior tree class and the target blackboard to obtain the target behavior tree includes:

[0135] Encapsulating the codes of different behaviors by using the behavior tree class, the target blackboard, and the target conversion class to obtain the target behavior tree.

[0136] In this embodiment, the behavior tree class, the target blackboard, and the target conversion class are constructed, and then the codes of different behaviors are encapsulated by using the behavior tree class, the target blackboard, and the target conversion class, so as to obtain the target behavior tree.

[0137] It should be noted that the terminal can implement the above behavior control method through the Unreal Engine 4 (UE4) in the terminal.

[0138] Next, refer to Figure 9 to give an example of the encapsulation process of the target behavior tree in this embodiment.

[0139] The target behavior is: comparing the distance between the target character and the target position. If the distance between the target character and the target position is greater than 30 meters, the target character moves to the target position, and during the process of moving to the target position, it performs a slide tackle and a jump, and the time for the slide tackle and the jump is between 1.1 and 1.5 seconds, and when the time is up, it stops the slide tackle and the jump. Among them, the probability of the slide tackle is 0.5, and if the slide tackle is successful, it will not perform a slide tackle again within the next 1.8 seconds. If someone attacks the target character, the probability of the jump is 0.2. If the target character does not perform a slide tackle and a jump, it only moves within the time range of 0.5 to 1.5 seconds and does not perform other actions.

[0140] First, the terminal constructs a behavior tree class in response to the user's trigger operation on the Behavior Tree Packagable control. Then, the terminal constructs a target blackboard corresponding to the behavior tree class in response to the user's trigger operation on the blackboard control. The target blackboard includes the first target blackboard BB_Apex_CommonBB and the second target blackboard BB_Apex_BRBB.

[0141] Next, in response to the user's first creation instruction, the terminal creates three first blackboard variables in the first target blackboard. The three first blackboard variables are the target position Transit_Target, the slide probability E_SlideProb, and the jump probability E_JumpProb. Moreover, all the values of the target position are configured on the property panel of the move node (FuncMoveTo) in the behavior tree class.

[0142] Secondly, in response to the user's second creation instruction, the terminal enables the pin interface mode (Enable Pin Mode) of the decorator node (BTDecorator_RollADice) of the behavior tree class, creates a target conversion class (Literal Blackboard Key) based on the second creation instruction, and selects the first blackboard variables (Blackboard Key) slide probability and the first blackboard variable jump probability that need to be converted based on the selection instruction. Finally, the pin interface of the node corresponding to the target conversion class is connected to the pin interface of the decorator node.

[0143] Furthermore, the terminal encapsulates the code of the target behavior using the behavior tree class, the target blackboard, and the target conversion class to obtain a target behavior tree. The target behavior tree can be as Figure 10 shown.

[0144] Finally, the terminal receives a third construction instruction, constructs a loading class node (Run Behavior Package) on the external behavior tree based on the third construction instruction, loads the target behavior tree through the loading class node, and displays the controls corresponding to the target position, the slide probability, and the jump probability on the property panel of the loading class node.

[0145] As can be seen from the above, in the embodiment of the present application, the input parameters of the target behavior for the target role are first obtained. Then, the input parameters are passed to the first blackboard variables in the target behavior tree corresponding to the target role. The target behavior tree includes different behaviors of the target role. Next, the input parameters are passed to the target nodes on the target behavior tree through the first blackboard variables. Finally, based on the input parameters, the target nodes are run to control the target role to execute the target behavior corresponding to the input parameters.

[0146] That is, in the embodiments of the present application, since the input parameters of the target behavior of the target role can be passed to the target node on the target behavior tree through the first blackboard variable in the target behavior tree, and finally, based on the input parameters, the target node is run to control the target role to execute the target behavior corresponding to the input parameters. Therefore, different behaviors of the target role can be included in the target behavior tree, and different input parameters can be used to make the target role execute different behaviors in the target behavior tree, thereby improving the reuse rate of the target behavior tree and further improving the development efficiency.

[0147] The method described in the above embodiments will be further described in detail with examples below.

[0148] In this embodiment, taking the behavior control device integrated in the terminal as an example, please refer to Figure 11 , Figure 11 which is a schematic flowchart of the behavior control method provided by the embodiments of the present application. The process of this behavior control method may include:

[0149] S1101. The terminal constructs a target blackboard, and the target blackboard includes a first target blackboard, and the first target blackboard includes a first blackboard variable for storing and transmitting input parameters.

[0150] In addition to the first target blackboard, the target blackboard may further include a second target blackboard. The first target blackboard includes a first blackboard variable for storing and transmitting input parameters, and the second target blackboard includes internal data for storing and transmitting the behavior tree.

[0151] S1102. The terminal constructs a behavior tree class and a target conversion class.

[0152] By constructing the behavior tree class, the behavior tree class can load the first target blackboard and the second target blackboard, and read the input parameters from the first target blackboard and the internal data from the second target blackboard, that is, the input parameters can be passed to the target node in the behavior tree class through the first blackboard variable in the first target blackboard.

[0153] The target conversion class is used to convert the format of the input parameters into a format recognizable by the target node. The formats recognizable by the target node include integer Int, floating point Float, string type String, property name Name, boolean type Bool, vector type Vector, and rotation type Rotator, etc.

[0154] It should be noted that when constructing the target conversion class, the variable type corresponding to the input parameter that needs to be converted can also be set. For example, when the variable type of the input parameter is an editable blackboard variable type, the input parameter needs to be converted by the target conversion class.

[0155] S1103. The terminal encapsulates the code for different behaviors of the target character using the target blackboard, behavior tree class, and target conversion class to obtain the target behavior tree.

[0156] The different behaviors can include various behaviors of the target character, such as the movement position of the target character, picking up things, climbing over walls, and turning around, etc.

[0157] S1104. The terminal constructs a loading class node on the external behavior tree, and loads the target behavior tree through the loading class node to display the control corresponding to the first blackboard variable on the property panel of the loading class node.

[0158] The terminal first constructs a loading class node so that the loading class node can load the target behavior tree. For example, Figure 12 as shown, when loading the target behavior tree through the loading class node, the first target blackboard Blackboard4Package Class will pass the first blackboard variable to the loading class node so that the loading class node can display the control corresponding to the first blackboard variable on the property panel.

[0159] S1105. The terminal obtains the input parameters for the target behavior of the target character through the control.

[0160] S1106. The terminal passes the input parameters to the loading class node and determines the variable type of the input parameters.

[0161] For example, Figure 12 as shown, the input parameters are passed to the loading class node.

[0162] S1107. If the variable type of the input parameter is an editable blackboard variable type, the input parameter is passed to the first blackboard variable corresponding to the editable blackboard variable type in the target behavior tree through the loading class node.

[0163] S1108. The passed parameters are passed to the target conversion class through the first blackboard variable corresponding to the editable blackboard variable type.

[0164] S1109. The format of the passed parameters is converted through the target conversion class to obtain the target parameters, and the target parameters are passed to the target node on the target behavior tree.

[0165] S1110. If the variable type of the input parameter is a selectable blackboard variable type, the input parameter is passed to the first blackboard variable corresponding to the selectable blackboard variable type in the target behavior tree through the loading class node.

[0166] S1111. The passed parameters are passed to the target node on the target behavior tree through the first blackboard variable corresponding to the selectable blackboard variable type.

[0167] For example, Figure 12As shown, input parameters and / or target parameters are passed to the target node.

[0168] S1112. Based on the target parameters and / or input parameters, run the target node to control the target character to execute the target behavior corresponding to the input parameters.

[0169] In this embodiment, a target blackboard is constructed. The target blackboard includes a first target blackboard, and the first target blackboard includes a first blackboard variable for storing and passing input parameters. A behavior tree class is constructed so that the input parameters of the first blackboard variable can be passed to the target node in the behavior tree class, enabling the terminal to have the encapsulation ability for the behavior tree. That is, the terminal can use the target blackboard and the behavior tree class to encapsulate the code of different behaviors to obtain the target behavior tree. Finally, the input parameters can be passed to the target node of the behavior tree class in the target behavior tree through the first blackboard variable, realizing that for different input parameters, the output of the target behavior tree is different, that is, for different input parameters, the behaviors executed by the target character are different, thereby improving the reuse rate of the target behavior tree and further improving the development efficiency.

[0170] Moreover, the target behavior tree is loaded through a pre-constructed loading class node in the external behavior tree, and the input parameters are passed to the loading class node, thereby passing the input parameters to the first blackboard variable in the target behavior tree corresponding to the target character. Since the target behavior tree includes different behaviors, the external behavior tree does not need to include many target behavior trees, so the volume of the external behavior tree can be reduced, the probability of errors in the external behavior tree can be reduced, and the maintenance cost of the external behavior tree can be lowered.

[0171] To facilitate better implementation of the behavior control method provided in the embodiments of the present application, the embodiments of the present application also provide a device based on the above behavior control method. The meanings of the nouns are the same as those in the above behavior control method, and the specific implementation details can be referred to the description in the method embodiments.

[0172] For example, as Figure 13 shown, the behavior control device may include:

[0173] An acquisition module 1301, configured to acquire input parameters for the target behavior of the target character.

[0174] A first transfer module 1302, configured to transfer the input parameters to the first blackboard variable in the target behavior tree corresponding to the target character, and the target behavior tree includes different behaviors of the target character.

[0175] A second transfer module 1303, configured to transfer the input parameters to the target node on the target behavior tree through the first blackboard variable.

[0176] The running module 1304 is used to run the target node based on the input parameters to control the target character to execute the target behavior corresponding to the input parameters.

[0177] Optionally, the second transfer module 1303 is specifically used to execute:

[0178] Transfer the input parameters to the target conversion class in the target behavior tree through the first blackboard variable;

[0179] Convert the format of the input parameters through the target conversion class to obtain the target parameters, and transfer the target parameters to the target node on the target behavior tree.

[0180] Correspondingly, the running module 1304 is specifically used to execute:

[0181] Run the target node based on the target parameters to control the target character to execute the target behavior corresponding to the input parameters.

[0182] Optionally, the target behavior tree is a subtree of an external behavior tree.

[0183] Correspondingly, the first transfer module 1302 is specifically used to execute:

[0184] Load the target behavior tree through the pre-constructed loading class node in the external behavior tree;

[0185] Transfer the input parameters to the loading class node;

[0186] Transfer the input parameters to the first blackboard variable in the target behavior tree corresponding to the target character through the loading class node.

[0187] Optionally, the behavior control device further includes:

[0188] The construction encapsulation module is used for:

[0189] Construct a target blackboard, the target blackboard includes a first target blackboard, and the first target blackboard includes a first blackboard variable for storing and transferring input parameters;

[0190] Construct a behavior tree class;

[0191] Encapsulate the codes of different behaviors using the behavior tree class and the target blackboard to obtain the target behavior tree.

[0192] Optionally, the behavior control device further includes:

[0193] The display module is used to display the control corresponding to the first blackboard variable on the electronic device including the target behavior tree.

[0194] Correspondingly, the acquisition module 1301 is specifically used to execute:

[0195] Obtain input parameters corresponding to the target behavior for the target role through the control.

[0196] Optionally, the encapsulation module is specifically configured to execute:

[0197] Construct a target conversion class;

[0198] Use the behavior tree class, the target blackboard, and the target conversion class to encapsulate the code of different behaviors to obtain a target behavior tree.

[0199] Optionally, the variable types of the first blackboard variables include a selectable blackboard variable type and an editable blackboard variable type.

[0200] Correspondingly, the first transfer module 1302 is specifically configured to execute:

[0201] Determine the variable type of the input parameter;

[0202] If the variable type of the input parameter is a selectable blackboard variable type, then pass the input parameter to the first blackboard variable corresponding to the selectable blackboard variable type in the target behavior tree corresponding to the target role;

[0203] If the variable type of the input parameter is an editable blackboard variable type, then pass the input parameter to the first blackboard variable corresponding to the editable blackboard variable type in the target behavior tree corresponding to the target role.

[0204] In specific implementation, each of the above modules can be implemented as an independent entity, or can be combined arbitrarily and implemented as the same or several entities. For the specific implementation manners of each of the above modules and the corresponding beneficial effects, reference can be made to the foregoing method embodiments, which will not be elaborated herein.

[0205] The embodiment of the present application further provides an electronic device, which may be a server or a terminal, etc. As Figure 14 shown, it shows a schematic structural diagram of the electronic device involved in the embodiment of the present application. Specifically:

[0206] The electronic device may include a processor 1401 with one or more processing cores, a memory 1402 with one or more computer-readable storage media, a power supply 1403, an input unit 1404 and other components. Those skilled in the art can understand that Figure 14 the structural diagram of the electronic device shown in

[0207] The processor 1401 is the control center of the electronic device, connecting various parts of the entire electronic device through various interfaces and circuits. By running or executing computer programs and / or modules stored in the memory 1402, and by invoking the data stored in the memory 1402, it executes various functions of the electronic device and processes data. Optionally, the processor 1401 may include one or more processing cores; preferably, the processor 1401 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communications. It can be understood that the above-mentioned modem processor may not be integrated into the processor 1401 either.

[0208] The memory 1402 can be used to store computer programs and modules. The processor 1401 executes various functional applications and data processing by running the computer programs and modules stored in the memory 1402. The memory 1402 may mainly include a program storage area and a data storage area. Among them, the program storage area can store the operating system, computer programs required for at least one function (such as the sound playback function, image playback function, etc.), etc.; the data storage area can store data created according to the use of the electronic device. In addition, the memory 1402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage devices. Correspondingly, the memory 1402 may also include a memory controller to provide the processor 1401 with access to the memory 1402.

[0209] The electronic device further includes a power supply 1403 for supplying power to each component. Preferably, the power supply 1403 can be logically connected to the processor 1401 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 1403 may also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.

[0210] The electronic device may further include an input unit 1404, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.

[0211] Although not shown, the electronic device may further include a display unit, etc., which will not be elaborated here. Specifically, in this embodiment, the processor 1401 in the electronic device will load the executable files corresponding to the processes of one or more computer programs into the memory 1402 according to the following instructions, and the processor 1401 will run the computer programs stored in the memory 1402 to realize various functions, such as:

[0212] Obtain input parameters for the target behavior of the target character;

[0213] Pass the input parameters to the first blackboard variable in the target behavior tree corresponding to the target character, where the target behavior tree includes different behaviors of the target character;

[0214] Pass the input parameters to the target node on the target behavior tree through the first blackboard variable;

[0215] Based on the input parameters, run the target node to control the target character to execute the target behavior corresponding to the input parameters.

[0216] For the specific implementation manners of the above operations and the corresponding beneficial effects, reference may be made to the detailed description of the image processing method above, which will not be elaborated here.

[0217] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by a computer program or by controlling relevant hardware through a computer program. This computer program can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0218] Therefore, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. This computer program can be loaded by a processor to execute the steps in any one of the image processing methods provided by the embodiments of the present application. For example, the computer program can execute the following steps:

[0219] Obtain input parameters for the target behavior of the target character;

[0220] Pass the input parameters to the first blackboard variable in the target behavior tree corresponding to the target character, where the target behavior tree includes different behaviors of the target character;

[0221] Pass the input parameters to the target node on the target behavior tree through the first blackboard variable;

[0222] Based on the input parameters, run the target node to control the target character to execute the target behavior corresponding to the input parameters.

[0223] For the specific implementation manners of the above operations and the corresponding beneficial effects, reference may be made to the previous embodiments, which will not be elaborated here.

[0224] Among them, the computer-readable storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc.

[0225] Since the computer program stored in the computer-readable storage medium can execute the steps in any of the behavior control methods provided in the embodiments of the present application, the beneficial effects achievable by any of the behavior control methods provided in the embodiments of the present application can be realized. For details, refer to the previous embodiments and will not be elaborated here.

[0226] Wherein, according to one aspect of the present application, there is provided a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned behavior control method.

[0227] The above has introduced in detail a behavior control method, apparatus, electronic device, and computer-readable storage medium provided in the embodiments of the present application. Specific examples are used herein to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.

Claims

1. A behavior control method, characterized in that, it includes: obtaining input parameters for a target behavior of a target role; transmitting the input parameters to a first blackboard variable in a target behavior tree corresponding to the target role, the target behavior tree including different behaviors of the target role, and the variable type of the first blackboard variable including a selection blackboard variable type and an editable blackboard variable type; The transmitting the input parameters to a first blackboard variable in a target behavior tree corresponding to the target role includes: determining the variable type of the input parameters; if the variable type of the input parameters is the selection blackboard variable type, then transmitting the input parameters to the first blackboard variable corresponding to the selection blackboard variable type in the target behavior tree corresponding to the target role; if the variable type of the input parameters is the editable blackboard variable type, then transmitting the input parameters to the first blackboard variable corresponding to the editable blackboard variable type in the target behavior tree corresponding to the target role; transmitting the input parameters to a target node on the target behavior tree through the first blackboard variable; The transmitting the input parameters to a target node on the target behavior tree through the first blackboard variable includes: when the variable type of the input parameters is the selection blackboard variable type, transmitting the input parameters to the target node on the target behavior tree through the first blackboard variable corresponding to the selection blackboard variable type; when the variable type of the input parameters is the editable blackboard variable type, transmitting the input parameters to a target conversion class on the target behavior tree through the first blackboard variable corresponding to the editable blackboard variable type; and converting the format of the input parameters through the target conversion class to obtain target parameters, and transmitting the target parameters to the target node on the target behavior tree; running the target node based on the input parameters to control the target role to execute the target behavior corresponding to the input parameters; The running the target node based on the input parameters includes: running the target node based on the target parameters.

2. The method according to claim 1, characterized in that, the target behavior tree is a subtree of an external behavior tree; The transmitting the input parameters to a first blackboard variable in a target behavior tree corresponding to the target role includes: loading the target behavior tree through a pre-constructed loading class node in the external behavior tree; transmitting the input parameters to the loading class node; transmitting the input parameters to a first blackboard variable in a target behavior tree corresponding to the target role through the loading class node.

3. The method according to any one of claims 1-2, characterized in that, before the obtaining the input parameters for a target behavior of a target role, it further includes: constructing a target blackboard, the target blackboard including a first target blackboard, and the first target blackboard including a first blackboard variable for storing and transmitting input parameters; constructing a behavior tree class; using the behavior tree class and the target blackboard to encapsulate the codes of different behaviors to obtain a target behavior tree.

4. The method according to claim 3, It is characterized in that after encapsulating the codes of different behaviors by using the behavior tree class and the target blackboard to obtain a target behavior tree, it further includes: displaying a control corresponding to the first blackboard variable on an electronic device including the target behavior tree; Correspondingly, the obtaining of the input parameter corresponding to the target behavior of the target role includes: obtaining the input parameter corresponding to the target behavior of the target role through the control.

5. The method according to claim 3, It is characterized in that before encapsulating the codes of different behaviors by using the behavior tree class and the target blackboard to obtain a target behavior tree, it further includes: constructing a target conversion class; Correspondingly, the encapsulating of the codes of different behaviors by using the behavior tree class and the target blackboard to obtain a target behavior tree includes: encapsulating the codes of different behaviors by using the behavior tree class, the target blackboard and the target conversion class to obtain a target behavior tree.

6. A behavior control device, It is characterized in that it includes: an obtaining module, configured to obtain an input parameter of a target behavior of a target role; a first transmission module, configured to transmit the input parameter to a first blackboard variable in a target behavior tree corresponding to the target role, the target behavior tree includes different behaviors of the target role, and the variable type of the first blackboard variable includes a selection blackboard variable type and an editable blackboard variable type; The transmitting the input parameter to the first blackboard variable in the target behavior tree corresponding to the target role includes: determining the variable type of the input parameter; if the variable type of the input parameter is the selection blackboard variable type, then transmitting the input parameter to the first blackboard variable corresponding to the selection blackboard variable type in the target behavior tree corresponding to the target role; if the variable type of the input parameter is the editable blackboard variable type, then transmitting the input parameter to the first blackboard variable corresponding to the editable blackboard variable type in the target behavior tree corresponding to the target role; a second transmission module, configured to transmit the input parameter to a target node on the target behavior tree through the first blackboard variable; The transmitting the input parameter to the target node on the target behavior tree through the first blackboard variable includes: when the variable type of the input parameter is the selection blackboard variable type, transmitting the input parameter to the target node on the target behavior tree through the first blackboard variable corresponding to the selection blackboard variable type; when the variable type of the input parameter is the editable blackboard variable type, transmitting the input parameter to the target conversion class on the target behavior tree through the first blackboard variable corresponding to the editable blackboard variable type; and converting the format of the input parameter through the target conversion class to obtain a target parameter, and transmitting the target parameter to the target node on the target behavior tree; a running module, configured to run the target node based on the input parameter to control the target role to execute the target behavior corresponding to the input parameter; The running the target node based on the input parameter includes: Run the target node based on the target parameter.

7. An electronic device, characterized in that, it includes a processor and a memory, the memory stores a computer program, and the processor is configured to run the computer program in the memory to execute the behavior control method according to any one of claims 1 to 6.

8. A computer-readable storage medium, characterized in that, the computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor to execute the behavior control method according to any one of claims 1 to 6.

9. A computer program product, characterized in that, the computer program product stores a computer program, and the computer program is suitable for being loaded by a processor to execute the behavior control method according to any one of claims 1 to 6.