Skip to content

Commit

Permalink
Update FallbackNode.md (BehaviorTree#287)
Browse files Browse the repository at this point in the history
Fix the pseudocode in the documentation of 'Reactive Fallback' according to its source code.
  • Loading branch information
liangyuwei authored Jul 11, 2021
1 parent 1ea0204 commit b422cc9
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions docs/FallbackNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,27 @@ if he/she is fully rested.

??? example "See the pseudocode"
``` c++
// index is initialized to 0 in the constructor
status = RUNNING;

for (int index=0; index < number_of_children; index++)
{
child_status = child[index]->tick();
if( child_status == RUNNING ) {
// Suspend all subsequent siblings and return RUNNING.
HaltSubsequentSiblings();
return RUNNING;
}
else if( child_status == FAILURE ) {
// continue the while loop
index++;
}
else if( child_status == SUCCESS ) {
// if child_status == FAILURE, continue to tick next sibling
if( child_status == SUCCESS ) {
// Suspend execution and return SUCCESS.
// At the next tick, index will be the same.
HaltAllChildren();
HaltAllChildren();
return SUCCESS;
}
}
// all the children returned FAILURE. Return FAILURE too.
index = 0;
HaltAllChildren();
return FAILURE;
```
Expand Down

0 comments on commit b422cc9

Please sign in to comment.