Skip to content

Commit

Permalink
Merge pull request #18 from JanWerder/main
Browse files Browse the repository at this point in the history
Added ArithmeticPostconditionsTests.cs
  • Loading branch information
caesuric authored Dec 16, 2023
2 parents a9f9b68 + 7b8c735 commit 849d4d4
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions MountainGoapTest/ArithmeticPostconditionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MountainGoapTest
{
public class ArithmeticPostconditionsTests
{
[Fact]
public void MinimalExampleTest()
{

List<BaseGoal> goals = new List<BaseGoal>(){
new ComparativeGoal(
name: "Goal1",
desiredState: new() {
{ "i", new ComparisonValuePair {
Value = 100,
Operator = ComparisonOperator.GreaterThan
} }
},
weight: 1f
),
};

List<MountainGoap.Action> actions = new List<MountainGoap.Action>(){
new MountainGoap.Action(
name: "Action1",
executor: (Agent agent, MountainGoap.Action action) => {
return ExecutionStatus.Succeeded;
},
arithmeticPostconditions: new Dictionary<string, object> {
{ "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"]);
agent.Step(StepMode.OneAction);
Assert.Equal(20, agent.State["i"]);
}
}
}

0 comments on commit 849d4d4

Please sign in to comment.