Game AI

CS380 Game AI.

Projects and assignments for CS380 Artificial Intelligence for Games class.

Realistic Enemy AI in Stealth Games (Final Project)

This research paper explored how to create intelligent enemy behavior in stealth games that feels natural and challenging. Rather than having enemies mindlessly chase the player, we developed systems where groups of enemies coordinate with each other, avoid congestion, and make strategic decisions about cover positions.

Group Behaviors and Flocking

We implemented a refined version of Craig Reynolds' Boid model, which gives each enemy agent three simple steering rules: alignment (move in the same direction as nearby allies), cohesion (stay close to the group), and separation (avoid colliding with others). To make the movement more realistic and less chaotic, we added obstacle avoidance, inertia stabilization, and force limiting. We also created a hierarchy system where a leader agent handles pathfinding for the entire group while followers use simpler math to stay in formation. This approach dramatically reduced computational cost while maintaining believable group movement.

Congestion Maps and Flow Fields

When many enemies try to reach the same location, they often get stuck in traffic. Congestion maps solve this by tracking where crowds are dense and steering agents toward less crowded paths. Flow fields take this further by precomputing the optimal direction for every cell on the map, so hundreds of enemies can follow navigation vectors instantly without each calculating their own path. This makes large-scale enemy encounters performant while keeping movement realistic and spread out.

Optimal Cover Placement

Level designers need to balance intense chase moments with safe recovery moments for players. We created an algorithm that analyzes the entire map to find the best cover locations. It considers factors like proximity to walls (openness), where enemies tend to cluster (congestion), and how many enemy sight lines reach each spot (visibility). The algorithm produces a heatmap showing the safest positions on the map. This helps designers understand pacing and strategically place cover to keep gameplay engaging rather than frustrating.

Game AI Maps showing congestion and flow fields

A* Pathfinding

Implementation of the A* algorithm for efficient pathfinding in game environments. A* combines the benefits of Dijkstra's algorithm with heuristic-based search to find optimal paths while exploring fewer nodes than uninformed algorithms.

Behavior Trees

We studied and implemented behavior trees, a hierarchical system for organizing AI decision-making. Behavior trees use composites (sequence and selector nodes), tasks (actions and conditions), and decorators (modifiers that change execution). We built a small demo where agents could patrol, hunt, retreat, and react to threats based on a tree structure that was easy to visualize and debug compared to traditional state machines.