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

Reproducing a minimal example with arithmeticPostconditions #17

Closed
JanWerder opened this issue Dec 13, 2023 · 6 comments
Closed

Reproducing a minimal example with arithmeticPostconditions #17

JanWerder opened this issue Dec 13, 2023 · 6 comments

Comments

@JanWerder
Copy link
Contributor

JanWerder commented Dec 13, 2023

Hi,
I'm trying a minimal example with the arithmeticPostconditions, but I'm getting an infinite loop.

_ = new AgentLogger(false, "npc.log");

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

this.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
),
};

this.agent = new Agent(
    goals: this.goals,
    actions: this.actions,
    state: new() {
        { "i", 0 }
    }
);

Afterwards I'm executing the Step function once, but viewing the log I can see an infinite loop.

2023-12-13 21:19:23.174 +01:00 [INF] Agent Agent a37d195d-ddf0-43ee-b5f5-2ce034fabe8a is working.
2023-12-13 21:19:23.201 +01:00 [INF] Agent Agent a37d195d-ddf0-43ee-b5f5-2ce034fabe8a started planning.
2023-12-13 21:19:23.211 +01:00 [INF] Evaluating node Action1 with 0 nodes leading to it.
2023-12-13 21:19:23.212 +01:00 [INF] Evaluating node Action1 with 1 nodes leading to it.
2023-12-13 21:19:23.212 +01:00 [INF] Evaluating node Action1 with 2 nodes leading to it.
2023-12-13 21:19:23.212 +01:00 [INF] Evaluating node Action1 with 3 nodes leading to it.
2023-12-13 21:19:23.212 +01:00 [INF] Evaluating node Action1 with 4 nodes leading to it.
2023-12-13 21:19:23.212 +01:00 [INF] Evaluating node Action1 with 5 nodes leading to it.
2023-12-13 21:19:23.212 +01:00 [INF] Evaluating node Action1 with 6 nodes leading to it.
2023-12-13 21:19:23.212 +01:00 [INF] Evaluating node Action1 with 7 nodes leading to it.
2023-12-13 21:19:23.212 +01:00 [INF] Evaluating node Action1 with 8 nodes leading to it.
2023-12-13 21:19:23.213 +01:00 [INF] Evaluating node Action1 with 9 nodes leading to it.
2023-12-13 21:19:23.213 +01:00 [INF] Evaluating node Action1 with 10 nodes leading to it.
2023-12-13 21:19:23.213 +01:00 [INF] Evaluating node Action1 with 11 nodes leading to it.
2023-12-13 21:19:23.213 +01:00 [INF] Evaluating node Action1 with 12 nodes leading to it.
2023-12-13 21:19:23.213 +01:00 [INF] Evaluating node Action1 with 13 nodes leading to it.
[...]

I'm most likely missing something, can you give me a hint?

@caesuric
Copy link
Owner

Let me try to reproduce, and I'll get back to you soon. 😄

@JanWerder
Copy link
Contributor Author

I recreated my example as a test for convenience. You can see it in the #18 where it shows the same behaviour.

@JanWerder
Copy link
Contributor Author

I was using the Goal instead of the ComparativeGoal, which was the cause for the error. When you use the ComparativeGoal it works as it should. I've added that to the test in the pull request as well.

@caesuric
Copy link
Owner

I'm so glad to hear this works properly! I was confused as I'm pretty sure I have a test for that. I'll look at your PR and get that test added in. 😄

@caesuric
Copy link
Owner

caesuric commented Dec 16, 2023

And yes, the regular goals are just relatively simple equality checks. Should I make that more clear in my documentation, or was it just a typo in this case?

@JanWerder
Copy link
Contributor Author

I think an additional sentence in the documentation would be good. I'll send a pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants