Back to portfolio
simulation2025

Zombie Simulation

Agent-based zombie outbreak simulation with emergent horde behavior on HTML Canvas

TypeScriptHTML5 CanvasViteWeb Audio API
Personal Project
2025
Zombie Simulation

Overview

A 2D agent-based zombie outbreak simulation on HTML Canvas. Watch Patient Zero spark a slow infection that tips into full apocalypse as emergent hordes form, survivors flee, and buildings become death traps. 300 humans face off against evolving zombie variants — Shamblers, Runners, and Tanks — across a dynamic day/night cycle.

Challenge

Creating believable emergent behavior from simple rules is the core challenge. Each agent needs to respond to its local environment — fleeing zombies, seeking shelter, forming groups — while the overall simulation produces dramatic, unpredictable outbreak narratives. Performance matters: hundreds of agents with steering forces, spatial lookups, and collision detection must run smoothly at variable speeds.

Solution

Built with vanilla TypeScript and HTML Canvas — no frameworks, no game engines. Agents use weighted steering forces (flee, seek, wander, cohesion, separation) with a spatial grid for fast neighbor lookups. Three zombie variants create varied threat dynamics: slow Shamblers form the backbone of hordes, fast Runners create sudden pressure, and large Tanks block escape routes. A day/night cycle shifts every 30 seconds, boosting zombie speed at night and adding atmospheric tension.

Results

The simulation produces compelling emergent narratives — buildings that seem safe become death traps, survivors cluster then scatter, and the infection curve tips from manageable to apocalyptic in seconds. The sparkline population tracker and heatmap overlay give players real-time insight into the outbreak dynamics.

Key Features

01Agent-based simulation with weighted steering forces (flee, seek, wander, cohesion, separation)
02Three zombie variants: Shamblers (60%), Runners (25%), and Tanks (15%)
03Day/night cycle with zombie speed boost and atmospheric changes
04Infection mechanic with visible pulsating orange-to-red transition
05Spatial grid for performant neighbor lookups across hundreds of agents
06Interactive controls: click to drop zombies, pause/resume, heatmap toggle
07Population sparkline tracking outbreak progression over time
08Zombie density heatmap overlay
09Adjustable simulation speed (0.25x — 3x)

Gallery

Zombie Simulation — EXTINCTION state with full zombie takeover