Behavior tree reaction type comprehensive and efficient execution method

By introducing the GR(1) specification, its constructability check and parallel optimization pruning strategy, an efficient behavior tree is built, which solves the problems of high computational complexity and low execution efficiency in the existing methods, and achieves the deep optimization and execution efficiency improvement of the behavior tree.

CN120447906APending Publication Date: 2025-08-08NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510525037.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-24
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

The existing behavior tree generation methods have problems such as high computational complexity, flat structure and low execution efficiency.

Method used

The GR(1) specification and its constructability check were introduced, and the target behavior tree was constructed by combining parallel optimization and pruning strategies.

Benefits of technology

Significantly improve the comprehensive efficiency and execution performance of the behavior tree, the depth of the generated behavior tree is reduced by 30%-50%, and the execution efficiency is improved by more than 20%. It is suitable for real-time decision-making and dynamic adjustment in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120447906A_ABST
    Figure CN120447906A_ABST
Patent Text Reader

Abstract

The invention discloses a behavior tree reaction equation comprehensive and efficient execution method in the technical field of automatic control and formalization methods. The behavior tree reaction equation comprehensive and efficient execution method comprises the following steps: checking constructability of a GR (1) protocol to be synthesized; constructing a target behavior tree based on an intermediate result of the constructability check; and executing and evaluating the target behavior tree by using an execution engine and a simulation environment matched with the target behavior tree. According to the behavior tree reaction equation synthesis and efficient execution method, the GR (1) protocol and constructability check thereof are introduced, and the parallel optimization and pruning strategy is combined, so that the comprehensive efficiency and the execution performance of the behavior tree are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of automatic control and formal methods, and in particular to a behavior tree reactive synthesis and efficient execution method. Background Art

[0002] Behavior Trees (BTs) are directed rooted trees whose leaf nodes are called execution nodes, including condition nodes for judgment and action nodes for performing specific operations; internal nodes are called control flow nodes, including sequential (→), fallback (Fallback) and parallel nodes. Their function is to control and implement different operational processes. For example, a sequence node executes its child nodes in order from left to right, and returns success if all child nodes return success. Behavior trees execute by ticking their child nodes from the root node in a manner similar to depth-first search. A child node runs only when a tick signal is received, and returns one of three states: "success," "failure," or "executing."

[0003] Behavior trees were originally developed for controlling non-player characters (NPCs) in games. Their modularity, reactivity, and other advantages have subsequently made them popular in robotics. Furthermore, behavior trees are a powerful tool in software engineering, particularly in areas requiring complex decision-making and control logic. They play a key role in organizing, controlling, and executing complex behaviors in a modular and maintainable manner, and provide a programming framework for component-based systems and software design. Behavior trees excel in reactive systems, handling task prioritization, and managing faults. As robotics and software systems become increasingly complex, developers have long sought the ability to automatically generate behavior trees. Over the past few decades, researchers have intensively pursued solutions. Existing methods, including evolutionary algorithms, reinforcement learning, task and motion planning, large language models, and learning from demonstrations, have been used to generate behavior trees for various tasks. Compared to the informal methods mentioned above, reactive synthesis, with its correctness guarantees based on rigorous mathematical proofs, has also been applied to the automatic generation of behavior trees.

[0004] Reactive synthesis methods for behavior trees can be divided into two categories. The first category is typified by "Reactive task and motion planning under temporal logic specifications." These methods, implemented in general linear temporal logic (LTL), utilize model checking techniques to synthesize behavior trees from counterexamples of non-emptiness checks in product automata. A product automaton is a product of a Buchi automaton (generated by transforming a negated LTL specification) and a transition system describing the agent and its environment. If the original LTL specification is satisfied, the model checking process identifies a counterexample path (i.e., a state transition path) from which the behavior tree can be constructed. However, the conversion from LTL to a Buchi automaton has exponential time complexity, meaning that the time required for the conversion increases exponentially with the size of the formula. Therefore, methods relying on this strategy inevitably face the challenge of high computational complexity (at least exponential). The second category of methods, exemplified by the "Synthesis of Correct-by-Construction Behavior Trees" approach, synthesizes on LTL fragments, thereby avoiding the doubly exponential time complexity of general LTL synthesis. Six types of LTL templates are selected, each responsible for a different property, including concepts such as "globally holds" and "responding to a signal." For each LTL pattern, a corresponding behavior tree template is designed, and the value function, demand function, and constraint function of each LTL formula are calculated. The automated behavior tree synthesis process combines these behavior tree templates according to LTL conventions. However, due to the lack of nesting support in the selected LTL fragments and the irregularities of formulas and BT templates, this approach always produces a flat behavior tree structure with subtrees of varying sizes. Although each subtree corresponding to an LTL pattern has specific meaning, the assembled behavior tree remains difficult to understand. Summary of the Invention

