-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Today, ticking a behavior tree after it has finished has confusing results. Looking at the code, it seems the intent was that once a `State` finishes, it is not expected to tick again. For example, if you tick a Sequence/Select after it has finished, it always returns `Running`. Here's an example test that shows this strange behavior: ```rust #[test] fn weird_behavior() { let a = 4; let mut bt = BT::new( Select(vec![ Invert(Box::new(Action(Dec))), Invert(Box::new(Action(Dec))), Invert(Box::new(Action(Dec))), ]), (), ); let (a, s, _) = tick(a, 0.1, &mut bt); assert_eq!(a, 1); assert_eq!(s, Failure); let (a, s, _) = tick(a, 0.1, &mut bt); assert_eq!(a, 1); assert_eq!(s, Running); let (a, s, _) = tick(a, 0.1, &mut bt); assert_eq!(a, 1); assert_eq!(s, Running); } ``` This is clearly wrong. We could fix this particular issue (make Sequence/Select return a finished status if you tick it again), but it's not clear that ticking a finished behavior makes sense at all - so perhaps we should stop that. This PR solves this by just keeping track of the BT returns a Success or Failure status and then prevents ticking in those cases (returning an Option)
- Loading branch information
Showing
11 changed files
with
163 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.