Library/Artificial Intelligence/Wander

A simple form of artificial intelligence is a Wanderer. A good example would be a sheep. A Wanderer is an entity that essentially dim-wittedly and with minimal reaction to the environment and very little planning goes from place to place looking for something. For example, a sheep looking for food.

The artificial intelligence can be described in two states:
 * Plan
 * Move

The Plan state in this case is very simple. It chooses a random location within a certain radius of the current location.

The Move state continues until the entity is in the location chosen in the Plan state. When the location is reached, the entity returns to the Plan state.

This is the basic Wanderer pattern. It can easily be used as a basis for slightly more intelligent entities. For example, adding more logic to the Plan state can easily enhance the seeming intelligence of the entity: e.g. have the sheep entity search out the area that seems to have the most grass but is not near other entities.