[0005] The purpose of the present invention is to provide a method for reactive synthesis and efficient execution of behavior trees, which solves the technical problems of high computational complexity, flat structure and low execution efficiency in traditional behavior tree generation methods. By introducing the GR(1) specification and its constructability check, combined with optimization and pruning strategies, the comprehensive efficiency and execution performance of behavior trees are significantly improved.

[0006] In order to achieve the above object, the technical solution of the present invention is as follows:

[0007] A method for reactive synthesis and efficient execution of behavior trees, comprising the following steps:

[0008] S1. Check the constructability of the GR(1) specification to be synthesized;

[0009] S2. Construct the target behavior tree based on the intermediate result of the constructability check in step S1;

[0010] S3. Execute and evaluate the target behavior tree using the target behavior tree's accompanying execution engine and simulation environment.

[0011] Furthermore, the S1 includes the following steps:

[0012] S11. Determine the GR(1) specification of the system to be integrated. The GR(1) specification is defined as follows:

[0013]

[0014] in, and are the set of variables controlled by the environment and the set of variables controlled by the system; θ e and θ s are the initial assumptions of the environment and the initial guarantees of the system, constraining the initial states of the environment and the system; ρ e and ρ s They are respectively the security assumption of the environment and the security guarantee of the system, which constrain the legal migration of the environment and the system from the current state to the next state; e and J s They are the environmental fairness assumption and the system fairness guarantee, which need to be established infinitely often and constrain the ultimate goals of the environment and the system;

[0015] S12. Construct a game structure equivalent to the GR(1) specification. The GR(1) specification defined in step S11 can be transformed into an equivalent game structure GS and GR(1) formula. The definitions are:

[0016]

[0017] in, and is a temporal operator in GR(1), indicating that the property should "always hold" and "will eventually hold";

[0018] S13. Using μ-calculus to solve game problems, game problems By using a three-level nested fixed-point computation approach, we solve the semantics of the following μ-calculus formula to check whether there exists a winning strategy for the system. Here, μ and ν are the minimum and maximum fixed-point operators, respectively, and the symbols X, Y, and Z are relational variables initially assigned the values true, false, and true:

[0019]

[0020] Furthermore, the S13 includes the following steps:

[0021] S131. If the game problem is won by the system, then the GR(1) specification is constructible, and the intermediate result arrays mX, mY and the system winning state set z will be stored and used as input for the next step;

[0022] S132.mX is a three-dimensional array, representing the intermediate computational results for solving the maximum fixed point vX. Let j, r, and i denote the indices along the three dimensions of mX, ranging from [0, n), [0, k), and [0, m), respectively. n, k, and m are the number of fairness guarantees, the number of iterations for solving the fixed point μY, and the number of environmental fairness assumptions, respectively.

[0023] S133.mY is a two-dimensional array, i.e., the intermediate calculation result of solving the minimum fixed point μY. Starting from the state in mY[j][r], the system can move to the state that satisfies the jth goal within r steps. state or violates at least one environmental assumption

[0024] Furthermore, the S2 includes the following steps:

[0025] S21. Build target behavior tree: Use constructability check intermediate result arrays mX and mY and system winning state set z to build the target behavior tree.

[0026] S22. Parallel Optimization and Pruning of Target Behavior Trees: Streamline the behavior tree structure and introduce parallel nodes to further optimize the size and execution efficiency of the generated target behavior tree.

[0027] Furthermore, the S21 includes the following steps:

[0028] S211. Extract the migrations required to achieve the same sub-goal into behavior tree subtrees, and combine the behavior tree subtrees together through control flow nodes. Each subtree subBT j It includes a conditional node to verify the auxiliary variable jx=j? and an action calculation node ρ e ∧ρ s , each subtree subBT jIt also contains a ρ-subtree, whose structure consists of three parts (BT ρx ,x=1,2,3);

[0029] S212.BT ρ1 :The subtree is constructed with the sequence node as the root node and the condition node as the lower node Used to check whether the current state has met the jth fairness goal and the action node Transition the state to a state z′ in the system's winning set |y , and auxiliary variables

[0030] S213.BT ρ2 :The subtree is constructed with the fallback node as the root node, and is connected to many subtrees with similar structures but different contents. ρ2 , each tree ρ2 The structure of the subtree is similar to BT ρ1 , but its condition node checks whether the current state satisfies mY[j][r];, its action node controls the control system to move one step further towards the j-th sub-goal, so that the next state satisfies mY[j][r-1], until the state mY[j][0] is satisfied, that is, the j-th sub-goal is satisfied;

