Class: BehaviorTree::Builder
- Inherits:
-
Object
- Object
- BehaviorTree::Builder
- Extended by:
- Dsl::InitialConfig, Dsl::Randomizer, Dsl::Registration, Dsl::SpellChecker, Dsl::Utils
- Defined in:
- lib/behavior_tree/builder.rb
Overview
DSL for building a tree.
Class Method Summary collapse
Methods included from Dsl::Registration
Methods included from Dsl::Randomizer
Methods included from Dsl::InitialConfig
Class Method Details
.build(&block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/behavior_tree/builder.rb', line 20 def build(&block) # Stack of lists. When a method like 'sequence' is executed, the resulting # sequence object will be stored in the last list. Then, the whole list will # be retrieved as the node children. @stack = [] stack_children_from_block(block) tree_main_nodes = @stack.pop raise DSLStandardError, 'Tree main node should be a single node' if tree_main_nodes.count > 1 raise 'Tree structure is incorrect. Probably a problem with the library.' unless @stack.empty? BehaviorTree::Tree.new tree_main_nodes.first end |