From 179a37e3ded8a641c779549e6cfb08da8be75c8b Mon Sep 17 00:00:00 2001 From: Jan Werder Date: Thu, 14 Dec 2023 14:10:16 +0100 Subject: [PATCH 1/2] Create ArithmeticPostconditionsTests.cs --- .../ArithmeticPostconditionsTests.cs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 MountainGoapTest/ArithmeticPostconditionsTests.cs diff --git a/MountainGoapTest/ArithmeticPostconditionsTests.cs b/MountainGoapTest/ArithmeticPostconditionsTests.cs new file mode 100644 index 0000000..4d6e45a --- /dev/null +++ b/MountainGoapTest/ArithmeticPostconditionsTests.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MountainGoapTest +{ + public class ArithmeticPostconditionsTests + { + [Fact] + public void MinimalExampleText() + { + + List goals = new List(){ + new Goal( + name: "Goal1", + desiredState: new() { + { "i", new ComparisonValuePair { + Value = 100, + Operator = ComparisonOperator.GreaterThan + } } + }, + weight: 1f + ), + }; + + List actions = new List(){ + new MountainGoap.Action( + name: "Action1", + executor: (Agent agent, MountainGoap.Action action) => { + return ExecutionStatus.Succeeded; + }, + arithmeticPostconditions: new Dictionary { + { "i", 10 } + }, + cost: 0.5f + ), + }; + + Agent agent = new Agent( + goals: goals, + actions: actions, + state: new() { + { "i", 0 } + } + ); + + agent.Step(StepMode.OneAction); + Assert.Equal(10, agent.State["i"]); + + } + } +} From 7b8c735f0bded5f473f2486f1196ffcad28aad4d Mon Sep 17 00:00:00 2001 From: Jan Date: Sat, 16 Dec 2023 18:02:01 +0100 Subject: [PATCH 2/2] Fixed Test: Use ComparativeGoal instead of Goal --- MountainGoapTest/ArithmeticPostconditionsTests.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MountainGoapTest/ArithmeticPostconditionsTests.cs b/MountainGoapTest/ArithmeticPostconditionsTests.cs index 4d6e45a..bbc4cf0 100644 --- a/MountainGoapTest/ArithmeticPostconditionsTests.cs +++ b/MountainGoapTest/ArithmeticPostconditionsTests.cs @@ -9,11 +9,11 @@ namespace MountainGoapTest public class ArithmeticPostconditionsTests { [Fact] - public void MinimalExampleText() + public void MinimalExampleTest() { List goals = new List(){ - new Goal( + new ComparativeGoal( name: "Goal1", desiredState: new() { { "i", new ComparisonValuePair { @@ -48,7 +48,8 @@ public void MinimalExampleText() agent.Step(StepMode.OneAction); Assert.Equal(10, agent.State["i"]); - + agent.Step(StepMode.OneAction); + Assert.Equal(20, agent.State["i"]); } } }