[0031] S214.BT ρ3 :The subtree is constructed with the fallback node as the root node. For the current j and all r and all i, the construction structure is similar to BT ρ1 The bottom subtree of The action node is Act(mX′ |y [j][r][i]∧jx′=j), use control flow nodes to combine these minimum modules to form BT ρ3 .

[0032] Furthermore, the S22 includes the following steps:

[0033] S221. The control flow node at the original location can be replaced with a parallel node if and only if the following two conditions are met: the original control flow node is a selection node and there are no blackboard read / write conflicts or simultaneous conditions and actions between the child nodes;

[0034] S222. Based on the above principle of using parallel nodes, the root node of the target behavior tree, the root node of the ρ-subtree and the BT ρ2 The root nodes of the subtrees can be replaced with parallel nodes;

[0035] S223. If two situations occur, the useless target behavior tree needs to be pruned.

[0036] Furthermore, the S223 includes the following steps:

[0037] S2231. If the condition to be judged of the conditional node in the sequence subtree is false, any subsequent nodes will no longer be executed, and the entire sequence subtree will be removed;

[0038] S2232. If the control flow node has only one child node, the control flow node can be removed, and its child node will be directly mounted on the parent node of the control flow node, effectively reducing the depth of the tree.

[0039] Furthermore, the S3 includes the following steps:

[0040] S31. Implement an execution engine and random environment that matches the target behavior tree. Add a user-transparent internal behavior tree blackboard to store the current state of the system and environment, the currently executing sub-strategy, and the intermediate results of BDD calculations.

[0041] S32. Both the action and condition nodes of the behavior tree can access the internal blackboard of the behavior tree.

[0042] S33. In a stochastic environment, the environment and the system randomly choose their next action from a set of currently feasible options.

[0043] By adopting the above technical solution, the present invention has the following advantages:

[0044] The present invention provides a method for reactive synthesis and efficient execution of behavior trees, which solves the problems of existing target behavior trees being flat and irregular in structure and requiring the calculation of multiple additional functions. The method of the present invention utilizes the GR(1) specification and its constructability check, fully utilizes the intermediate results of the constructability check and the local characteristics of the GR(1) strategy execution, and efficiently guides the construction of the behavior tree. The parallel optimization and pruning strategy is used to streamline the size of the behavior tree, further improve the execution efficiency of the behavior tree, and significantly improve the overall efficiency and execution performance of the behavior tree. Compared with the traditional LTL method, the synthesis time is reduced, the depth of the behavior tree generated by this method is reduced by 30%-50%, the execution efficiency is improved by more than 20%, and the structure is optimized. In addition, the method has enhanced applicability and supports real-time decision-making and dynamic adjustment in complex environments. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 Schematic diagram of the flow of the behavior tree reactive synthesis and efficient execution method of the present invention;

[0046] Figure 2 This is a schematic diagram of the structure of a target behavior tree constructed in a specific embodiment of the present invention;

[0047] Figure 3Schematic diagram of the structure of the subtree in the target behavior tree constructed by the present invention and BT ρ3 Schematic diagram of the pruning effect on . DETAILED DESCRIPTION

[0048] The technical solution of the present invention is described in detail below with reference to the accompanying drawings. It should be noted that, in this document, relational terms such as first and second, etc., are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "include," "comprise," or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or apparatus that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article, or apparatus.

[0049] A method for reactive synthesis and efficient execution of behavior trees, including the following specific steps: Figure 1 As shown:

[0050] Step S1: Check the constructability (realizability) of the GR (1) specification to be synthesized. Its function is to use the existing public game-based solution method to check whether there is a feasible implementation of the specification provided by the designer. If not, the program terminates and the designer needs to further refine the specification to ensure its realizability. If so, the intermediate result arrays mX, mY and the system winning variable set z are retained for the subsequent construction of the target behavior tree.

[0051] S1 includes the following specific steps:

[0052] S11. Determine the GR(1) specification of the system to be integrated. The GR(1) specification is defined as follows:

[0053]

[0054] in, and are the set of variables controlled by the environment and the set of variables controlled by the system; θ e and θ s They are the initial assumption of the environment and the initial guarantee of the system, constraining the initial states of the environment and the system; ρ e and ρ s They are respectively the security assumption of the environment and the security guarantee of the system, which constrain the legal migration of the environment and the system from the current state to the next state; e and J sThey are the environmental fairness assumption and the system fairness guarantee, which need to be established infinitely often and constrain the ultimate goals of the environment and the system;

