SpoutDev/SpoutAPI — pull request #482 by fullwall (2012-12-29 08:58:45+00:00)
Title: AI framework

This is a rough implementation of the GOAP framework from F.E.A.R 1 in Java (see: http://web.media.mit.edu/~jorkin/goap.html) taken from a personal project. It is not perfect, obviously, and a lot of it has been directly lifted from my project so any design changes are welcome.

To summarise the GOAP approach briefly: AI is made up of a series of Actions and Goals. These operate on a key-value mapping representing the world state with support for additional runtime checking. A goal is a key-value mapping of the desired world state; Actions modify the world state via preconditions and effects. A* is used to map through this graph and develop a plan.

This system has the advantage that plans are dynamic; replanning can be done based on new discovered facts and dynamic/non-explicit approaches to the goal taken. Disadvantages: key-value store can take up memory, potential performance issues with A* although it is done on a small scale and can be threaded.

GOAP is not the only way to approach the AI; I am open to implementing behavior trees as an alternative if need be. Comments welcome.