Examples

llms.txt

Select an example to explore it in the playground.

Beginner - Introductory Models

Fishery Simulation

A fishery simulation of stocks, flows, and feedback loops managing fish populations.

Level: Beginner

populationresource-managementsustainabilitymanagementecosystemstocks-flowsreinforcing-loopbalancing-looprenewable-resourcequota-policy

  • Stocks: population
  • Flows: births, quota
  • Feedback Loops: reproduction (reinforcing), quota (balancing)
  • Probes: population, quota, gap_to_capacity, extracted_total

Antifragile System

The same adaptive loop, two fates: with one knob negative each failure makes the system stronger; flip its sign and failures spiral to certain breakdown.

Level: Beginner

reinforcing-loopbalancing-loopreliabilityantifragility

  • Stocks: failure_rate, total_failures
  • Flows: failure
  • Feedback Loops: antifragile healing (balancing), fragile spiral (reinforcing)
  • Probes: failure_rate, total_failures

Bathtub Fill and Drain

Bathtub stock and flow simulation: water volume rises and falls with inflow and outflow. Change the rates and watch the stock respond.

Level: Beginner

stocks-flowscapacity

  • Stocks: water_volume
  • Flows: inflow, outflow
  • Probes: water_volume, inflow, outflow

Elementary Cellular Automata

Elementary cellular automata rule table for all 256 rules. See how each 8-neighbourhood maps to the next state, and try rules 30, 90, and 110.

Level: Beginner

cellular-automatagridcomputationchaos

  • Probes: ones, clusters, center_fraction

Gacha Box

Same 50 pulls, same spend, one setting apart: a pity timer guarantees the 1%-odds ultra after a dry streak, while turning it off can leave you empty-handed.

Level: Beginner

stochasticgamerandompity-timerprobability

  • Probes: count_common, count_rare, count_ultra, spent, draws_since_top

Game of Life

Conway's Game of Life: a random soup self-organizes into still-lifes, blinkers, and gliders — global order from one local rule.

Level: Beginner

cellular-automatagridemergenceself-organization

  • Probes: alive, changed

Goal-Seeking Decay

A goal-seeking decay simulation modeling exponential approach toward a target.

Level: Beginner

decaygoalbalancing-loopexponentialcontrolfirst-order-dynamicstime-delay

  • Stocks: level
  • Flows: approach_rate
  • Feedback Loops: goal-seeking (balancing)
  • Probes: level, approach_rate

Inventory Oscillation

Naive reordering that ignores in-transit stock makes inventory swing; counting the pipeline flattens it.

Level: Beginner

inventorydelaybullwhip

  • Stocks: inventory
  • Flows: demand, shipments
  • Feedback Loops: delayed reorder (balancing loop that overshoots)
  • Probes: inventory, pipeline

Logistic Growth

Grow a population too fast and it overshoots its carrying capacity before settling; grow it gently and it glides up to the same limit.

Level: Beginner

populationcapacityovershootnonlinear-dynamicsreinforcing-loop

  • Stocks: population
  • Flows: growth
  • Feedback Loops: reinforcing adoption, saturation constraint
  • Probes: population, growth

Nested Hierarchy Workflow

A nested hierarchy simulation where tasks flow across company departments.

Level: Beginner

workflowcapacityresource-managementthroughputbottleneck

  • Flows: arrivals, service
  • Probes: Dept0, Dept1, Dept0-Team0, Dept0-Team1, Dept1-Team0, Dept1-Team1

Queue Simulation

A single-server queue at the edge of overload: nudge utilization past 1 and the backlog diverges.

Level: Beginner

queuethroughputbottleneckdiscrete-eventservicecapacity

  • Stocks: backlog
  • Flows: arrivals, served
  • Probes: backlog, utilization, throughput

Savings vs Credit-Card Debt

Same card, same income - one number decides everything: pay just under the interest and the debt runs away; pay just over it and the balance marches to zero.