[0055] S12. Construct a game structure equivalent to the GR(1) specification. The GR(1) specification defined in step S11 can be transformed into an equivalent game structure GS and GR(1) formula. The definitions are:

[0056]

[0057] in, and is a temporal operator in GR(1), indicating that the property should "always hold" and "will eventually hold"; in addition, the game problem obtained by the transformation The system winability of is equivalent to the constructability of the original GR(1) specification, that is, if a system winning strategy for the game problem can be found, then the original GR(1) specification is also constructable. In this way, the constructability problem of the GR(1) specification is transformed into a game solving problem.

[0058] S13. Using μ-calculus to solve game problems, game problems By using a three-level nested fixed-point computation, we solve the semantics of the following μ-calculus formula to check whether there is a winning strategy for the system. Here, μ and v are the minimum and maximum fixed-point operators, respectively, and the symbols X, Y, and Z are relational variables initially assigned the values true, false, and true:

[0059]

[0060] Wherein, S13 includes the following specific steps:

[0061] S131. If the system wins the game, then the original GR(1) specification is constructible, and the intermediate result arrays mX, mY and the system winning state set z will be stored and used as input for the next step.

[0062] S132.mX is a three-dimensional array that records the fixed point calculation results of the innermost security game, that is, the maximum fixed point vX. Let j, r, i represent the indexes on the three dimensions of mX, and their value ranges are [0, n), [0, k), and [0, m), respectively. Among them, n, k, m are the number of fairness guarantees of the system, the number of iterations to solve the fixed point μY, and the number of environmental fairness assumptions. Intuitively, starting from the state in mX[j][r][i], the system needs at most r steps to reach state, thereby satisfying the jth system goal; or continuously violating the ith environmental assumption By violating the left side of GR(1), the formula is always valid.

[0063] S133.mY is a two-dimensional array that records the solution of the sub-outer reachability fixed point, that is, the minimum fixed point μY. Starting from the state in mY[j][r], the system can also move to the state that satisfies the jth goal within r steps. state, or violates at least one environmental assumption

[0064] Step S2: Construct a target behavior tree based on the intermediate result of the constructability check in step S1. This is to fully utilize the locality of the GR(1) strategy execution based on the intermediate result of the constructability check, superimpose pruning and parallel optimization, and extract a target behavior tree that complies with the GR(1) specification and has high execution efficiency.

[0065] S2 includes the following specific steps:

[0066] S21. Use the constructability check intermediate result arrays mX and mY and the system winning state set z to construct the target behavior tree. The classic method for extracting strategies uses the following method to construct a fair discrete system with the transition rule ρ = ρ1∨ρ2∨ρ3. The components are as follows:

[0067]

[0068] Intuitively, if the current state has fallen into the system's winning state set, it will be processed by the first part ρ1, which will assign the auxiliary variable jx to And the next state is transferred to a state in the winning set z (for example, a random state is selected). If the current state satisfies mY[j][r], then the second part ρ2 comes into play, and then the system will transfer to a state closer to satisfying Finally, if the current state falls into mX[j][r][i], the sub-policy ρ3 starts to take effect, which will force the system to remain in the mX[j][r][i] state, making the entire implication valid by violating the left side of the GR(1) formula.

[0069] Step S21 discovers and proves the locality of the execution of the fair discrete system constructed by the classical method. The sub-strategy here refers to the sub-strategy constructed to achieve a certain fairness goal, not ρ1, ρ2, or ρ3 in the classical construction method.

[0070] (Proposition 1.) When the system is executed, the number of state transitions that occur within a sub-strategy will far exceed the number of state transitions that occur between sub-strategies.

[0071] (Proof:) A state satisfies the conjunction of the jth fairness guarantee and the winning set if and only if When the system transfers from the current sub-strategy (assuming it is the jth, j∈[0..n)) to the next substrategy. However, from the transition strategies ρ2 and ρ3 (if they exist) in the fair discrete system, it can be seen that in order to reach such a state, the system needs to move at least r steps (r is the number of iterations to calculate μY, r>1). This situation occurs for all fairness objectives, that is, before switching from one substrategy to another, the system needs to move r (r>1) steps to meet the switching condition. Therefore, the number of state transitions within the substrategy is greater than the number of state transitions before the substrategy, and Proposition 1 holds. In addition, if ρ2 and ρ3 are empty (that is, r=1), this means that only ρ1 migration exists in the fair discrete system. This situation occurs when the system's winning set is the entire state space. However, this is meaningless in practice because the user has not given a valid specification. Therefore, we do not consider this situation.

