You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changed any Goap* to ReGoap* to keep naming style.
Changed every ReGoap class to use generics so we are not bound anymore to <string, object> states, but anything can be used.
Using Vector3? instead of Vector3 in the Unity example.
Related to #13
This commit breaks every implementation.
Copy file name to clipboardexpand all lines: README.md
+29-27
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,9 @@ This library is very generic, if you don't include the Unity folder you can use
7
7
2.[Get Started, long version](#get-started-long-version)
8
8
1.[Explaining GOAP](#explaining-goap)
9
9
2.[How to use ReGoap in Unity3D](#how-to-use-regoap-in-unity3d)
10
-
1.[How to implement your own GoapAction](#how-to-implement-your-own-goapaction)
11
-
2.[How to implement your own GoapGoal](#how-to-implement-your-own-goapgoal)
12
-
3.[How to implement your own GoapSensor](#how-to-implement-your-own-goapsensor)
10
+
1.[How to implement your own ReGoapAction](#how-to-implement-your-own-regoapaction)
11
+
2.[How to implement your own ReGoapGoal](#how-to-implement-your-own-regoapgoal)
12
+
3.[How to implement your own ReGoapSensor](#how-to-implement-your-own-regoapsensor)
13
13
3.[Debugging](#debugging)
14
14
4.[Pull Requests](#pull-requests)
15
15
@@ -65,7 +65,7 @@ Examples:
65
65
66
66
*IMPORTANT*: false preconditions are NOT supported
67
67
*IMPORTANT*: the action effects aren't written in the memory when the action is done, this is a wanted behaviour because in most of the games you will want to set these variables from the memory or from the sensors.
68
-
If you want you can override Exit in your GoapAction and set the effects to the memory, example following.
68
+
If you want you can override Exit in your ReGoapAction and set the effects to the memory, example following.
69
69
70
70
71
71
#### Goal
@@ -97,49 +97,51 @@ Command line:
97
97
git clone https://github.com/luxkun/ReGoap.git
98
98
```
99
99
2. Create a GameObject for your Agent
100
-
3. Add a GoapAgent component, choose a name (it is advised to create your own class that inherit GoapAgent, or implements IReGoapAgent)
101
-
4. Add a GoapMemory component, choose a name (it is advised to create your own class that inherit GoapMemory, or implements IReGoapMemory)
102
-
5.[optional | repeat as needed] Add your own sensor class that inherit GoapSensor or implements IReGoapSensor
103
-
6.[repeat as needed] Add your own class that inherit GoapAction or implements IReGoapAction (choose wisely what preconditions and effects should this action have) and implement the action logic by overriding the Run function, this function will be called by the GoapAgent.
104
-
7.[repeat as needed] Add your own class that inherit GoapGoal or implements IReGoapGoal (choose wisely what goal state the goal has)
105
-
8. Add ONE GoapPlannerManager to any GameObject (not the agent!), this will handle all the planning in multiple-threads.
100
+
3. Add a ReGoapAgent component, choose a name (you must create your own class that inherit ReGoapAgent, or implements IReGoapAgent)
101
+
4. Add a ReGoapMemory component, choose a name (you must create your own class that inherit ReGoapMemory, or implements IReGoapMemory)
102
+
5.[optional | repeat as needed] Add your own sensor class that inherit ReGoapSensor or implements IReGoapSensor
103
+
6.[repeat as needed] Add your own class that inherit ReGoapAction or implements IReGoapAction (choose wisely what preconditions and effects should this action have) and implement the action logic by overriding the Run function, this function will be called by the ReGoapAgent.
104
+
7.[repeat as needed] Add your own class that inherit ReGoapGoal or implements IReGoapGoal (choose wisely what goal state the goal has)
105
+
8. Add ONE ReGoapPlannerManager (you must create your own class that inherit ReGoapPlannerManager) to any GameObject (not the agent!), this will handle all the planning.
106
106
9. Play the game :-)
107
107
108
108
What's more? nothing really, the library will handle all the planning, choose the actions to complete a goal and run the first one until it's done, then the second one and so on, all you need to do is implement your own actions and goals.
109
109
110
110
In the next paragraphs I'll explain how to create your own classes (but for most of behaviours all you need to implement is GoapAction and GoapGoal).
111
111
112
-
#### How to implement your own GoapAction
112
+
#### How to implement your own ReGoapAction
113
113
Check out the actions in this example: https://github.com/luxkun/ReGoap/tree/master/ReGoap/Unity/FSMExample/Actions
114
114
115
-
Check out GoapAction implementation, to see what functions you can override: https://github.com/luxkun/ReGoap/blob/master/ReGoap/Unity/GoapAction.cs
115
+
Check out ReGoapAction implementation, to see what functions you can override: https://github.com/luxkun/ReGoap/blob/master/ReGoap/Unity/ReGoapAction.cs
116
116
117
-
You can also implement your own GoapAction by implementing IReGoapAction interface, not advised except you know what you are doing!
117
+
You must implement your own ReGoapAction by implementing IReGoapAction interface or inheriting ReGoapAction.
118
+
Choose wisely the generic types, they must be the same across all the classes of the agent.
119
+
Usually string, object is the most generic, also int/enum, object is as well generic but lighter.
118
120
119
121
For a simple implementation all you have to do is this:
// when done, in this function or outside this function, call the done or fail callback, automatically saved to doneCallback and failCallback by GoapAction
134
-
doneCallback(this); // this will tell the GoapAgent that the action is succerfully done and go ahead in the action plan
135
-
// if the action has failed then run failCallback(this), the GoapAgent will automatically invalidate the whole plan and ask the GoapPlannerManager to create a new plan
135
+
// when done, in this function or outside this function, call the done or fail callback, automatically saved to doneCallback and failCallback by ReGoapAction
136
+
doneCallback(this); // this will tell the ReGoapAgent that the action is succerfully done and go ahead in the action plan
137
+
// if the action has failed then run failCallback(this), the ReGoapAgent will automatically invalidate the whole plan and ask the ReGoapPlannerManager to create a new plan
136
138
}
137
139
}
138
140
```
139
141
140
-
As written before the GoapAction does not, by default, write the effects on the memory, but the memory should check out if the effects are effectively done, if for any reason you want to set the effects at the end of the action you can add this code to your GoapAction implementation:
142
+
As written before the ReGoapAction does not, by default, write the effects on the memory, but the memory should check out if the effects are effectively done, if for any reason you want to set the effects at the end of the action you can add this code to your ReGoapAction implementation:
This is less tricky, most of the goal will only override the Awake function to add your own goal state (objectives).
160
162
161
-
Anyway check out GoapGoal, like everything you can implement your own class from scratch by implementing IReGoapGoal interface: https://github.com/luxkun/ReGoap/blob/master/ReGoap/Unity/GoapGoal.cs
163
+
Anyway check out ReGoapGoal, like everything you have to implement your own class from scratch by implementing IReGoapGoal interface or inheriting ReGoapGoal: https://github.com/luxkun/ReGoap/blob/master/ReGoap/Unity/ReGoapGoal.cs
162
164
163
165
Also check out the goals in this example: https://github.com/luxkun/ReGoap/tree/master/ReGoap/Unity/FSMExample/Goals
0 commit comments