IBM
Contents Index Previous Next



Navigating in a Behavior Tree


In this first exercise, we will explore the state space of the Demongame system by manually navigating in the behavior tree. The explorer will then behave in a way similar to when running a simulator. However, there are also important differences, which will be pointed out.

By default, the explorer is set up in a way that results in a state space as small as possible. In this set-up, a transition between two states in the behavior tree always corresponds to a complete transition in the SDL process graphs. Also, the number of possible branches from a state is limited to a minimum.

What You Will Learn

Setting Up the Exploration

When interactively exploring the behavior tree, an explorer tool called the Navigator is used.

  1. Start the Navigator by clicking the Navigator button in the Explore module. The Navigator window is opened:

Figure 124 : The Navigator tool

The Navigator shows part of the behavior tree around the current system state. In general, the upper box represents the behavior tree transition leading to the current state, i.e., the transition that just has been executed. The boxes below represent the possible tree transitions from the current state. They are labelled Next 1, Next 2, etc. and have not yet been executed.
Since the system now is in its start state, there is no up node. The only next node is the start transition of Main.
  1. To be able to see the printed trace familiar from simulation, open the Command window from the View menu. (The trace is not printed in the main window of the explorer.)
  2. To switch on GR trace of SDL symbols, select Toggle SDL Trace from the Commands menu in the Explorer window; SDL trace is now enabled. However, an SDL Editor will not be opened until the first transition is executed.

Using the Navigator

  1. In the Navigator, execute the next transition by double-clicking on the Next 1 node. The following happens, in order:
    • In the Navigator, the Up 1 node shows the just executed transition, while the Next 1 node shows the next possible transition, the start transition of Demon. You have now moved down to a system state in the next level of the behavior tree.

Figure 125 : The last and next transition

Figure 126 : The printed trace for the executed transition

  1. If needed, move and resize all opened windows to make them completely visible and still fit on the screen together.
  2. Double-click the Next 1 node to execute the next transition. The start transition of Demon is traced in the Command window and in the SDL Editor.
    At this stage, neither of the two active processes can continue without signal input: Main awaits the signal Newgame from the environment, and Demon awaits the sending of the timer signal T. These are the two transitions from the current state now shown in the Navigator as Next 1 and Next 2. As you can see, the transitions in the boxes are described by the same type of information as in a printed trace.

Figure 127 : Transition descriptions in the Navigator

This means that the explorer gives information of all possible transitions from the current system state, even though they have not been executed yet. (This information cannot easily be obtained when running a simulator.)
  1. Send the timer signal by double-clicking the Next 2 node. The Command window tells us that the timer signal is sent and the Navigator shows that the next transition is the input of the timer T.
  2. Execute the next transition by double-clicking the Next 1 node. This is where the dynamic error in the Demongame system occurs, as explained in the simulator tutorial earlier (see Dynamic Errors). Instead of showing the next transition, the Navigator displays the error message in the next box.

Figure 128 : The dynamic error

Figure 129 : The tail of the Print-Trace module

We cannot go further down this branch of the behavior tree, since a reported error by default truncates the tree at the current state. Instead, we will back up to the state where we could select the output of Newgame.
  1. Double-click the Up 1 node to go back to the previous state. Repeat this action again to go to the state we were in after step 3 above. This way of backing up in the execution is not possible when running a simulator, as you may have noticed when running the Simulator tutorial.
    You should also note that the Next 2 node is marked with three asterisks "***". This is used to indicate that this is the transition we have been backing up through:

Figure 130 : Marking a transition that has been backed through

  1. Execute the Next 1 transition instead. The printed trace shows that the signal Newgame was sent from the environment. The Main process is ready to receive the signal. Note that you do not have to send the signal yourself; this is taken care of automatically by the explorer.
  2. Execute the next transition. The printed trace and the SDL trace show that Main now is in the state Game_On. The Navigator displays the start transition of the newly created Game process.
  3. Execute the start transition of Game. The Navigator will now show the different signal inputs that are required to continue execution: Endgame, Probe, Result, and the timer T.

Figure 131 : Signal inputs required for continued execution

If the number of transitions from a state is large, it may be difficult to see them all in the Navigator when a tree structure is used. To overcome this problem, you can change the display to a list structure.
  1. Click the Toggle Tree quick-button to see how the list structure looks like. Now it is easier to see the possible signals.

Figure 132 : The list structure

  1. Change back to the tree structure.
    We will not continue further down in the behavior tree in this exercise. Figure 133 shows the part of the behavior tree we have explored so far. The nodes in the figure represent states of the complete SDL system. Each node lists the active process instances that have changed since the previous system state, what process state they are in and the content of their input queues. The arrows between the nodes represent the possible tree transitions. They are tagged with a number and the SDL action that causes the transition. The arrow numbers are the same numbers as printed in the Next nodes in the Navigator.
    Note that this is a somewhat different view of the behavior tree compared to the Navigator. In the Navigator, the nodes represent the tree transitions and the process states are not shown.

Figure 133 : A Demongame behavior tree


http://www.ibm.com/rational
Contents Index Previous Next