The program simulates a forest fire in a terminal window. It is based on the model created in 1992 by Barbara Drossel and Frank Schwabl. Written in C for Linux.
The program consists of three files:
| File | Description |
|---|---|
| main.c | setup and main loop |
| grid.h | constants, cell states, declarations |
| grid.c | cell colors and definitions |
Optionally, set the grid dimensions and other constants in grid.h before building.
| Constant | Description |
|---|---|
| ROWS | number of rows |
| COLS | number of columns |
| STEPS | number of simulation steps |
| TIME | delay between steps in milliseconds |
| TREE_CHANCE | chance of a tree growing in each step |
| FIRE_CHANCE | chance of a fire starting in each step |
Then build the program and watch the world burn.
gcc main.c grid.c -o forest-fire
./forest-firecmake -B build
cmake --build build
./build/forest-fire