Game AI / Game AI

Game AI Systems

Behavior trees, flocking and steering, squad formations, and procedural generation — agents built to read as deliberate.

01/05Flock steering with "Pariah" agents

A collection of agent and generation systems built in Unity: specialized behavior trees for support roles, emergent flocking with disruptive "Pariah" agents, close-quarters squad formations, and BSP-based procedural map generation.

Engineering highlights

Hover to preview · click to pin

Boid.cs

Vector3 Steer()
{
    var v = Cohesion()  * wCoh
          + Align()     * wAli
          + Separate()  * wSep;

    foreach (var p in pariahs)
        v += Repel(p) * wPariah;

    return v.normalized;
}

Demo

Agents that support rather than attack

Most enemy AI is built to close distance and deal damage. The Shield and the Medic are interesting precisely because they aren’t — their goals are defined relative to their allies, which means their decision-making depends on state they don’t directly control.

The Shield selects a protectee by priority value and positions itself between that ally and the threat. The Medic looks for downed allies to revive, and has to answer the awkward question of what a support unit does when there is nothing to support — it idles, and escalates to attacking the player when the situation collapses.

Both use behavior trees rather than finite state machines. With a handful of states an FSM is simpler, but the transition count grows quadratically and support roles have a lot of conditions. Behavior trees keep that legible.

Emergence from local rules

The flocking work is a steering proof-of-concept built around Pariahs — independent agents that don’t follow the flock and actively influence it. Standard boids produce cohesive but monotonous motion. Introducing agents with contrary goals generates disruption that looks authored without being scripted.

The close-quarters formation work is the same idea under tighter constraints: in a corridor, naive flocking collapses into a clump, so the squad needs explicit formation behaviors — standard spacing and single-file — to stay coherent.

Generating the space they move through

Map generation uses BSP to recursively partition the level and connect the resulting rooms, with a follow-up pass that fills leftover space and scales enemy spawns to room size. An earlier iteration paired BSP with cellular automata to get the eroded, irregular feel of an abandoned prison — useful for showing how much the same partitioning skeleton can change under a different fill strategy.