Doric column
David Pittman
HomePersonal ProjectsTeam ProjectsResume
Doric column

Stealth-Based Game AI

Stealth AI image



Quick facts:
Development time: 3 months
Engine: Original

For my first directed focus study at The Guildhall at SMU, I developed a finite state machine-based AI for a Thief-type stealth game. This manifested in a game demo in which a defenseless player must retrieve three pieces of treasure while avoiding capture by guards.

The AI had states based on its awareness of the player. At the start of the game, each AI would simply wander the map or stand idly. Distant noises or peripheral glimpses of the player would cause the guard to change to a marginally aware state. The guard would then search in the appropriate direction until he either found more evidence of the player (causing a state transition to full awareness) or found nothing and reverted to an unsuspicious state. Group behavior was implemented using a separate state. If an AI was at a lower awareness than another nearby AI, it would transition to the follow state and stick with the more aware AI.

I used my existing Quake BSP loader in this project and added an in-game tool to create, modify, save, and load waypoint graphs. I implemented A* pathfinding on this graph using a basic shortest distance heuristic. An AI would traverse the found path until a direct line to its target was available, then move directly towards it.

The sensory mechanisms of the AI utilized many existing components of my original engine. Hearing was modeled using the distance between the source and AI, multiplied by half if a ray test against the BSP failed (to simulate the muffling of sound by world geometry). This product was then quantized to provide discrete input to the AI. If it exceeded a low threshold, the AI heard the noise faintly and would become partially aware of the source if not already at an equal or higher awareness. If the result exceeded a higher threshold, the AI heard the noise clearly and became immediately aware of the source.

Visual testing could produce the same transitions in the AI as hearing, but was modeled with a more specific system. Each AI had four sight frustums (for front-near, front-far, left peripheral, and right peripheral). The player's location was tested for intersection against each frustum each frame. If the player was seen at a far distance or in the AI's peripheral vision, the AI would become partially aware of the player. If the player remained in one of these ranges for one second, the AI would become fully aware. Entering the AI's front-near frustum caused it to become fully aware immediately.

The demo I produced was a simple treasure hunting game. In it, a defenseless player must steal three pieces of loot while avoiding the guards. If the player is seen, he may run and hide and lose the guards' attention, but if a guard catches up to the player, the game is over. This game was one of four programmer directed focus studies selected by The Guildhall at SMU faculty to display at the Summer 2006 exhibition.



Stealth AI image Stealth AI image Stealth AI image