simidiot.net

Late-night tutorials for understanding simulation, written in the margins of a library that never closes

Foundations of Simulation

Simulation is the art of building a simplified world. Not to replace reality, but to understand it—to see which pieces matter and which are noise.

When you build a model of a population, a market, or a neural network, you're making choices about what to include. The idiot part of this domain is acknowledging that every model is wrong. The useful part is knowing how it fails.

// A simple population simulation
const step = (population, birthRate, deathRate) => {
  const births = population * birthRate;
  const deaths = population * deathRate;
  return population + births - deaths;
};

The above code misses migration, age distribution, disease, and ten thousand other factors. And yet, it captures something true about exponential growth and decay.

Agent-Based Models

In agent-based modeling, you don't solve equations. You simulate entities—"agents"—that follow simple rules and interact with each other and their environment. Complexity emerges from the interplay.

Think of a forest fire: no central orchestration, just trees burning when they get hot enough, spreading flames to neighbors. The pattern that emerges—irregular burned patches, firebreaks of unburned forest—looks designed, but it's purely emergent.

class Agent {
  constructor(x, y, energy) {
    this.x = x;
    this.y = y;
    this.energy = energy;
  }

  step(environment) {
    // Move toward food
    // Consume energy
    // Reproduce if energy > threshold
  }
}

The magic is in the step function. Call it thousands of times, and populations oscillate, predator-prey cycles emerge, and the system reaches strange attractors.

Neural Networks as Simulated Minds

A neural network is a simulation of how a mind might work—not how it actually does. We build layers of simplified neurons, apply backpropagation, and watch patterns emerge.

The network doesn't "understand" what it's simulating. It's a tool for approximating functions, for finding patterns in data. But the patterns it finds are often patterns we didn't know existed—or didn't want to see.

// Training loop for a simple network
for (let epoch = 0; epoch < maxEpochs; epoch++) {
  let loss = 0;
  for (let sample of trainingData) {
    const prediction = network.forward(sample.input);
    const error = sample.output - prediction;
    loss += error * error;
    network.backward(error);
  }
  if (loss < threshold) break;
}

This is optimization driven by mathematics, not intelligence. And yet, enough layers and parameters, and the optimized function behaves intelligently. The simulation becomes indistinguishable from the thing itself.

The Idiot's Truth

All models are wrong. Some are useful. The ones that are useful are often wrong in enlightening ways—their failures teach us about the world better than their successes.

Simulation is an exercise in productive humility: building worlds you know are incomplete, running them anyway, and learning from the gaps between the simulation and reality.

Welcome to simidiot.net. Build something that breaks beautifully.