Differentiated event configuration method and system based on behavior tree
By configuring differentiated events in behavior tree, the problem of low efficiency of differentiated events in game development is solved, and unconscious environment adaptation is achieved, code modification is reduced, and configuration modification efficiency is improved.
Patent Information
- Application Number
- CN202310748317.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-25
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2043-06-25
AI Technical Summary
In game development, differentiated events cannot be completely differentiated by configuration, resulting in frequent code modification and inefficient efficiency.
Using a differentiated event configuration method based on behavior tree, we use the reflection mechanism to read and set parameters to achieve differentiated configurations in different environments and avoid modifying script code.
The service layer is unaware of different environments, reduces the coupling to the business logic layer, and improves the configuration modification efficiency.
Smart Images

Figure CN119201197A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a behavior tree-based differentiated event configuration method and system. Background Art
[0002] In game development, it is often necessary to configure different data according to different situations (for example, the current environment is divided into domestic and foreign environments). In this way, the business layer does not need to pay attention to the differences between domestic and foreign environments during execution and can be unaware of different situations. If only the numerical data is different, the conventional numerical configuration can be used to achieve the business being unaware of the difference.
[0003] However, some events usually differ. For example, domestic game logins usually require a privacy agreement, while foreign environments usually do not. The data configured are usually numerical parameters. If some behavioral events are different in different situations (that is, there are differentiated events), the different situations cannot be completely distinguished by configuration. At this time, if only data differentiation configuration is performed according to conventional practices, the business layer still needs to make different logics based on different environmental judgments, and if the data differentiation configuration changes, the code often needs to be modified. Summary of the invention
[0004] In order to overcome the problem that differentiated events cannot be completely distinguished by configuration in the existing data differentiation configuration of game development, and often need to modify the code, which is inefficient, the purpose of the present invention is to provide a differentiated event configuration method and system based on behavior tree, which can realize the use of behavior tree to configure different differentiated events, thereby fully realizing the configuration of different situations, and avoiding the need to modify the script code when there are differences in the configuration of certain events.
[0005] The present invention is implemented by the following scheme:
[0006] The differentiated event configuration method based on behavior tree is characterized in that the method steps are as follows:
[0007] Step 1: Create a behavior tree file;
[0008] Step 2: Create a global static function and global static parameter task event node in the behavior tree;
[0009] Step 3: Create a behavior tree singleton class function and parameter task event node in the behavior tree;
[0010] Step 4: Create a function and parameter task event node of the object mount script loaded into memory in the behavior tree;
[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 according to 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 of the global static parameter task event node configuration 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, 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 of the parameter task event node configuration 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 the dictionaries of the class names and singleton instances of all inherited singleton base classes in the program set, and caches them. The corresponding singleton is read according to the configured class name, and the corresponding function is executed, and the parameters are read or set.
[0015] Furthermore, 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 engine's built-in scene search object function is used to find all objects hanging 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 functions are executed, and the parameters are read or set.
[0016] Furthermore, step 5 is further specified as follows: creating a data management task event node of a resident memory global management controller, wherein the content of the data management task event node configuration is a parameter to be read or set, wherein the resident memory global management controller manages the game memory throughout the entire process, caches data to be used by the game throughout the entire process, establishes a reference to the global management controller in the data management task event node, and reads or sets global data according to the configuration.
[0017] Differentiated event configuration system based on behavior tree, including 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 a behavior tree file;
[0019] The creation module A is used to create a behavior tree global static function and a global static parameter task event node in the behavior tree;
[0020] The creation module B is used to create a behavior tree singleton class function and a parameter task event node in the behavior tree;
[0021] The creation module C is used to create a function and parameter task event node of the object mounting script loaded into the memory in the behavior tree;
[0022] The creation module D is used to create a data management task event node of the resident memory global management controller in the behavior tree;
[0023] The allocation module is used to create different configuration files according to regions and establish references. The business layer reads the configuration files and parameters and executes differentiated events.
[0024] Furthermore, the creation module A is further specified as follows: the content of the global static parameter task event node configuration 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, 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 of the parameter task event node configuration 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 the dictionaries of the class names and singleton instances of all inherited singleton base classes in the program set, and caches them. The corresponding singleton is read according to the configured class name, and the corresponding function is executed, and the parameters are read or set.
[0026] Furthermore, the creation module C 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 engine's built-in scene search object function is used to find all objects hanging 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 functions are executed, and the parameters are read or set.
[0027] Furthermore, the creation module D is further specified as follows: creating a data management task event node of a resident memory global management controller, the content of the data management task event node configuration is a parameter to be read or set, the resident memory global management controller manages the game memory throughout the process, caches data to be used throughout the game, establishes a reference to the global management controller in the data management task event node, and reads or sets global data according to the configuration.
[0028] The beneficial effects of the present invention are:
[0029] The differentiated event configuration method and system based on behavior trees of the present invention fully implements configuration according to different situations by using behavior trees to configure different differentiated events, avoiding the need to modify script codes when there are differences in the configuration of certain events such as addition, deletion, and modification, and fully realizes that the business layer is unaware of different situations. When new situations arise, they can also be fully implemented through configuration. When adding, deleting, and modifying the configuration, the coupling with the business logic layer is reduced, thereby improving the efficiency of configuration modification. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 is a flow chart of the method of the present invention;
[0031] Figure 2 It is a structural block diagram of the system of the present invention. DETAILED DESCRIPTION
[0032] The present invention will be further described below in conjunction with the accompanying drawings.
[0033] See also Figure 1 , a differentiated event configuration method based on behavior tree, the method steps are as follows:
[0034] Step 1: Create a behavior tree file;
[0035] Step 2: Create a global static function and global static parameter task event node in the behavior tree;
[0036] Step 3: Create a behavior tree singleton class function and parameter task event node in the behavior tree;
[0037] Step 4: Create a function and parameter task event node of the object mount script loaded into memory in the behavior tree;
[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 according to the region and establish references. The business layer reads the configuration files, reads the parameters, and executes differentiated events.
[0040] To establish a reference here is to drag the edited behavior tree file to the corresponding configuration system that needs to use the event, and trigger the edited behavior tree when the event is triggered.
[0041] The present invention will be further described below in conjunction with a specific embodiment:
[0042] Step 1: Create a differentiated event behavior tree when the configuration requires differentiated events, similar to the behavior tree of the Unity3d engine. Different events correspond to different edited behavior trees.
[0043] Step 2: Create global static function and global static parameter task event nodes used by the behavior tree, similar to the Action behavior node of the Unity3d engine. The content that needs to be configured in this behavior node is the class name and the function to be called or the parameter to be read or set in the class. In this behavior node, use reflection to read the corresponding function or parameter of the assembly, execute the function, read or set 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, which is similar to the Action behavior node of the Unity3d engine. The content that needs to be configured in this behavior node is also the class name and the function to be called in the class and the parameters to be read or set. In this behavior node, reflection is used to read all the dictionaries of all class names and singleton instances of all inherited singleton base classes in the assembly, correspond and cache, read the corresponding singleton according to the configured class name, execute the corresponding function, and read or set parameters;
[0045] Reflection is an existing type of computing that can read functions and parameters in a library or assembly, and can call the functions and parameters in it; the reflection reading here refers to using existing reflection technology to call functions in the game or read related parameters.
[0046] Step 4: Create a function and parameter task event node for the object mounting script loaded into memory, which is similar to the Action behavior node of the Unity3d engine. The content that needs to be configured in this behavior node is the class name and the function to be called in the class, as well as the parameter conditions and the parameters to be read or set. Use the engine's built-in function to find the object of the current scene to find all objects mounted in the class name script, and filter out the corresponding single or multiple objects according to the configured object parameter conditions, and execute the configured function, read or set the parameters;
[0047] Step 5: Create a data management task event node for the resident memory global management controller, which is similar to the Action behavior node of the Unity3d engine. The content that needs to be configured in this behavior node is the parameters to be read or set. It is similar to the global management controller commonly used in game development. This controller usually resides in the game memory throughout the whole process, and caches the data to be used by the game throughout the whole process. In the event node, establish a reference to the global manager and read or set the global data according to the configuration;
[0048] Step 6: Create different configuration files according to different situations (similar to Unity's ScriptableObject, for example, create a local ScriptableObject file in China and a ScriptableObject file abroad). 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 differentiated events. The different data and behaviors of the domestic and foreign environments read the configured data and execute the configured differentiated behaviors respectively.
[0049] See also Figure 2 , a differentiated event configuration system based on behavior tree, including 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 a behavior tree file;
[0051] The creation module A is used to create a behavior tree global static function and a global static parameter task event node in the behavior tree;
[0052] The creation module B is used to create a behavior tree singleton class function and a parameter task event node in the behavior tree;
[0053] The creation module C is used to create a function and parameter task event node of the object mounting script loaded into the memory in the behavior tree;
[0054] The creation module D is used to create a data management task event node of the resident memory global management controller in the behavior tree;
[0055] The allocation module is used to create different configuration files according to regions and establish references. The business layer reads the configuration files and parameters and executes differentiated events.
[0056] The creation module A is further specified as follows: the content of the global static parameter task event node configuration 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, 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 of the parameter task event node configuration 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 the dictionaries of the class names and singleton instances of all inherited singleton base classes in the program set, and caches them. The corresponding singleton is read according to the configured class name, and the corresponding function is executed, and the parameters are read or set.
[0058] The creation module C 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 engine's built-in scene search object function is used to find all objects hanging 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, and the parameters are read or set.
[0059] The creation module D is further specified as follows: creating a data management task event node of a resident memory global management controller, wherein the content of the data management task event node configuration is a parameter to be read or set, wherein the resident memory global management controller manages the game memory throughout the entire process, caches data to be used by the game throughout the entire process, establishes a reference to the global management controller in the data management task event node, and reads or sets global data according to the configuration.
[0060] In summary, the differentiated event configuration method and system based on behavior trees of the present invention fully implements situation-based configuration by using behavior trees to configure different differentiated events, avoiding the need to modify script codes when there are differences in the configuration of certain events, and fully realizing that the business layer is unaware of different situations. When new situations arise, they can also be fully implemented through configuration. When adding, deleting, and modifying the configuration, the coupling with the business logic layer is reduced, thereby improving the efficiency of configuration modification.
[0061] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.
Claims
1. The differentiated event configuration method based on behavior tree is characterized by: The method steps are as follows: Step 1: Create a behavior tree file; Step 2: Create a global static function and global static parameter task event node in the behavior tree; Step 3: Create a behavior tree singleton class function and parameter task event node in the behavior tree; Step 4: Create a function and parameter task event node of the object mount script loaded into memory in the behavior tree; 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 according to the region and establish references. The business layer reads the configuration files, reads the parameters, and executes differentiated events.
2. The behavior tree-based differentiated event configuration method according to claim 1, characterized in that: Step 2 is further specified as follows: the content of the global static parameter task event node configuration 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, reads or sets the parameter. The global static parameter task event node is used to call all static functions or parameters.
3. The differentiated event configuration method based on behavior tree according to claim 1, characterized in that: Step 3 is further specified as follows: the content of the parameter task event node configuration 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 the dictionaries of the class names and singleton instances of all inherited singleton base classes in the program set, and caches them. The corresponding singleton is read according to the configured class name, and the corresponding function is executed, and the parameters are read or set.
4. The differentiated event configuration method based on behavior tree according to claim 1, characterized in that: 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 engine's built-in scene search object function is used to find all objects hanging 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, and the parameters are read or set.
5. The differentiated event configuration method based on behavior tree according to claim 1, characterized in that: Step 5 is further specified as follows: creating a data management task event node for a resident memory global management controller, wherein the content configured in the data management task event node is a parameter to be read or set, wherein the resident memory global management controller manages the game memory throughout the entire process, caches data to be used by the game throughout the entire process, establishes a reference to the global management controller in the data management task event node, and reads or sets global data according to the configuration.
6. Differentiated event configuration system based on behavior tree, characterized by: Including 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 a behavior tree file; The creation module A is used to create a behavior tree global static function and a global static parameter task event node in the behavior tree; The creation module B is used to create a behavior tree singleton class function and a parameter task event node in the behavior tree; The creation module C is used to create a function and parameter task event node of the object mounting script loaded into the memory in the behavior tree; The creation module D is used to create a data management task event node of the resident memory global management controller in the behavior tree; The allocation module is used to create different configuration files according to regions and establish references. The business layer reads the configuration files and parameters and executes differentiated events.
7. The behavior tree-based differentiated event configuration system according to claim 6, characterized in that: The creation module A is further specified as follows: the content of the global static parameter task event node configuration 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, reads or sets the parameter; the global static parameter task event node is used to call all static functions or parameters.
8. The behavior tree-based differentiated event configuration system according to claim 6, characterized in that: The creation module B is further specified as follows: the content of the parameter task event node configuration 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 the dictionaries of the class names and singleton instances of all inherited singleton base classes in the program set, and caches them. The corresponding singleton is read according to the configured class name, and the corresponding function is executed, and the parameters are read or set.
9. The behavior tree-based differentiated event configuration system according to claim 6, characterized in that: The creation module C 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 engine's built-in scene search object function is used to find all objects hanging 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, and the parameters are read or set.
10. The behavior tree-based differentiated event configuration system according to claim 6, characterized in that: The creation module D is further specified as follows: creating a data management task event node of a resident memory global management controller, wherein the content of the data management task event node configuration is a parameter to be read or set, wherein the resident memory global management controller manages the game memory throughout the entire process, caches data to be used by the game throughout the entire process, establishes a reference to the global management controller in the data management task event node, and reads or sets global data according to the configuration.
Citation Information
Patent Citations
Static analysis method and device of behavior tree, behavior tree execution method and device, and behavior tree operation optimization method and device
CN105653271A
Multi-thread transaction processing method based on MongoDB
CN107436881A
Automatic simulation test optimization method based on state behavior tree
CN109669363A
Method for calling an instance of a function, and corresponding device and computer software
US20110271290A1
