Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ArithmeticPostconditionsTests.cs #18

Merged
merged 2 commits into from
Dec 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]);
}
}
}
Loading