Broken Reality 2000 - AI Programming

Broken Reality 2000 - AI Programming

I developed a modular state machine and probability based reaction system for NPCs in Broken Reality 2000. Using context triggers, NPCs react dynamically to player actions: wandering, talking, or shifting into emotional states like anger or fear, bringing humor and life to Broken Reality's world.

I developed a modular state machine and probability based reaction system for NPCs in Broken Reality 2000. Using context triggers, NPCs react dynamically to player actions: wandering, talking, or shifting into emotional states like anger or fear, bringing humor and life to Broken Reality's world.

Category

Category

Unity · C# · GitHub

Unity · C# · GitHub

Role

Role

AI Programmer

AI Programmer

Studio

Studio

Dynamic Media Triad

Dynamic Media Triad

Duration

Duration

1 Year

1 Year

The Challenge

Design expressive NPCs that react differently to player behavior in a Y2K, humor-driven world. The AI had to feel dynamic and unpredictable without relying on complex behavior trees or heavy computation.

What I Built

  • Built a modular AI system using state machines to manage dynamic NPC behaviors

  • Developed reusable State classes to simplify logic and extend functionality

  • Implemented a probability-weighted decision system to simulate emotional reactions to player interactions

  • Designed contextual NPC responses for various triggers (e.g., taking photos, using weapons)

  • Ensured maintainable and scalable AI architecture aligned with the game’s surreal tone

My Technical Contributions

1. State Machine Architecture

Problem:
Create a flexible system to manage multiple NPC behavior states without duplicating logic or hardcoding transitions.

Solution:
Implemented a base State class and assigned each NPC a current state. Each state handles its own logic, making behaviors easily extendable.

// NPC Properties
[SerializeField] protected NavMeshAgent navMeshAgent;
[SerializeField] protected TMP_Text dialogText;
[SerializeField] protected List<string> dialogs = new List<string>();
protected State currentState;

private void Start() {
    // Set default state to IDLE
    SetState(new IDLE_State(this));
}

private void Update() {
    currentState.Update();
}

public void SetState(State state) {
    if (currentState != null) {
        // Get out of the current state
        currentState.OnStateExit();
    }
    // Replace current state with new state
    currentState = state;
    if (currentState != null) {
        // Initialize new state
        currentState.OnStateEnter

Result:

Enabled a clean, modular AI system where behaviors like idle, scared, angry, or impressed could be easily added and maintained.

2. Idle State Implementation

Problem:
NPCs needed to simulate life when idle by wandering and occasionally speaking, helping the world feel alive even without player interaction.

Solution:
Programmed an IDLE_State that moves NPCs to random points on a timer and triggers random dialog lines every few seconds.

// Wander around logic
if (canMove == true) {
  // Pick a random point in a certain range.
  randX = Random.Range(newPointRadiusMin, newPointRadiusMax);
  randZ = Random.Range(newPointRadiusMin, newPointRadiusMax);
  // Use the walk method to move the NPC to the randomly selected point.
  npc.Walk(new Vector3(randX, 0, randZ));
  canMove = false;
} else {
  /* Randomly choose between 5 and 20 seconds to wait between
      each wander.
  */
  timeToWait = Random.Range(walkWaitTimeMin, walkWaitTimeMax);
  if(time > elapsedTime) {
    elapsedTime = time + timeToWait;
    canMove = true;
  }
}
// Talk every n seconds
if (time > actionTime) {
  actionTime += talkRate;
  npc.Talk

Result:
NPCs now display lively, naturalistic idle behaviors that fill the game world with charm and unpredictability.

3. Probability-Based State Switching

Problem:
Make NPCs react differently depending on what the player does, and ensure reactions feel unpredictable but intentional.

Solution:
Created a probability-weighted selection system that assigns each possible reaction a range of chances. On trigger, the system randomly selects a new behavior based on those weights.

/*
This method recieves an n number of states with their probability range of being
selected, then when a new state is selected it replaces the old state for the NPC.
*/
private void SelectStateRandomly(params (State, (int,int))[] states) {
    /*
    Picks a number from 0 to 100 to randomly choose a state.
    Each state has its own probability range.
    */
    int rand = Random.Range(0, 100);
    for (int i = 0; i < states.Length; i++) {
        if (rand >= states[i].Item2.Item1 && rand <= states[i].Item2.Item2) {
            // Assigns the state from the array of states
            npc.SetState(states[i].Item1

Result:
NPCs now respond with a wide variety of emotional states (scared, angry, silly, etc.) based on interaction context — making each encounter feel unique and reactive.

Results & Impact

  • Delivered a system that supports 10+ unique NPC behaviors with clean, reusable code

  • Achieved dynamic emotional responses that aligned with the game’s surreal tone

  • Created a more immersive and humorous world by making NPC reactions context-sensitive and unpredictable

What I Learned

  • Modular AI design: Building a state machine system taught me how to architect flexible, reusable logic for characters with multiple behaviors.

  • Balancing unpredictability with control: Using weighted randomness gave me insight into how to simulate emotion and variation without sacrificing player clarity.

  • Readable systems matter: By separating responsibilities across states and selectors, I created maintainable AI logic that other team members could easily understand.

  • Player expression through NPCs: Designing reactions to player input reinforced how AI behavior can shape game tone, humor, and emotional response.

Key Technologies & Patterns Demonstrated

  • AI Architecture: Finite state machines with modular state classes for behavior control

  • Design Patterns: State pattern, Weighted probability systems, Modular component design

  • Procedural Systems: Random point navigation, Probability-based decision making

  • Game Feel: Context-sensitive reactions, Dynamic emotional state transitions

  • Performance: Lightweight AI without behavior trees, Timer-based update cycles

Create a free website with Framer, the website builder loved by startups, designers and agencies.