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.
ph1387 / JavaGOAP Public
An implementation of the Goal Oriented Action Planning (GOAP) AI-system in Java.
Notifications You must be signed in to change notification settings
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Go to fileAn implementation of the Goal Oriented Action Planning (GOAP) AI-system in Java. Creator: P H, ph1387@t-online.de
The GoapAgent, GoapAction and the GoapState require you to directly extend / use them, whereas the rest of the classes can be swapped as desired. After creating the Agent and assigning a Unit the update() function of it has to be called continuously in order for it to function. The GoapUnit can be implemented as desired. Either subclasses with additional functionalities like immediately changing to a GoalState or with the given Interface (IGoapUnit) and only the bare bone functions.
A GoapAgent is defined by it surrounding (WorldState) and by the goal that it is trying to achieve (GoalState). Certain actions with preconditions and effects (GoapActions) can be taken to get to a / the GoalState(s). Each action taken influences the current WorldState and therefore the possible actions taken after it. I.e. the goal of eating a cookie requires the Unit to have a cookie in its hands (precondition) therefore queuing a action taking a cookie in its hand (effect) before it:
WorldState: CookieInHand = false GoalState: EatingCookie = true AvailableActions: TakeCookieInHand - precondition: CookieInHand = false - effect: CookieInHand = true EatCookie - precondition: CookieInHand = true - effect: EatingCookie = true - effect: CookieInHand = false Sequence: TakeCookieInHand -> EatCookie
Different actions can have multiple effect and preconditions that must be matched in order to fulfill set goals. If the most important one can not be met by a sequence of GoapActions, then the next one is tried until either a goal can be reached or none remains. If more than one possible way are found the one with the lesser cost is chosen.