CP2: Forest Fire – Simulation in p5.js
Channel: Jeff Thompson
Date: 30/03/2021

Based on a classic chaotic algorithm (citation is tricky) described in James Gleick's amazing book "Chaos." This example uses the grid of pixels instead of discreet objects: green are trees and black is empty space. A single random pixel (the seed) is started on fire. Each frame we test every pixel: if it's on fire, we set fire to any neighboring trees. This kind of grid-based system works great for terrain-generation too!



👩‍💻 https://editor.p5js.org/jeffThompson/sketches/58sH7ojC6

ALL THE VIDEOS IN THIS UNIT
🎥 https://youtube.com/playlist?list=PLsGCUnpinsDkhWlWYUdMC1R2yOLO2Xmqd

SEE ALSO
💡 A much more detailed paper that uses a similar approach: https://www.intechopen.com/books/forest-fire/forest-fire-model
💡 Mathematician John Conway's "Game of Life": http://pi.math.cornell.edu/~lipa/mec/lesson6.html
💡 https://www.youtube.com/watch?v=C2vgICfQawE

CHALLENGES
❓ Can you keep track of the number of pixels burned each frame and reset the simulation when it's zero?
❓ Can you add wind that makes the fire move faster in one direction?
❓ Can you add other elements to our landscape, perhaps ones like rocks or ponds that don't burn?