What is Doathingy Labs?
The Nature of Code teaches how to simulate the natural world with code: a falling leaf, a flock of birds, a forest that grows, a population that evolves. Labs turns those ideas into simulations you can actually touch. Launch a planet like a slingshot, release a predator into a flock, paint chemicals into a reaction–diffusion field, or watch a neural network learn to drive.
The simulations are organised in the book’s twelve chapters, and they come in three generations. The first generation shows each idea cleanly. The second and third generations are evolutions: they take an earlier simulation and push it further — combining mechanisms, adding measurements, or turning a demonstration into an experiment.
Play, then evolve
Every simulation has sliders, switches and colour controls, and most respond to the mouse. When you want more, press Evolve this: Labs suggests a handful of next-generation ideas based on the simulation’s own code, and builds the one you choose. You can also combine two or three simulations into one system, or start from scratch by picking concepts — say, Forces + Evolutionary Computing — and the kind of piece you want: an art piece, a game, an explainer or an experiment.
The chapters
00 · Randomness
Randomness is where simulating nature starts. These simulations show how the shape of randomness — uniform, Gaussian, Perlin noise, Lévy flights — changes everything from a wandering line to a whole planet.
Random Walkers · Distributions · Perlin Noise Landscapes · Self-Avoiding Walk · Monte Carlo π · Flying Over Noise Terrain · Brownian Motion & Diffusion · Paint Your Own Distribution · Domain-Warped Noise · Maze Generation & Solving · Buffon's Needle · Procedural Noise Planet
01 · Vectors
Everything that moves in a simulation is driven by vectors: a position, a velocity and an acceleration. These simulations make the arrows visible so the maths stops being abstract.
Vector Math Playground · Motion 101: Acceleration · Reflection off Walls · Matrices: Transforming Space · Spaceship: Thrust & Rotation · Laser & Mirrors (Ray Tracing)
02 · Forces
Newton’s second law — acceleration equals force divided by mass — is enough to simulate gravity, friction, drag and collisions. These simulations let you add the forces one at a time and see what each one does.
Forces: Gravity, Wind, Friction & Drag · Gravitational Attraction · Elastic Collisions & Momentum · The Three-Body Problem · Terminal Velocity & Parachutes · Colliding Galaxies · Ideal Gas & Maxwell–Boltzmann · Gravity Field & Potential
03 · Oscillation
Oscillation is motion that repeats: a pendulum, a spring, a wave. Add a second pendulum and it turns into one of the most famous examples of chaos.
Pendulum Wave · Springs (Hooke's Law) · Oscillation & Waves · Double Pendulum & Chaos · Pressure Soft Bodies (Jelly) · Fourier Epicycles · Harmonograph · Coupled Oscillators & Normal Modes · Ripple Tank (2D Wave Equation) · Phase Space & Strange Attractors · Soft-Body Lattices · Fourier Series: Building Waves
04 · Particle Systems
A particle system is a crowd of simple objects — sparks, raindrops, letters — born, moved and removed every frame. Together they make effects no single object could.
Particle Emitters · Fireworks: Systems of Systems · Particle Text · Rain, Splashes & Ripples
05 · Autonomous Agents
Autonomous agents decide for themselves where to go. Give each one a few simple steering rules and flocks, trails, traffic jams and transport networks emerge on their own.
Steering Behaviors · Flow Field Following · Flocking (Boids) · Path Following · Predators & Prey · Ant Colony & Pheromone Trails · Obstacle Avoidance · Physarum Slime Mould · Crowd Evacuation · Phantom Traffic Jams · Wolves, Sheep & Grass · Termites Building Piles
06 · Physics
Physics engines make things collide, hang, squash and tumble. These simulations build one from points and sticks, so you can see — and break — how it works.
Verlet Physics: Cloth & Ropes · Rigid Circles & the Galton Board · Verlet Ragdolls · Granular Hourglass
07 · Cellular Automata
A cellular automaton is a grid where every cell follows the same tiny rule based on its neighbours. From that, gliders, spirals, avalanches and Turing patterns appear.
Elementary Cellular Automata · Game of Life & Friends · Reaction–Diffusion (Gray–Scott) · Langton's Ant & Turmites · Atlas of All 256 Rules · Cyclic Cellular Automaton · Forest Fire Model · Abelian Sandpile
08 · Fractals
A fractal repeats its shape at every scale. Recursion, L-systems and the chaos game build trees, ferns, snowflakes and the endless coastline of the Mandelbrot set from a few lines of rules.
Recursive Tree · L-Systems · Space Colonization Trees · Mandelbrot & Julia Explorer · Chaos Game & IFS Fractals · Pythagoras Tree · Stochastic L-System Garden · Diffusion-Limited Aggregation · Burning Ship, Tricorn & Newton · Fractal Flames
09 · Evolutionary Computing
Evolution is an algorithm: copy the fittest with small mutations, repeat. These simulations let you watch it find answers nobody programmed — a rocket path, a phrase, a picture, a creature.
Evolving a Phrase · Smart Rockets · Traveling Salesperson (GA) · Interactive Selection: Breed Flowers · Evolving a Picture from Triangles · Evolving Steering: Food vs Poison · Simulated Annealing · Biomorphs
10 · Neural Networks
A neural network is a stack of weighted sums that learns by nudging its weights. These simulations show the learning happen, step by step, on data you can draw yourself.
The Perceptron · Neural Network Playground · Neural Network Curve Fitting · Gradient Descent Optimizers · Teach a Network Your Drawings · Overfitting & Regularization · Neural Network Painter · K-Means Clustering
11 · Neuroevolution
Neuroevolution combines the last two ideas: instead of training a neural network with examples, a genetic algorithm evolves its weights. Nobody tells the cars how to drive — the ones that get furthest have children.
Neuroevolution Ecosystem · Neuroevolution: Self-Driving Cars · Neuroevolution: Balancing a Pole · Neuroevolution: Rocket Landing
Free, private, and yours to export
Every simulation runs entirely in your browser — nothing to install, no account needed to play. You can save a picture of the canvas or download any simulation as a single HTML file that runs on its own.
Open Labs →
96 simulations to play with, and a studio that evolves them into new ones.