Skip to content

Commit

Permalink
Add routine to prevent bots from getting stuck to bot behavior trees
Browse files Browse the repository at this point in the history
  • Loading branch information
perturbed committed Feb 11, 2017
1 parent fa49484 commit 60e1feb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bots/camper.bt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
selector
{
{
behavior unstick

condition alertedToEnemy
{
action fight
Expand Down
2 changes: 2 additions & 0 deletions bots/default.bt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
selector
{
behavior unstick

sequence
{
condition alertedToEnemy
Expand Down
2 changes: 2 additions & 0 deletions bots/reckless.bt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
selector
{
behavior unstick

condition alertedToEnemy
{
action fight
Expand Down
37 changes: 37 additions & 0 deletions bots/unstick.bt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Subroutine to try to prevent bots from getting stuck

condition(stuckTime > 10000)
{
selector
{
condition(stuckTime > 20000)
{
action suicide
}

decorator timer(3000)
{
decorator return(STATUS_FAILURE)
{
action jump
}
}
condition(stuckTime > 17500)
{
action moveInDir(MOVE_FORWARD)
}
condition(stuckTime > 15000)
{
action moveInDir(MOVE_RIGHT)
}
condition(stuckTime > 12500)
{
action moveInDir(MOVE_BACKWARD)
}
sequence
{
action moveInDir(MOVE_LEFT)
action moveTo(E_SELF) // cancel old target which may be causing the bot to walk into a wall, etc.
}
}
}

0 comments on commit 60e1feb

Please sign in to comment.