From eb1fc65d7ee03a759234430c2ab1db3b4f82f376 Mon Sep 17 00:00:00 2001 From: Krzysztof Bartocha Date: Mon, 26 Sep 2022 13:23:20 +0200 Subject: [PATCH 1/5] Update BranchTask.java do not clean the children --- gdx-ai/src/com/badlogic/gdx/ai/btree/BranchTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/BranchTask.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/BranchTask.java index adef60c5..38885530 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/BranchTask.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/BranchTask.java @@ -73,7 +73,7 @@ protected Task copyTo (Task task) { @Override public void reset() { - children.clear(); + //children.clear(); super.reset(); } From a3c1797b4f69e94382471ca80276428da3c75da2 Mon Sep 17 00:00:00 2001 From: Krzysztof Bartocha Date: Mon, 26 Sep 2022 14:17:04 +0200 Subject: [PATCH 2/5] Update Wait.java do not reset seconds --- gdx-ai/src/com/badlogic/gdx/ai/btree/leaf/Wait.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/leaf/Wait.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/leaf/Wait.java index 687f7b96..4cd66c80 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/leaf/Wait.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/leaf/Wait.java @@ -85,7 +85,7 @@ protected Task copyTo (Task task) { @Override public void reset() { - seconds = ConstantFloatDistribution.ZERO; + //seconds = ConstantFloatDistribution.ZERO; startTime = 0; timeout = 0; super.reset(); From 5c70236d625caeef7e279cf4d22b84d5a9065d38 Mon Sep 17 00:00:00 2001 From: krzysztofbartocha Date: Mon, 26 Sep 2022 15:34:31 +0200 Subject: [PATCH 3/5] bug fix --- gdx-ai/src/com/badlogic/gdx/ai/btree/BranchTask.java | 2 +- .../src/com/badlogic/gdx/ai/btree/LoopDecorator.java | 10 ++++++++-- .../src/com/badlogic/gdx/ai/btree/branch/Parallel.java | 2 +- gdx-ai/src/com/badlogic/gdx/ai/btree/leaf/Wait.java | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/BranchTask.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/BranchTask.java index 38885530..adef60c5 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/BranchTask.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/BranchTask.java @@ -73,7 +73,7 @@ protected Task copyTo (Task task) { @Override public void reset() { - //children.clear(); + children.clear(); super.reset(); } diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java index 0e60a68e..32b76509 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java @@ -49,14 +49,20 @@ public void run () { while (condition()) { if (child.status == Status.RUNNING) { child.run(); - } else { - child.setControl(this); + } + else { + if(child.status == Status.FRESH) { + child.setControl(this); + } else { + child.reset(); + } child.start(); if (child.checkGuard(this)) child.run(); else child.fail(); } + } } diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/branch/Parallel.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/branch/Parallel.java index 95a7f6ba..69835412 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/branch/Parallel.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/branch/Parallel.java @@ -155,7 +155,7 @@ protected Task copyTo (Task task) { public void resetAllChildren() { for (int i = 0, n = getChildCount(); i < n; i++) { Task child = getChild(i); - child.reset(); + child.resetTask(); } } diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/leaf/Wait.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/leaf/Wait.java index 4cd66c80..687f7b96 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/leaf/Wait.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/leaf/Wait.java @@ -85,7 +85,7 @@ protected Task copyTo (Task task) { @Override public void reset() { - //seconds = ConstantFloatDistribution.ZERO; + seconds = ConstantFloatDistribution.ZERO; startTime = 0; timeout = 0; super.reset(); From 15963c6426352bfb7d0c54fde084a23da6f310b9 Mon Sep 17 00:00:00 2001 From: krzysztofbartocha Date: Mon, 26 Sep 2022 15:59:03 +0200 Subject: [PATCH 4/5] bug fix --- gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java index 32b76509..12aa5fbd 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java @@ -54,7 +54,7 @@ public void run () { if(child.status == Status.FRESH) { child.setControl(this); } else { - child.reset(); + child.resetTask(); } child.start(); if (child.checkGuard(this)) From 956f7c11d14f89063a5e37789899a966e59c668a Mon Sep 17 00:00:00 2001 From: krzysztofbartocha Date: Mon, 26 Sep 2022 17:24:55 +0200 Subject: [PATCH 5/5] loop decorator --- .../src/com/badlogic/gdx/ai/btree/LoopDecorator.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java b/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java index 12aa5fbd..0e60a68e 100644 --- a/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java +++ b/gdx-ai/src/com/badlogic/gdx/ai/btree/LoopDecorator.java @@ -49,20 +49,14 @@ public void run () { while (condition()) { if (child.status == Status.RUNNING) { child.run(); - } - else { - if(child.status == Status.FRESH) { - child.setControl(this); - } else { - child.resetTask(); - } + } else { + child.setControl(this); child.start(); if (child.checkGuard(this)) child.run(); else child.fail(); } - } }