THE NATURE OF CODE
BY DANIEL SHIFFMAN
SUPPORT
GITHUB
CODING TRAIN
Other Options
Chapter 0. Randomness
Example 0.1
A Traditional Random Walk
Example 0.2
A Random-Number Distribution
Example 0.3
A Walker That Tends to Move to the Right
Example 0.4
A Gaussian Distribution
Example 0.5
An Accept-Reject Distribution
Example 0.6
A Perlin Noise Walker
Chapter 1. Vectors
Example 1.1
Bouncing Ball with No Vectors
Example 1.2
Bouncing Ball with Vectors!
Example 1.3
Vector Subtraction
Example 1.4
Multiplying a Vector
Example 1.5
Vector Magnitude
Example 1.6
Normalizing a Vector
Example 1.7
Motion 101 (Velocity)
Example 1.8
Motion 101 (Velocity and Constant Acceleration)
Example 1.9
Motion 101 (Velocity and Random Acceleration)
Example 1.10
Accelerating Toward the Mouse
Chapter 2. Forces
Example 2.1
Forces
Example 2.2
Forces Acting on Two Objects
Example 2.3
Gravity Scaled by Mass
Example 2.4
Including Friction
Example 2.5
Fluid Resistance
Example 2.6
Attraction
Example 2.7
Attraction with Many Movers
Example 2.8
Two-Body Attraction
Example 2.9
n Bodies
Chapter 3. Oscillation
Example 3.1
Angular Motion Using rotate()
Example 3.2
Forces with (Arbitrary) Angular Motion
Example 3.3
Pointing in the Direction of Motion
Example 3.4
Polar to Cartesian
Example 3.5
Simple Harmonic Motion I
Example 3.6
Simple Harmonic Motion II
Example 3.7
Oscillator Objects
Example 3.8
Static Wave
Example 3.9
The Wave
Example 3.10
A Spring Connection
Example 3.11
Swinging Pendulum
Chapter 4. Particle Systems
Example 4.1
A Single Particle
Example 4.2
An Array of Particles
Example 4.3
A Single Particle Emitter
Example 4.4
A System of Systems
Example 4.5
A Particle System with Inheritance and Polymorphism
Example 4.6
A Particle System with Forces
Example 4.7
A Particle System with a Repeller
Example 4.8
An Image-Texture Particle System
Example 4.9
Additive Blending
Chapter 5. Autonomous Agents
Example 5.1
Seeking a Target
Example 5.2
Arriving at a Target
Example 5.3
“Stay Within Walls” Steering Behavior
Example 5.4
Flow-Field Following
Example 5.5
Creating a Path Object
Example 5.6
Simple Path Following
Example 5.7
Path Made of Multiple Line Segments
Example 5.8
Path Following
Example 5.9
Separation
Example 5.10
Combining Steering Behaviors (Seek and Separate)
Example 5.11
Flocking
Example 5.12
Bin-Lattice Spatial Subdivision
Example 5.13
Quadtree
Example 5.14
Sin/Cos Lookup Table
Chapter 6. Physics Libraries
Example 6.1
Matter.js Default Render and Runner
Example 6.2
A Comfortable and Cozy p5.js Sketch That Needs a Little Matter.js
Example 6.3
Falling Boxes Hitting Boundaries
Example 6.4
Polygon Shapes
Example 6.5
Multiple Shapes on One Body
Example 6.6
Matter.js Pendulum
Example 6.7
Spinning Windmill
Example 6.8
MouseConstraint Demonstration
Example 6.9
Attraction with Matter.js
Example 6.10
Collision Events
Example 6.11
Simple Spring with Toxiclibs.js
Example 6.12
Soft Swinging Pendulum
Example 6.13
Soft-Body Character
Example 6.14
Cluster
Example 6.15
Attraction (and Repulsion) Behaviors
Chapter 7. Cellular Automata
Example 7.1
Wolfram Elementary Cellular Automata
Example 7.2
Game of Life
Example 7.3
Object-Oriented Game of Life
Chapter 8. Fractals
Example 8.1
Recursive Circles Once
Example 8.2
Recursive Circles Twice
Example 8.3
Recursive Circles Four Times
Example 8.4
The Cantor Set
Example 8.5
The Koch Curve
Example 8.6
A Recursive Tree
Example 8.7
A Stochastic Tree
Example 8.8
Simple L-system Sentence Generation
Example 8.9
An L-system
Chapter 9. Evolutionary Computing
Example 9.1
Genetic Algorithm for Evolving Shakespeare
Example 9.2
Smart Rockets
Example 9.3
Smarter Rockets
Example 9.4
Interactive Selection
Example 9.5
An Evolving Ecosystem
Chapter 10. Neural Networks
Example 10.1
The Perceptron
Example 10.2
Gesture Classifier
Chapter 11. Neuroevolution
Example 11.1
Flappy Bird Clone
Example 11.2
Flappy Bird with Neuroevolution
Example 11.3
Smart Rockets with Neuroevolution
Example 11.4
Dynamic Neuroevolutionary Steering
Example 11.5
A Bloop with Sensors
Example 11.6
A Neuroevolutionary Ecosystem