Level: Beginner

debtreinforcing-loopexponentialcompounding

  • Stocks: savings_balance, debt_balance
  • Flows: interest, deposit, payment
  • Feedback Loops: compound interest on savings (reinforcing), compound interest on debt (reinforcing)
  • Probes: savings_balance, debt_balance

Success to the Successful

Funding by last period's output turns a 5% productivity edge into a budget Gini of 0.84. Redistributing 30% of the pool holds that gap near 0.057.

Level: Beginner

reinforcing-loopbalancing-loopinequalitycompetitionresource-allocation

  • Stocks: budget_A, budget_B
  • Flows: allocation to A, allocation to B
  • Feedback Loops: performance allocation (reinforcing), equal floor (balancing)
  • Probes: budget_A, budget_B, output_A, output_B, gini_budget, gini_output

Thermostat Simulation

A bang-bang thermostat reading a delayed sensor overshoots and rings; shorten the delay and it settles.

Level: Beginner

controltime-delaybalancing-loop

  • Stocks: indoor_temp
  • Flows: heat_gain, heat_loss
  • Feedback Loops: controller chasing set-point (balancing)
  • Probes: indoor_temp, error, heater_on
Intermediate - Classic Dynamics

First-Price vs. Vickrey Auctions

Repeated sealed-bid auctions comparing first-price and Vickrey rules with learning agents.

Level: Intermediate

game-theoryauctionlearningincentivesimpy

  • Probes: revenue, allocative_efficiency, truthful_bidding

Bank Renege Simulation

Bank queue simulation of reneging: impatient customers leave before a line forms, while patient ones wait and nearly all get served.

Level: Intermediate

queueservicediscrete-eventreneging

  • Stocks: queue_length
  • Flows: served, reneged
  • Probes: wait_time, served, reneged, queue_length

Atmospheric CO₂ Bathtub

CO₂ rises while emissions exceed the sink: the same cut turns the bathtub around, but waiting until year 50 leaves a higher peak and a higher year-120 level.

Level: Intermediate

climatestocks-flowsbalancing-loopslow-drainpolicy

  • Stocks: atmospheric CO₂
  • Flows: emissions, removals
  • Feedback Loops: sink removal (balancing)
  • Probes: co2_atmos, emissions, removals, net_flow

Dynamic Difficulty Adjustment

Dynamic difficulty simulation that tracks win rate and adapts encounters so players stay challenged. See the feedback loop that tunes the challenge.

Level: Intermediate

gameplayreinforcing-loopbalancing-loopadaptivegame

  • Stocks: skill, difficulty, retention
  • Flows: practice gains, difficulty adaptation
  • Feedback Loops: skill improvement (reinforcing), challenge tuning (balancing)
  • Probes: skill, difficulty, win_rate, frustration, retention

Hospital ER Patient Flow

Hospital ER queue simulation of patient flow through an emergency department. See how arrival rate, treatment time, and capacity change the wait.

Level: Intermediate

queuehealthcareresource-managementprioritization

  • Stocks: beds
  • Flows: arrivals, departures
  • Feedback Loops: staffing effects
  • Probes: wait_low, wait_med, wait_high, bed_util, lwbs, served

Inspection Game

A ranger who patrols just 40% of sites can still stop poaching - but only if the penalty is harsh enough. Soften it and the same patrols let crime pay.

Level: Intermediate

game-theoryreinforcementmonitoringdeterrence

  • Feedback Loops: poacher adaptation (reinforcement)
  • Probes: catch_rate, ranger_coverage, poacher_payoff

Inventory–Workforce Oscillator

A hire delay swings seasonal backlog amplitude from 60 down to 7. Workforce turns 14 times in both: amplified seasonality, not an unforced oscillator.

Level: Intermediate