[0072] Among them, S21 includes the following specific steps:

[0073] S211. Using this feature and combining it with the modularity of the behavior tree, we extract the migrations required to achieve the same sub-goal into a behavior tree subtree. Each subtree is also a sub-strategy. Finally, we combine these subtrees together through control flow nodes. The sub-strategy at this point is no longer the ρ in the classic method. x (x=1,2,3), but a set of steps required to achieve a certain fairness goal. In addition, the present invention uses behavior trees to split the migration rules constructed in the classic method (stored as binary decision diagrams (BDDs) and calculated) into smaller BDDs. Compared with the classic method, it effectively improves the efficiency of constructing and executing the target behavior tree. Specifically, the entire behavior tree structure constructed is as follows Figure 2 As shown, each subtree subBT j This is the sub-strategy constructed to achieve the j-th system fairness goal. Each subtree subBT j First, it includes a conditional node to verify the auxiliary variable jx=j?, which is used to identify whether the current target is moving towards the sub-goal; and an action calculation node ρ e ∧ρ s , used to determine whether the current migration complies with the migration constraints in the GR(1) specification. In addition, each subtree subBT j It also contains a ρ-subtree, whose structure consists of three parts (BT ρx ,x=1,2,3), their meanings and construction methods are as follows:

[0074] S212.BTρ1 :The subtree is constructed with the sequence node as the root node and the condition node as the lower node Used to check whether the current state has met the jth fairness goal and the action node Transition the state to a state z′ in the system's winning set |y , and auxiliary variables

[0075] S213.BT ρ2 :The subtree is constructed with the fallback node as the root node, and is connected to many subtrees with similar structures but different contents. ρ2 , each tree ρ2 The structure of the subtree is similar to BT ρ1 , but its condition node checks whether the current state satisfies mY[j][r];, its action node controls the control system to move one step further towards the j-th sub-goal, so that the next state satisfies mY[j][r-1], until the state mY[j][0] is satisfied, that is, the j-th sub-goal is satisfied;

[0076] S214.BT ρ3 :The subtree is constructed with the fallback node as the root node. For the current j and all r and all i, the construction structure is similar to BT ρ1 The bottom subtree of The action node is Act(mX′ |y [j][r][i]∧jx′=j), use control flow nodes to combine these minimum modules to form BT ρ3 .

[0077] S22. Parallel Optimization and Pruning of the Target Behavior Tree: This streamlines the behavior tree structure and introduces parallel nodes, aiming to further optimize the size and execution efficiency of the generated target behavior tree. Parallel nodes in a behavior tree can execute their child nodes simultaneously. These nodes contain two additional parameters, N and M: N is the total number of child nodes, and M (M≤N) is a manually set threshold. During execution, a parallel node returns a success if M child nodes have succeeded. The threshold M for parallel nodes mentioned in this disclosure is always 1.

[0078] S22 includes the following specific steps:

[0079] S221. A control flow node at the original location can be replaced with a parallel node if and only if the node satisfies the following two conditions:

[0080] (1) The original control flow node is a selection node;

[0081] (2) There will be no blackboard read and write conflicts or simultaneous conditions and actions between child nodes.

[0082] S222. Based on the above principle of using parallel nodes, the root node of the target behavior tree, the root node of the ρ-subtree and the BT ρ2 The root nodes of the subtrees can all be replaced with parallel nodes (M=1).

[0083] S223. If the following two situations occur, the useless target behavior tree needs to be pruned.

[0084] S223 includes the following steps:

[0085] S2231. The first case is that the condition to be judged of the conditional node in the sequential subtree is false, that is, there is no state that can make the conditional node return to success. At this time, no subsequent nodes can be executed, so the entire sequential subtree is eliminated;

[0086] S2232. In the second case, if a control flow node has only one child node, the control flow node can be removed and its child node will be directly mounted on the parent node of the control flow node. In this case, the tree depth is effectively reduced, the tick efficiency is improved, and this operation does not change the execution semantics of the behavior tree.

[0087] Step S3 (optional): After Step S2, the target behavior tree has been generated and the core algorithm flow has concluded. Therefore, Step S3 is an optional evaluation step. The target behavior tree, which meets the design specifications, has been synthesized, and the synthesis algorithm is now complete. Designers can then run and evaluate the target behavior tree in the execution engine or simulation environment.

[0088] S3 includes the following steps:

[0089] S31. Execute and evaluate the behavior tree using the execution engine and simulation environment provided by the present invention. This allows for quick and convenient evaluation of the target behavior tree using the provided execution engine and random simulation environment. This engine incorporates a user-transparent behavior tree internal blackboard, which stores the current state of the system and environment, the currently executing sub-strategy, and intermediate BDD calculation results.

