I am committing myself to reading The Nature of Code by Daniel Shiffman, which I’ve had on my bookshelf for years but never opened. It’s a book about simulating natural systems with code — vectors, forces, oscillation, particle systems, autonomous agents, cellular automata, neural networks. Each chapter builds on the last.
The examples are written in p5.js, which I’ve used a little before and want to get more comfortable with. I’m not sure where this will take me — maybe better intuitions for animation and motion, maybe ideas for visualizations, maybe just the pleasure of making things bounce. Honest answer: I’m curious.
I figured I’d write a short post per chapter as I go. Not a formal review or tutorial — more like notes on what I worked through, what surprised me, and what I made along the way. Each post will probably include a sketch or two of my own.
Chapter 0 is mostly an introduction to randomness and probability. This is one of the first sketches Shiffman shows — draw a small transparent circle at a random position every frame, with a transparent background that lets the previous circles slowly fade. Run it for thirty seconds and you have something that looks like atmosphere.
Nothing fancy yet — that’s a few lines of code, randomness, and patience. But it’s the kind of thing the rest of the book builds on. By chapter 6 you’re supposedly simulating flocks of birds. We’ll see.
Next post: Chapter 1, Vectors.