workforceseasonalitytime-delaycontrol

  • Stocks: workforce, backlog
  • Flows: hiring, layoffs, production, demand
  • Feedback Loops: staffing to this period's demand (balancing, lagged)
  • Probes: demand, workforce, backlog

Predator-Prey (Lotka–Volterra, SciPy)

Lotka-Volterra predator-prey simulation of oscillating populations. Change growth and predation rates and watch the classic cycle appear.

Level: Intermediate

populationecosystemnonlinear-dynamics

  • Stocks: prey, predator
  • Flows: prey_births, predations, predator_deaths
  • Feedback Loops: predation cycle
  • Probes: prey, predator

Predator-Prey (Lotka–Volterra, SimPy)

Lotka-Volterra predator-prey model in discrete-time SimPy. Compare this simulation with the continuous equations and see the same oscillation.

Level: Intermediate

populationecosystemnonlinear-dynamics

  • Stocks: prey, predator
  • Flows: prey_births, predations, predator_deaths
  • Feedback Loops: predation cycle
  • Probes: prey, predator

Matchmaking Queue

Simulates skill-based matchmaking with adjustable buckets, skill delta and max wait.

Level: Intermediate

matchmakingqueuegamefairness

  • Probes: queue_len, avg_wait, avg_delta

Token Bucket vs Leaky Bucket Rate Limiting

Rate limiting compared: a token bucket allows a burst then drops traffic, while a leaky bucket smooths the same burst into a steady queue.

Level: Intermediate

queuerate-limitingtoken-bucketleaky-bucketthrottlingtraffic-shapingburstdiscrete-event

  • Stocks: token credits, leaky-bucket queue
  • Flows: arrivals, token-bucket admissions, token-bucket drops, leaky-bucket drain
  • Feedback Loops: credits refill and gate admission (balancing), queue drains at a fixed rate until empty (balancing)
  • Probes: token_drops_total, token_credits, token_bucket_output, leaky_bucket_output

Ride-Share Surge Control

Dynamic pricing stabilises rider waits—until high gain and delay turn it into surge whiplash.

Level: Intermediate

queuepricingelasticitybalancing-loopdelayoscillation

  • Stocks: Riders Waiting, Idle Drivers, Drivers on Trip
  • Flows: Passenger Arrivals, Driver Logins, Matches, Trip Completions, Driver Logouts
  • Feedback Loops: Wait-driven surge (balancing), High-gain with delay (reinforcing oscillation)
  • Probes: price_multiplier, wait_estimate, riders_waiting, idle_drivers, arrival_rate, driver_logins, matches_per_min

Rumor vs Counterwave

Competing rumor and fact-check messages racing across a social network.

Level: Intermediate

competing-contagionsocial-networkrumorfact-check

  • Stocks: rumor, correction
  • Flows: transmissions
  • Probes: rumor, correction

SIR Model with Vaccination

An SIR epidemic at the threshold: vaccinating past the herd-immunity line pushes effective R0 below 1 and the outbreak fizzles.

Level: Intermediate

populationreinforcing-loopbalancing-loopcontrol

  • Stocks: susceptible, infected, recovered
  • Flows: infections, recoveries
  • Feedback Loops: disease spread (reinforcing), susceptible depletion / herd immunity (balancing)
  • Probes: susceptible, infected, recovered, r_eff

Sleep Debt Simulation

A sleep debt simulation tracking caffeine, sleep patterns, and debt buildup.

Level: Intermediate

debtreinforcing-loopbalancing-loop

  • Stocks: sleep_debt_hours
  • Feedback Loops: coffee reduces sleep (reinforcing), circadian pressure triggers sleep (balancing)
  • Probes: sleep_debt, subjective_energy

War of Attrition

Two-player waiting game exploring mixed strategies and the option value of waiting.

Level: Intermediate

game-theorywaiting-gamesimpy

  • Probes: contest_length, surplus, cost_variance

Water Heater PID Control

PID control keeps a domestic hot water tank near its setpoint while balancing heater power and losses.