[0090] S32. Both the action and condition nodes of the behavior tree can access the internal blackboard of the behavior tree.

[0091] S33. In a stochastic environment, the environment and the system randomly select their next action from a set of currently available options. For example, the agent will randomly choose to move up or left to avoid an attack (if both options are available in the current state).

[0092] In a specific embodiment, the specific working mode of the method is as follows Figure 1 As shown: First, the designer gives the GR(1) specification of the system to be integrated, including the frame environment variable set and system variable collections Determine the initial state θ of the environment and system e and θ s , determine the legal migration of the environment and system ρ e and ρ s , and finally determine the goals of the environment and systemJ e and J s Then, the specification is fed into the constructability checker and step S1 is executed, which constructs a game problem equivalent to the GR(1) specification. And by solving the fixed point of the game through μ-calculus, it is judged whether the input specification is constructible. If the specification is not constructible, the program terminates directly, and the designer needs to further refine and modify the GR(1) specification to ensure that there is a feasible implementation. If the specification is constructible, that is, there is a system that can meet the design specification, then continue to step S2, extracting the execution strategy (behavior tree) of the target system from the intermediate result arrays mX and mY of the constructibility check and the system winning state set z. Step S2 contains two sub-steps, step S21 uses the locality property to construct the target behavior tree and step S22 performs parallel optimization and pruning on the target behavior tree. In a specific embodiment, step S21 and step S22 are not explicitly separated, but are performed in a way of constructing the target behavior tree with parallel nodes while pruning. The input of this step is the intermediate result arrays mX and mY calculated by step S1, the winning set z and the auxiliary variable jx, which is used to indicate the sub-strategy number currently being executed. This step uses the parallel node as the root node of the entire target behavior tree, and then constructs the complete behavior tree by embedding two inner loops in an outer loop. The outer loop traverses from j=0 to j=n-1, and its purpose is to construct the following for each sub-target: Figure 2 The behavior tree subtree (subBT j ), where the condition node (jx=j?) is used to determine whether the current sub-strategy is being executed, and the action node (ρ e ∧ρ s ) is used to require that the environment and system migration meet the migration conditions. At the same time, the outer loop will also construct Figure 2 Chinese BT ρ BT of subtree ρ1 The subtree, because it has only a single layer structure, does not require additional nested loops. Figure 3 The following diagram shows the structure of the subtree in the target behavior tree constructed by the present invention and the pruning effect diagram. Figure 3 (a) Figure 3 (b) Figure 3 (c) BT in the constructed target behavior tree ρx Schematic diagram of the subtree structure, Figure 3 (d) BT ρ3 Next, we use the pruning effect diagram constructed to achieve the j-th sub-goal Subtree as an example, its structure is as follows Figure 3 As shown in (a), the conditional node is constructed as The action node is constructed as Symbols such as jx′ represent the next action in the current state. This part of the behavior tree shows that if the current state can already meet the jth sub-goal Then the next step will be to migrate to a state z′ in the system's winning set |y , and auxiliary variables Next, the first nested loop is used to construct subBT j BT ρ2 The subtree has the following structure: Figure 3 As shown in (b), the role of this subtree is to handle the situation where the current state mY[j][r] (for the current j and all r) is satisfied. First, its root node is set as a parallel node because it can meet the two conditions for parallel nodes in the present invention. Then, the loop will traverse r and construct a structure similar to BT for each mY[j][r] situation. ρ1 subtree ρ2 , however, its conditional node is The action node is Act(mY[j][r-1]′ |y ∧jx′=j). This part shows that if the current state is mY[j][r] state that satisfies a specific j and r, then the system will migrate to mY[j][r-1] state while keeping the value of the auxiliary variable jx unchanged, so that the system continues to move towards the jx-th sub-goal. Finally, the second nested loop is used to construct subBT j BT ρ3 The subtree has the following structure: Figure 3 As shown in (c), the role of this subtree is to handle the situation where the current state satisfies mX[j][r][i] (for the current j and all r and all i). First, its root node is set as the fallback node, and then two layers of loops are used to traverse r and i respectively, and a structure similar to BT is constructed for each mX[j][r][i] situation. ρ1 The subtree of , whose conditional node is The action node is Act(mX′ |y[j][r][i]∧jx′=j). This section states that if the current state is mX[j][r][i] for a specific j, r, and i, then the system will continue to maintain this state and the value of the auxiliary variable jx unchanged in the next step, ensuring the validity of the specification by continuously violating a certain fairness assumption.

