3.8 GOAP Design
All of Orkin’s previous articles relating to GOAP indicate that within a planning system each GOAP agent should maintain a world state which is a collection of world state symbols that relate to the virtual world.
3.8.1 World state
Each agent maintains a world state which is basically a fixed-size array of world state symbols. Following on from Orkin’s advice (Orkin, 2004), each world state symbol is a key- value pair and includes a name, type and overloaded operators to allow for testing against other symbols and for setting values of the symbols. Figure 1 illustrates a simple world state for an agent with three Boolean world state symbols, weaponLoaded, isTargetDead and inMeleeRange. It was determined from designing the actions and goals that the GOAP agent required eight core world state symbols for this project: targetIsDead, covering, weaponLoaded, atTargetNode, atDomPointOne, atDomPointTwo, inMeleeRange and inTargetSights.
A world state doesn’t require all the symbols to be set. For example, the Reload action in figure 1 has a precondition world state with just the symbol weaponLoaded set to true for its effect, all other symbols are unset as they are not relevant or needed. The world state class provides methods to evaluate one world state against another, find out how many world state symbols are different (i.e. test each symbol against every other symbol regardless if the symbol has been set or not) and check how many symbols are unsatisfied (i.e. how many symbols that are set in each world state are different). This functionality was required for the planning process as different world states are often tested against one another. Also a means of getting,