Wildfire Simulation
In this project, you will simulate the spread of a wildfire on an N by M grid representing a forest. The forest is generated by a random walk that marks tiles as trees until 50% of the map is forest. Fire then starts at K randomly chosen forest tiles. Each burning tile burns for 5 ticks. At each tick, every burning tile gives each of its neighboring forest tiles a 30% chance to ignite. The simulation runs until no tiles are burning. The program reads configuration from instructions.txt with template:
N M
K
p_spread
burn_ticks
seed
Example
100 100
10
0.30
5
42
If any line is missing, use sensible defaults such as p_spread 0.30, burn_ticks 5, and a random seed.
Implementation Guidelines
- Running the Program:
- Parse
instructions.txt: grid size N M, number of ignition points K, spread probability p_spread, burn duration burn_ticks, and optional seed. - Generate the forest with a random walk. Start from a random tile, walk uniformly at random, mark visited tiles as forest until 50% of tiles are forest. Nonvisited tiles remain nonforest.
- Initialize fire at K random forest tiles. If K exceeds available forest tiles, clamp to the number of forest tiles.
- Spread rule each tick: for every burning tile, each neighbor (diagonals considered neighbors) that is forest ignites independently with probability p_spread.
- Advance the simulation in ticks until there are no burning tiles.
- Rendering: Use distinct colors for grasslands, forest, burning, burned out. Optionally export a frame sequence or a video.
- Parse
Testing
- Vary grid size such as 50 by 50, 100 by 100, 200 by 200. Measure ticks to extinction and absolute times of simulation (ms).
- Vary K such as 1, 5, 10, 50. Observe how multiple ignition points change spread speed (ticks and absolute time) and final size.