[0093] In addition, the pruning process is carried out simultaneously with the above loop process. Once the condition to be checked by the conditional node is found to be false, the sequential behavior subtree will be directly discarded and will not be mounted. Once it is found that the control flow node has only one child node, the control flow node will be removed, and its child node will be directly mounted to the parent node of the removed control flow node. Figure 3 As shown in (c), assuming that there is only one level-3 subtree under the level-2 sequence node, the level-2 sequence node will be deleted, and the level-3 subtree will be directly mounted under the level-1 node. The streamlined effect is as follows Figure 3 (d). After step S2 is completed, the target behavior tree that meets the GR(1) design specification has been successfully synthesized, and the synthesis algorithm ends. The designer can then choose to run and evaluate the target behavior tree in an execution engine and simulation environment.

[0094] Step S3 implements the execution engine that matches the target behavior tree, and adds an internal blackboard (Inner Blackboard) of the behavior tree that is transparent to the user to store information such as the current state of the system and environment, the currently executed sub-strategy, and the intermediate results of the BDD calculation. The action and condition nodes of the behavior tree can access this blackboard. During execution, the root node (parallel node) of the target behavior tree receives a tick signal, and then the root node ticks all its child nodes at the same time. The tick signal will be transmitted to each subtree, followed by the leftmost child node (condition node) Cond(jx=j), j∈{0,···,n-1}. After the condition node starts running, it will query the value of jx in the internal blackboard to check whether it is currently running at the jth subtree, and only one subtree will return "running". Then, at the next tick, the subtree that can run will run its next node ρ e ∧ρ s , the execution engine calculates the current state, environment migration and ρ e ∧ρ sThe conjunction of the intermediate nodes and the action is calculated to verify the legality of the current migration, and the intermediate result is written to the blackboard. Finally, if an action is executed, the execution engine first calculates the conjunction of the above intermediate nodes and the action, and then determines the legal operation. Finally, the value of the variable to be operated is updated. Because the method of the present invention does not involve the synthesis of the underlying atomic actions, if it involves operations in a simulation environment, an additional action library is required to record the operation function corresponding to each system control variable. In a random environment, the environment and the system randomly select their next action from the currently feasible option set. For example, the agent will randomly choose to move up or left to avoid an attack (if both options are available in the current state).

[0095] In one specific embodiment, the publicly available C++ BDD tool library CUDD (Version 3.0, https: / / github.com / ivmai / cudd) was used to implement binary decision diagrams (BDDs). This tool library offers numerous advantages, including high performance, rich functionality, strong flexibility, and excellent stability. It was used for all BDD-related operations, storage, and computations in this embodiment.

[0096] Finally, it should be pointed out that although the present invention has been described with reference to the current specific embodiments, ordinary technicians in this technical field should realize that the above embodiments are only used to illustrate the present invention and are not used to limit the present invention. Various equivalent changes or substitutions can be made without departing from the concept of the present invention. Therefore, as long as the changes and modifications to the above embodiments are within the scope of the essential spirit of the present invention, they will fall within the scope of the claims of the present invention.

Claims

1. A method for reactive synthesis and efficient execution of behavior trees, characterized by: The following steps are involved: S1. Check the constructability of the GR(1) specification to be synthesized; S2. Construct the target behavior tree based on the intermediate result of the constructability check in step S1; S3. Execute and evaluate the target behavior tree using the target behavior tree's accompanying execution engine and simulation environment.

2. A behavior tree reactive synthesis and efficient execution method according to claim 1, characterized in that: Said S1 comprises the following steps: S11. Determine the GR(1) specification of the system to be integrated. The GR(1) specification is defined as follows: in, and are the set of variables controlled by the environment and the set of variables controlled by the system; θ e and θ s are the initial assumptions of the environment and the initial guarantees of the system, constraining the initial states of the environment and the system; ρ e and ρ s They are respectively the security assumption of the environment and the security guarantee of the system, which constrain the legal migration of the environment and the system from the current state to the next state; e and J s They are the environmental fairness assumption and the system fairness guarantee, which need to be established infinitely often and constrain the ultimate goals of the environment and the system; S12. Construct a game structure equivalent to the GR(1) specification. The GR(1) specification defined in step S11 can be transformed into an equivalent game structure GS and GR(1) formula. The definitions are: in, and is a temporal operator in GR(1), indicating that a property should "always hold" and "will eventually hold"; S13. Using μ-calculus to solve game problems, game problems By using a three-level nested fixed-point computation approach, we solve the semantics of the following μ-calculus formula to check whether there is a winning strategy for the system, where μ and ν are the minimum and maximum fixed-point operators, respectively, and the symbols X, Y, and Z are relational variables initially assigned the values true, false, and true:

