The behavior trees presented in class have encoded deterministic (if time variant) mappings from situation to action.
The behavior trees presented in class have encoded deterministic (if time variant) mappings from situation to action. However, characters often seem smarter if they are less predictable. One way to create that effect is to add nondeterminism to behavior trees. For parts (a) and (b) below, use the expression child. execute() to invoke the Behavior Tree interpreter on
a child node.
For parts (a) through (d), assume that the return values of True and False map onto Succeed and Fail, respectively. Also, assume the decorator Until Fail returns true when its child node fails, and Until Succeed returns true when its child succeeds.
(a) 2 points. Write a pseudo-code that implements a Random Selector, which is identical to a normal sequence except that it considers its children in a random order, vs a fixed order.
(b) 2 points. Write pseudo-code for a Random Sequence, which is identical to a normal Sequence, except it considers its children in a random order, vs a fixed order.
(c) 6 points. Use these new node types together any of the following (Sequence; Selector; actions; checks; and the decorators Inverter, Until Fail, Until Succeed, Persist) to draw a behavior tree with this specification:
• Your character needs to move through a room. That room might contain a single enemy.
• The character will randomly consider fighting the enemy and crossing the room without a fight.
• Creeping through the room is only relevant if the character hears but does not see the enemy. Moving through the room is always relevant. Creeping is preferred.
• Fighting is only relevant if the enemy is visible.
• To fight, the character will hit the enemy, pause, and check to see if the enemy is conscious in a random order. This continues until the enemy is unconscious.
• When the enemy is unconscious, the character ties it up.
• On completion of this behavior, the character has either crossed the room, or is in the room facing a restrained and unconscious enemy. In your drawing, denote a Random Selector by
(d) This question asks you to define a portion of its activity as a behavior tree with parallel branches. We define a parallel node, denoted as a non-primitive node with an arbitrary number of children. All of those children will be tried once, and all must succeed for the parallel node to succeed. All of the children are launched in parallel. The moment any child returns Fail, the parallel node returns
Draw a behavior tree with the following specifications:
● The robot is either tidying up trash or recharging.
● Tidying is only relevant so long as trash is visible.
● Recharging is only relevant so long as trash is not visible.
● The tidying action never terminates of its own (it neither returns Success or Failure).
● The recharging action never terminates on its own (it neither returns Success or Failure).
● The robot continues to execute its tidying and recharging behavior forever.