luxkun / ReGoap

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

Bug in Node Expansion during AStar search? #21

Closed DigitalEd closed 7 years ago

DigitalEd commented 7 years ago

In ReGoapNode.cs, there seems to be a bug on line 149 in the Expand method. The line: !goal.HasAnyConflict(precond) seems to be an error.

Any action that has a precondition that's different than the goal will always be rejected. Consider the case where the goal GoSwimming requires { isAtPosition: 0} and a JumpIntoWater action with effect {isAtPosition: 0} and a precondition {isAtPosition: 1}. The action precondition will always be in conflict (as it should be) with the goal and therefore never be chosen for the expandList.

Bug? Or am I misunderstanding something?

----- Ed

luxkun commented 7 years ago

Not working a lot on this project right now, but you are right, let me know if this branch fixes your issue: https://github.com/luxkun/ReGoap/tree/conflicting-actions

DigitalEd commented 7 years ago

That seems to fix it