Skip to content

Commit b422cc9

Browse files
authored
Update FallbackNode.md (BehaviorTree#287)
Fix the pseudocode in the documentation of 'Reactive Fallback' according to its source code.
1 parent 1ea0204 commit b422cc9

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

docs/FallbackNode.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,29 +88,27 @@ if he/she is fully rested.
8888

8989
??? example "See the pseudocode"
9090
``` c++
91-
// index is initialized to 0 in the constructor
9291
status = RUNNING;
9392

9493
for (int index=0; index < number_of_children; index++)
9594
{
9695
child_status = child[index]->tick();
9796
9897
if( child_status == RUNNING ) {
98+
// Suspend all subsequent siblings and return RUNNING.
99+
HaltSubsequentSiblings();
99100
return RUNNING;
100101
}
101-
else if( child_status == FAILURE ) {
102-
// continue the while loop
103-
index++;
104-
}
105-
else if( child_status == SUCCESS ) {
102+
103+
// if child_status == FAILURE, continue to tick next sibling
104+
105+
if( child_status == SUCCESS ) {
106106
// Suspend execution and return SUCCESS.
107-
// At the next tick, index will be the same.
108-
HaltAllChildren();
107+
HaltAllChildren();
109108
return SUCCESS;
110109
}
111110
}
112111
// all the children returned FAILURE. Return FAILURE too.
113-
index = 0;
114112
HaltAllChildren();
115113
return FAILURE;
116114
```

0 commit comments

Comments
 (0)