-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
I am running the examples with a scenario of updating the goals at runtime, and it seems once the agent is created with goals they can't be updated.
here is an example
_ = new DefaultLogger(true);
var goal = new ComparativeGoal(
name: "Travel 50 miles",
desiredState: new() {
{
"distanceTraveled", new() {
Operator = ComparisonOperator.GreaterThanOrEquals,
Value = 50
}
}
});
var walkAction = new Action(
name: "Walk",
cost: 50,
postconditions: new() {
{ "distanceTraveled", 50 }
},
executor: TravelExecutor
);
var driveAction = new Action(
name: "Drive",
cost: 5,
preconditions: new() {
{ "inCar", true }
},
postconditions: new() {
{ "distanceTraveled", 50 }
},
executor: TravelExecutor
);
var getInCarAction = new Action(
name: "Get in Car",
cost: 1,
preconditions: new() {
{ "inCar", false }
},
postconditions: new() {
{ "inCar", true }
},
executor: GetInCarExecutor
);
var agent = new Agent(
name: "Driving Agent",
state: new() {
{ "distanceTraveled", 0 },
{ "inCar", false }
}
);
agent.Goals.Add(goal);
agent.Actions.Add(walkAction);
agent.Actions.Add(driveAction);
agent.Actions.Add(getInCarAction);
agent.Step(StepMode.OneAction);
agent.Step(StepMode.OneAction);
agent.Step(StepMode.OneAction);
var newGoal = new ComparativeGoal(
name: "Travel 60 miless",
desiredState: new() {
{
"distanceTraveled", new() {
Operator = ComparisonOperator.GreaterThanOrEquals,
Value = 60
}
}
});
agent.Goals.Clear();
agent.Goals.Add(newGoal);
agent.Step(StepMode.OneAction);
agent.Step(StepMode.OneAction);
agent.Step(StepMode.OneAction);
It throws
:0 @ void System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Array , IntPtr , System.Object ): System.IndexOutOfRangeException: Index was outside the bounds of the array.
<C++ Error> System.IndexOutOfRangeException
<C++ Source> :0 @ void System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Array , IntPtr , System.Object )
<Stack Trace> :0 @ void System.Runtime.CompilerServices.CastHelpers.StelemRef(System.Array , IntPtr , System.Object )
:0 @ MountainGoap.ActionAStar..ctor(MountainGoap.ActionGraph , MountainGoap.ActionNode , MountainGoap.BaseGoal , Single , Int32 )
Metadata
Metadata
Assignees
Labels
No labels