3. A behavior tree reactive synthesis and efficient execution method according to claim 2, characterized in that: The S13 includes the following steps: S131. If the game problem is won by the system, then the GR(1) specification is constructible, and the intermediate result arrays mX, mY and the system winning state set z will be stored and used as input for the next step; S132.mX is a three-dimensional array, representing the intermediate results of the computation for the maximum fixed point νX. Let j, r, and i denote the indices along the three dimensions of mX, ranging from [0, n), [0, k), and [0, m), respectively. n, k, and m are the number of fairness guarantees, the number of iterations for the fixed point μY, and the number of environmental fairness assumptions, respectively. S133.mY is a two-dimensional array, i.e., the intermediate calculation result of solving the second outer layer minimum fixed point μY. Starting from the state in mY[j][r], the system can move to the state that satisfies the jth goal within r steps. state or violates at least one environmental assumption 4. A behavior tree reactive synthesis and efficient execution method according to claim 3, characterized in that: The S2 comprises the following steps: S21. Build target behavior tree: Use constructability check intermediate result arrays mX and mY and system winning state set z to build the target behavior tree. S22. Parallel Optimization and Pruning of Target Behavior Trees: Streamline the behavior tree structure and introduce parallel nodes to further optimize the size and execution efficiency of the generated target behavior tree.

5. The method for reactive synthesis and efficient execution of behavior trees according to claim 4, characterized in that: The S21 includes the following steps: S211. Extract the migrations required to achieve the same sub-goal into behavior tree subtrees, and combine the behavior tree subtrees together through control flow nodes. Each subtree subBT j It includes a conditional node to verify the auxiliary variable jx=j? and an action calculation node ρ e ∧ρ s , each subtree subBT j It also contains a ρ-subtree, whose structure consists of three parts (BT ρx ,x=1,2,3); S212.BT ρ1 :The subtree is constructed with the sequence node as the root node and the condition node as the lower node Used to check whether the current state has met the jth fairness goal, and the action node Act(z′ |y ∧jx′=j⊕1) Transition the state to a state z′ in the system’s winning set |y , and auxiliary variable jx′=j⊕1; S213.BT ρ2 :The subtree is constructed with the fallback node as the root node, and is connected to many subtrees with similar structures but different contents. ρ2 , each tree ρ2 The structure of the subtree is similar to BT ρ1 , but its condition node checks whether the current state satisfies mY[j][r]; its action node controls the system to move one step further towards the j-th sub-goal, so that the next state satisfies mY[j][r-1], until the state mY[j][0] is satisfied, that is, the j-th sub-goal is satisfied; S214.BT ρ3 :The subtree is constructed with the fallback node as the root node. For the current j and all r and all i, the construction structure is similar to BT ρ1 The bottom subtree of The action node is Act(mX′ |y [j][r][i]∧jx′=j), use control flow nodes to combine these minimum modules to form BT ρ3 .

6. A behavior tree reactive synthesis and efficient execution method according to claim 4, characterized in that: The S22 includes the following steps: S221. The control flow node at the original location can be replaced with a parallel node if and only if the following two conditions are met: the original control flow node is a selection node and there are no blackboard read / write conflicts or simultaneous conditions and actions between the child nodes; S222. Based on the above principle of using parallel nodes, the root node of the target behavior tree, the root node of the ρ-subtree and the BT ρ2 The root nodes of the subtrees can be replaced with parallel nodes; S223. If two situations occur, the useless target behavior tree needs to be pruned.

7. The method for reactive synthesis and efficient execution of behavior trees according to claim 6, characterized in that: The S223 includes the following steps: S2231. If the condition to be judged of the conditional node in the sequence subtree is false, any subsequent nodes will no longer be executed, and the entire sequence subtree will be removed; S2232. If the control flow node has only one child node, the control flow node can be removed, and its child node will be directly mounted on the parent node of the control flow node, so that the depth of the tree is effectively reduced.

8. The method for reactive synthesis and efficient execution of behavior trees according to claim 7, characterized in that: The S3 includes the following steps: S31. Implement an execution engine and random environment that matches the target behavior tree. Add a user-transparent internal blackboard to the behavior tree to store the current state of the system and environment, the currently executing sub-strategy, and the intermediate results of the BDD calculation. S32. The action and condition nodes of the behavior tree can access and write to the behavior tree's internal blackboard. S33. In a stochastic environment, the environment and the system randomly choose their next action from a set of currently feasible options.