A Differentiated Event Configuration Method and System Based on Behavior Trees
By using a behavior tree-based differentiated event configuration method, the problem of frequent code modifications required for differentiated events in game development is solved, achieving seamless configuration and improving modification efficiency.
Patent Information
- Application Number
- CN202310748317.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-25
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2043-06-25
AI Technical Summary
In current game development, differentiated events cannot be fully distinguished through configuration, leading to frequent code modifications and low efficiency.
A behavior tree-based differentiated event configuration method is adopted. By creating behavior tree files and nodes, using reflection technology to read and set parameters, and establishing configuration file references, differentiated event configuration can be achieved without the business layer's awareness.
It enables differentiated event configurations that do not require modification of script code under different circumstances, reducing the coupling of the business logic layer and improving the efficiency of configuration modification.
Smart Images

Figure CN119201197B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computers, and in particular to a differentiated event configuration method and system based on behavior trees. Background Technology
[0002] In game development, it is often necessary to configure different data according to different situations (such as the current environment being divided into domestic and foreign environments). This way, the business layer does not need to pay attention to the differences between domestic and foreign environments when executing, and can be unaware of the differences. If only the numerical data is different, the business can be unaware of the differences by following the conventional numerical configuration.
[0003] However, some events are different. For example, domestic game login usually requires a privacy agreement, while foreign environments usually do not. The configured data is usually numerical parameters. If some behavioral events are different in different situations (i.e., there are differentiated events), it is not possible to completely distinguish different situations through configuration. In this case, if we only do data differentiation configuration according to the conventional approach, the business layer still needs to make different judgments and do different logic according to different environments. Moreover, if the data differentiation configuration changes, the code often needs to be modified. Summary of the Invention
[0004] To overcome the shortcomings of existing game development methods where differentiated events cannot be fully distinguished through configuration and often require code modification, resulting in low efficiency, the present invention aims to provide a behavior tree-based differentiated event configuration method and system. This method enables the configuration of different differentiated events using behavior trees, thereby achieving configuration based on different scenarios and avoiding the need to modify script code when configuring certain events differently.
[0005] This invention is implemented using the following scheme:
[0006] The behavior tree-based differentiated event configuration method is characterized by the following steps:
[0007] Step 1: Create a behavior tree file;
[0008] Step 2: Create global static functions and global static parameter task event nodes in the behavior tree;
[0009] Step 3: Create a behavior tree singleton class function and parameter task event nodes in the behavior tree;
[0010] Step 4: Create objects loaded into memory in the behavior tree, attaching script functions and parameters to task event nodes;
[0011] Step 5: Create a data management task event node for the resident memory global management controller in the behavior tree;
[0012] Step 6: Create different configuration files based on the region and establish references. The business layer reads the configuration files, reads the parameters, and executes differentiated events.
[0013] Furthermore, step 2 is further specified as follows: the content configured in the global static parameter task event node is the class name, the function to be called in the class, or the parameter to be read or set. The global static parameter task event node reads the corresponding function or parameter of the assembly through reflection, executes the function, and reads or sets the parameter. The global static parameter task event node is used to call all static functions or parameters.
[0014] Furthermore, step 3 is further specified as follows: the content configured in the parameter task event node is the class name, the function to be called in the class, and the parameters to be read or set. The parameter task event node uses reflection to read all dictionaries of singleton instances that inherit from the singleton base class in the assembly, based on the class name and singleton instance, and caches them. Based on the configured class name, the corresponding singleton is read, and the corresponding function is executed to read or set the parameters.
[0015] Furthermore, step 4 is further specified as follows: the content configured in the parameter task event node is the class name and the function to be called in the class corresponding to the class name, as well as the parameter conditions and the parameters to be read or set. The object search function of the engine is used to find all objects under the same class name script, and the corresponding single or multiple objects are filtered out according to the configured object parameter conditions, and the configured function is executed to read or set the parameters.
[0016] Furthermore, step 5 specifically involves: creating a data management task event node for a resident memory global management controller. The data management task event node is configured with parameters to be read or set. The resident memory global management controller manages the game memory throughout the game and caches the data used throughout the game. A reference to the global management controller is established in the data management task event node, and global data is read or set according to the configuration.
[0017] A behavior tree-based differentiated event configuration system includes a behavior tree file creation module, creation module A, creation module B, creation module C, creation module D, and allocation module.
[0018] The behavior tree file creation module is used to create behavior tree files;
[0019] The creation module A is used to create global static functions and global static parameter task event nodes in the behavior tree;
[0020] The creation module B is used to create behavior tree singleton class functions and parameter task event nodes in the behavior tree;
[0021] The creation module C is used to create objects loaded into memory, along with script functions, parameters, task event nodes, etc., in the behavior tree.
[0022] The creation module D is used to create data management task event nodes for the resident memory global management controller in the behavior tree;
[0023] The allocation module is used to create different configuration files based on the region and establish references. The business layer reads the configuration files, reads the parameters, and executes differentiated events.
[0024] Furthermore, the creation module A is further specified as follows: the content configured in the global static parameter task event node is the class name, the function to be called in the class, or the parameter to be read or set. The global static parameter task event node reads the corresponding function or parameter of the assembly through reflection, executes the function, and reads or sets the parameter. The global static parameter task event node is used to call all static functions or parameters.
[0025] Furthermore, the creation module B is further specified as follows: the content configured in the parameter task event node is the class name, the function to be called in the class, and the parameters to be read or set. The parameter task event node uses reflection to read all dictionaries of singleton instances that inherit from the singleton base class in the assembly, based on the class name and the singleton instance, and caches them. Based on the configured class name, the corresponding singleton is read, and the corresponding function is executed to read or set the parameters.
[0026] Furthermore, the creation module C is further specified as follows: the parameter task event node is configured with the class name and the function to be called in the class corresponding to the class name, as well as the parameter conditions and the parameters to be read or set. The engine's built-in scene-finding object function is used to find all objects under the same class name script, and the corresponding single or multiple objects are filtered out according to the configured object parameter conditions, and the configured function is executed to read or set the parameters.
[0027] Furthermore, the creation module D specifically involves: creating a data management task event node for a resident memory global management controller. The data management task event node is configured with parameters to be read or set. The resident memory global management controller manages the game memory throughout the game and caches the data used throughout the game. A reference to the global management controller is established in the data management task event node, and global data is read or set according to the configuration.
[0028] The beneficial effects of this invention are as follows:
[0029] This invention relates to a differentiated event configuration method and system based on behavior trees. By using behavior trees to configure different differentiated events, it can fully realize configuration based on different situations. This avoids the need to modify script code when there are differences in the configuration of certain events. It completely realizes that the business layer is unaware of different situations. Moreover, when new situations occur, they can also be fully implemented through configuration. When adding, deleting, or modifying configurations, it reduces the coupling to the business logic layer and improves the efficiency of configuration modification. Attached Figure Description
[0030] Figure 1 This is a flowchart of the method of the present invention;
[0031] Figure 2 This is a structural block diagram of the system of the present invention. Detailed Implementation
[0032] The invention will now be further described with reference to the accompanying drawings.
[0033] Please see Figure 1 The differentiated event configuration method based on behavior trees has the following steps:
[0034] Step 1: Create a behavior tree file;
[0035] Step 2: Create global static functions and global static parameter task event nodes in the behavior tree;
[0036] Step 3: Create a behavior tree singleton class function and parameter task event nodes in the behavior tree;
[0037] Step 4: Create objects loaded into memory in the behavior tree, attaching script functions and parameters to task event nodes;
[0038] Step 5: Create a data management task event node for the resident memory global management controller in the behavior tree;
[0039] Step 6: Create different configuration files based on the region and establish references. The business layer reads the configuration files, reads the parameters, and executes differentiated events.
[0040] Creating a reference here means dragging the edited behavior tree file into the corresponding configuration system that needs to use the event, and triggering the edited behavior tree when the event is triggered.
[0041] The present invention will be further described below with reference to a specific embodiment:
[0042] Step 1: Create a differentiated event behavior tree for configurations that require differentiated events, similar to the behavior tree in the Unity3D engine, with different events corresponding to different edited behavior trees;
[0043] Step 2: Create global static function and global static parameter task event nodes used in the behavior tree, similar to the Action behavior node in the Unity3D engine. The behavior node needs to be configured with the class name and the function to be called or the parameter to be read or set in the class. The behavior node uses reflection to read the corresponding function or parameter of the assembly, and executes the function, reads or sets the parameter. This behavior node is used to call all static functions or parameters in the game.
[0044] Step 3: Create a behavior tree singleton class function and parameter event node. Similar to the Action behavior node in the Unity3D engine, this behavior node needs to be configured with the class name, the function to be called in the class, and the parameters to be read or set. In this behavior node, use reflection to read all dictionaries of singleton instances that inherit from the singleton base class in the assembly, based on the class name and the singleton instance, match them and cache them. Read the corresponding singleton based on the configured class name, and execute the corresponding function to read or set the parameters.
[0045] Reflection is an existing computational technique that can read functions and parameters from libraries or assemblies and call those functions and parameters. Here, reflection reading refers to using existing reflection technology to call functions within the game or read relevant parameters.
[0046] Step 4: Create a function and parameter task event node for the object loaded into memory and attached to the script. Similar to the Action node in the Unity3D engine, this behavior node needs to be configured with the class name, the function to be called in the class, the parameter conditions, and the parameters to be read or set. Use the engine's built-in function to find all objects attached to the script of the class name, and filter out the corresponding single or multiple objects according to the configured object parameter conditions, and execute the configured function to read or set the parameters.
[0047] Step 5: Create a data management task event node for the resident global management controller. Similar to the Action behavior node in the Unity3D engine, this behavior node needs to be configured to read or set parameters. It is similar to the global management controller commonly used in game development. This controller usually resides in the game memory throughout the game and caches the data used throughout the game. In the event node, establish a reference to this global manager and read or set the global data according to the configuration.
[0048] Step 6: Create different configuration files for different situations (similar to Unity's ScriptableObject, for example, create a local ScriptableObject file for domestic environments and a ScriptableObject file for international environments). If the current environment is domestic, create a reference to the domestic ScriptableObject file. The ScriptableObject file contains different numerical parameters and behavior tree configuration for differentiated events. The different data and behaviors in domestic and international environments read the configured data and execute the configured differentiated behaviors respectively.
[0049] Please see Figure 2 A behavior tree-based differentiated event configuration system, including a behavior tree file creation module, creation module A, creation module B, creation module C, creation module D, and allocation module;
[0050] The behavior tree file creation module is used to create behavior tree files;
[0051] The creation module A is used to create global static functions and global static parameter task event nodes in the behavior tree;
[0052] The creation module B is used to create behavior tree singleton class functions and parameter task event nodes in the behavior tree;
[0053] The creation module C is used to create objects loaded into memory, along with script functions, parameters, task event nodes, etc., in the behavior tree.
[0054] The creation module D is used to create data management task event nodes for the resident memory global management controller in the behavior tree;
[0055] The allocation module is used to create different configuration files based on the region and establish references. The business layer reads the configuration files, reads the parameters, and executes differentiated events.
[0056] The creation module A is further specified as follows: the content configured in the global static parameter task event node is the class name, the function to be called in the class, or the parameter to be read or set. The global static parameter task event node reads the corresponding function or parameter of the assembly through reflection, executes the function, and reads or sets the parameter. The global static parameter task event node is used to call all static functions or parameters.
[0057] The creation module B is further specified as follows: the content configured in the parameter task event node is the class name, the function to be called in the class, and the parameters to be read or set. The parameter task event node uses reflection to read all dictionaries of singleton instances that inherit from the singleton base class in the assembly, based on the class name and singleton instance, and caches them. Based on the configured class name, it reads the corresponding singleton and executes the corresponding function to read or set the parameters.
[0058] The creation module C is further specified as follows: the parameter task event node is configured with the class name and the function to be called in the class corresponding to the class name, as well as the parameter conditions and the parameters to be read or set. The engine's built-in scene object search function is used to find all objects under the same class name script, and the corresponding single or multiple objects are filtered out according to the configured object parameter conditions, and the configured function is executed to read or set the parameters.
[0059] The creation module D is further specified as follows: creating a data management task event node for a resident memory global management controller. The data management task event node is configured with parameters to be read or set. The resident memory global management controller manages the game memory throughout the game and caches the data used throughout the game. A reference to the global management controller is established in the data management task event node, and global data is read or set according to the configuration.
[0060] In summary, this invention presents a behavior tree-based differentiated event configuration method and system. By using behavior trees to configure different differentiated events, it fully realizes configuration based on different situations, avoiding the need to modify script code when adding, deleting, or modifying certain events. It completely achieves the business layer's unawareness of different situations, and when new situations occur, they can also be fully implemented through configuration. When adding, deleting, or modifying configurations, it reduces the coupling to the business logic layer and improves the efficiency of configuration modification.
[0061] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made within the scope of the claims of the present invention should be included in the scope of the present invention.
Claims
1. A differentiated event configuration method based on behavior trees, characterized in that, The method steps are as follows: Step 1: Create a behavior tree file; Step 2: Create global static functions and global static parameter task event nodes in the behavior tree; Step 3: Create a behavior tree singleton class function and parameter task event nodes in the behavior tree; Step 4: Create objects loaded into memory in the behavior tree, attaching script functions and parameters to task event nodes; Step 5: Create a data management task event node for the resident memory global management controller in the behavior tree; Step 6: Create different configuration files based on the region and establish references. The business layer reads the configuration files, reads the parameters, and executes differentiated events. Step 2 is further specified as follows: The content configured in the global static parameter task event node is the class name, the function to be called in the class, or the parameter to be read or set. The global static parameter task event node reads the corresponding function or parameter of the assembly through reflection, executes the function, and reads or sets the parameter. The global static parameter task event node is used to call all static functions or parameters. Step 3 is further specified as follows: The content configured in the parameter task event node is the class name, the function to be called in the class, and the parameters to be read or set. The parameter task event node uses reflection to read all dictionaries of singleton instances that inherit from the singleton base class in the assembly, based on the class name and singleton instance, and caches them. Based on the configured class name, the corresponding singleton is read, and the corresponding function is executed to read or set the parameters. Step 4 is further specified as follows: The content of the parameter task event node configuration is the class name and the function to be called in the class corresponding to the class name, as well as the parameter conditions and the parameters to be read or set. The object search function of the engine is used to find all objects under the same class name script, and the corresponding single or multiple objects are filtered out according to the configured object parameter conditions, and the configured function is executed to read or set the parameters. Step 5 further specifies: creating a data management task event node for a resident memory global management controller. The data management task event node is configured with parameters to be read or set. The resident memory global management controller manages the game memory throughout the game and caches the data used throughout the game. A reference to the global management controller is established in the data management task event node, and global data is read or set according to the configuration.
2. A differentiated event configuration system based on behavior trees, characterized in that, This includes the behavior tree file creation module, creation module A, creation module B, creation module C, creation module D, and allocation module; The behavior tree file creation module is used to create behavior tree files; The creation module A is used to create global static functions and global static parameter task event nodes in the behavior tree; The creation module B is used to create behavior tree singleton class functions and parameter task event nodes in the behavior tree; The creation module C is used to create objects loaded into memory, along with script functions, parameters, task event nodes, etc., in the behavior tree. The creation module D is used to create data management task event nodes for the resident memory global management controller in the behavior tree; The allocation module is used to create different configuration files based on the region and establish references. The business layer reads the configuration files, reads the parameters, and executes differentiated events. The creation module A is further specified as follows: the content configured in the global static parameter task event node is the class name, the function to be called in the class, or the parameter to be read or set. The global static parameter task event node reads the corresponding function or parameter of the assembly through reflection, executes the function, and reads or sets the parameter. The global static parameter task event node is used to call all static functions or parameters. The creation module B is further specified as follows: the content configured in the parameter task event node is the class name, the function to be called in the class, and the parameters to be read or set. The parameter task event node uses reflection to read all dictionaries of singleton instances based on class name and singleton instance in all classes that inherit from the singleton base class in the assembly, and caches them. It reads the corresponding singleton based on the configured class name, executes the corresponding function, and reads or sets the parameters. The creation module C is further specified as follows: the content configured in the parameter task event node is the class name and the function to be called in the class corresponding to the class name, as well as the parameter conditions and the parameters to be read or set. The engine's built-in scene object search function finds all objects under the same class name script, and filters out the corresponding single or multiple objects according to the configured object parameter conditions, and executes the configured function to read or set parameters. The creation module D is further specified as follows: creating a data management task event node for a resident memory global management controller. The data management task event node is configured with parameters to be read or set. The resident memory global management controller manages the game memory throughout the game and caches the data used throughout the game. A reference to the global management controller is established in the data management task event node, and global data is read or set according to the configuration.
Citation Information
Patent Citations
Multi-thread transaction processing method based on MongoDB
CN107436881A
Automatic simulation test optimization method based on state behavior tree
CN109669363A