luxkun / ReGoap

Generic C# GOAP (Goal Oriented Action Planning) library with Unity3d examples
Apache License 2.0
1.03k stars 147 forks source link

Some question about multiple goals #18

Closed Papitoh closed 7 years ago

Papitoh commented 7 years ago

Hello. I am using ReGoap and Im wish to thank you for this work! But there are some strange thing for me. When i add multiple goals(simpleones: "go to marker" and "shoot at enemy" for example), planner choose top priority goal and agent execute it. But after planer still try to execute same goal by running 0 actions plan. There are some issue? Or i should procedurally change goals priorietes when some goal achieved? Thanks regoapconsole

Papitoh commented 7 years ago

By the way this can be fixed by adding

if (path.Count == 0) { continue; }

in

Planner:Plan(...) { while (possibleGoals.Count > 0) { .... if (path.Count == 0) { continue; } } }

Papitoh commented 7 years ago

But a more effective way is to add a check for memory of agent containing goal state at the stage of forming list of possible goals , like:

foreach (var pair in goalValues) { W worldValue; worldValues.TryGetValue(pair.Key, out worldValue); var goalValue = pair.Value; if (worldValue == null || !Equals(worldValue, goalValue)) isGoalSatisfied = false; } ...

if (goal.IsGoalPossible() && !isGoalSatisfied) possibleGoals.Add(goal);

Is there a better way?

luxkun commented 7 years ago

I just added a check inside ReGoapPlanner.Plan, thank you for finding out!