Level: Intermediate

pid-controlthermostatenergybalancing-loophouseholdcontrol-systemstemperature

  • Stocks: water_temperature
  • Flows: heater_input, heat_loss
  • Feedback Loops: PID control (balancing)
  • Probes: temperature, heater_output, error, setpoint
Advanced - Complex Simulations

Beer Game: The Bullwhip Effect

A Beer Game simulation of the bullwhip effect: one demand step whips factory orders from a surge to zero unless each tier counts stock already in transit.

Level: Advanced

supply-chainbullwhipbeer-gamedelayinventoryoscillation

  • Stocks: Inventory (cases on hand, per tier), Backlog (unfilled orders, per tier), Supply line (cases on order, per tier)
  • Flows: Customer demand, Orders (upstream), Shipments (downstream), Production (factory batches)
  • Feedback Loops: Stock-correction (balancing): order more when net stock is below target, Supply-line correction (balancing): order less when the pipeline is already full — switched off when pipeline-blind, Demand-signal amplification (reinforcing): each tier forecasts off its neighbour's already-jittery orders
  • Probes: order_retailer, order_factory, inventory_retailer, inventory_factory

Car Service Simulation - SimPy Tutorial

A car service simulation showing priority washing with features like interrupts.

Level: Advanced

simpypriorityservicemaintenancequeueinterruptsdiscrete-eventreliabilityworkflow

  • Stocks: fuel_level, parts
  • Probes: fuel_level, wash_q, parts

Hawk-Dove Game: When Does Fighting Pay?

Hawk-Dove game simulation of when fighting pays. When a fight costs more than the prize, hawks and doves settle; cheapen the fight and conflict spreads.

Level: Advanced

game-theoryevolutionary-gamemixed-strategyequilibriumconflictcooperationreplicator-dynamicsreinforcing-loopbalancing-loop

  • Stocks: hawk population
  • Flows: switches to Hawk, switches to Dove
  • Feedback Loops: imitation of success (reinforcing), frequency-dependent payoff (balancing)
  • Probes: hawk_fraction, avg_payoff, conflict_cost, hawk_advantage

Logistic Map

A logistic map simulation that iterates x_{n+1}=r*x_n*(1-x_n) to illustrate chaos.

Level: Advanced

populationnonlinear-dynamics

  • Stocks: x
  • Feedback Loops: growth with self-limiting term
  • Probes: x

Machines Simulation

Machines simulation of resource allocation and reliability. See how breakdowns and repairs change throughput when capacity is shared.

Level: Advanced

reliabilityresource-managementmaintenancequeuethroughput

  • Stocks: buffer, idle-token store
  • Flows: in_rate, dispatch_rate
  • Probes: in_rate, dispatch_rate, buffer_level, breakdown, repair

Phantom Traffic Jam

Why a highway jams with no crash and no bottleneck: past a critical reaction time, one brake tap becomes a phantom stop-and-go wave that creeps backward.

Level: Advanced

trafficagent-basedemergencetime-delaycontrolbalancing-loop

  • Stocks: speed of each car, gap to the car ahead
  • Flows: acceleration, gap change
  • Feedback Loops: headway control (balancing), reaction delay (makes that loop overshoot)
  • Probes: speed_spread, slowest_car, min_gap

Prisoner's Dilemma: Noise, Tit-for-Tat, and Forgiveness

One accidental defection turns unforgiving tit-for-tat into a prisoner's dilemma revenge spiral. Forgive some of those slips and cooperation holds.

Level: Advanced

game-theorycooperationreciprocitytit-for-tatnash-equilibriumsocial-dilemmarepeated-gamenoisesimpy

  • Stocks: trust (last move seen), cumulative payoff
  • Flows: defections, retaliations, forgiveness events
  • Feedback Loops: retaliation echo (reinforcing), forgiveness (balancing)
  • Probes: cooperation_rate, round_payoff, cumulative_payoff