From 60e1feb841d5f54ac3b8bacd032fdd6beadf01b2 Mon Sep 17 00:00:00 2001 From: perturbed Date: Fri, 10 Feb 2017 22:29:48 -0600 Subject: [PATCH] Add routine to prevent bots from getting stuck to bot behavior trees --- bots/camper.bt | 4 +++- bots/default.bt | 2 ++ bots/reckless.bt | 2 ++ bots/unstick.bt | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 bots/unstick.bt diff --git a/bots/camper.bt b/bots/camper.bt index d93c32a2..63020e1a 100644 --- a/bots/camper.bt +++ b/bots/camper.bt @@ -1,5 +1,7 @@ selector -{ +{ + behavior unstick + condition alertedToEnemy { action fight diff --git a/bots/default.bt b/bots/default.bt index 07348078..1e182d67 100644 --- a/bots/default.bt +++ b/bots/default.bt @@ -1,5 +1,7 @@ selector { + behavior unstick + sequence { condition alertedToEnemy diff --git a/bots/reckless.bt b/bots/reckless.bt index 3d144181..e8341272 100644 --- a/bots/reckless.bt +++ b/bots/reckless.bt @@ -1,5 +1,7 @@ selector { + behavior unstick + condition alertedToEnemy { action fight diff --git a/bots/unstick.bt b/bots/unstick.bt new file mode 100644 index 00000000..d9142801 --- /dev/null +++ b/bots/unstick.bt @@ -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. + } + } +}