Play Turn

Skip Turn

Restart Game


Humans

Loading...
Loading...

Zombies

Loading...

Influence Maps




How It Works

This page uses a utility AI to manage a group of selfish humans who "cooperate" in battles against hordes of zombies. It's inspired by Zombie Panic.

Utility AI, where NPCs consider their own needs, produces agents that show an awareness of their environments and act autonomously, without the need for brittle scripting. The approach is tried and tested, and has worked in various commercial games, such as The Sims, Iron Man and Red Dead Redemption.

This implementation has the following design: AI agents have Brains. Brains are top-level decision makers that tell agents what they should try to do. Brains contain Reasoners, which encapsulate logic for assessing the suitability of sets of game actions. Reasoners contain ActionSets, groups of actions. ActionSets consist of Actions, identifiers for actual activities an agent can perform in the game. Actions (also known as Options) contain Considerations, aspects that an agent must assess to decide whether to perform a game action. Finally, each Consideration (also known as an Axis) references an Input, a measurable aspect of the game world, and a technique for considering (evaluating) the Input.

When it is time to update the AI, an agent thinks using their Brain(s) to evaluate the current situation in the game world. The best scoring actions are chosen using a strategy encapsulated by the Reasoners and ActionSets within the Brains, with individual Actions being evaluated by scoring their associated Considerations. At this point the Actions are merely conceptual, so as the agent's Brains select new actions, a set of Intents are updated based on this. The presence of specific Intents activates or deactivates Actualizers, which are responsible for making the Intents of the agents concrete i.e. actualizing agent intentions.

A single agent can have more than one Brain. This is for handling separate sets of Actions that can be performed in parallel, such as walking and talking. In this demo, humans have one Brain for chattering with fellow survivors and taunting zombies, and another for core behaviours, such as handling weapons or fleeing from zombies.

Needs based AI requires careful balancing to produce the behaviours you want. For example, a human who has to decide whether to flee the undead has a Consideration based on the number of zombies in the vicinity, but how the Brain processes that information depends on where other survivors are, and how cowardly the survivor in question is.

Another area of interest is making Inputs (a view of some information in the world) available in an efficient way. To do this, you often need to provide generalized distances between objects, influence maps, elapsed times and other attributes. Scalability is easy to handle - you can perform triggered updates, make agents only use their Brains every so often, disallow Actions that take a lot of work to consider, or even tell agents to think less often when processing power is in short supply.

This utility AI demo was written using Haxe. For developers, there is a list of articles and useful references in the code repository readme. If you have any suggestions, requests or comments then contact me or open an issue.