This project simulates the spread of fire in a forest using a cellular automaton model. It visualizes how fire propagates through trees over time based on probability rules such as ignition, immunity, and lightning strikes.
The simulation uses:
-
Moore Neighborhood (8 surrounding cells)
-
Reflective boundary conditions
-
Randomized forest generation
-
Matplotlib animation for visualization
-
Optional parallelized versions of functions (Numba-ready)
Random forest initialization
Configurable probabilities for:
-
Tree presence
-
Initial burning
-
Tree immunity
-
Lightning strike
-
Fire spread modeled using neighborhood checks
-
Animation of the full simulation
-
Sequential + parallel versions of major functions
-
Support for large grids (up to 2000Γ2000)
Each cell can be in one of three states:
Value Meaning 0 EMPTY 1 TREE 2 BURNING
At each timestep:
Trees may catch fire if any neighbor is burning.
Trees may resist burning based on immunity probability.
Lightning may randomly ignite trees.
Burning trees become empty on the next step.
Boundary cells use reflective edges to avoid index issues.
The simulation runs for a configurable number of timesteps and stores each grid state.
The simulation animates a visual representation where:
Yellow = Empty
Green = Tree
Red = Burning
Matplotlib animates the spread of the fire over time.
-
Clone the repository git clone https://github.com/yourusername/forest-fire-simulation.git cd forest-fire-simulation
-
Install dependencies pip install matplotlib
(Optional Numba acceleration)
pip install numba
π Running the Simulation
Simply run:
python [filename].py
This will:
Generate the forest
Run the simulation
Display an animated visualization
probTree = 0.8 # Probability a cell is a tree probBurning = 0.01 # Initial probability a tree is burning probImmune = 0.3 # Chance a tree resists catching fire probLightning = 0.001 # Chance a tree is struck by lightning timeStep = 500 # Number of simulation steps
You can adjust these values to explore different fire-spread behaviors.
At the end of the script:
A custom colormap maps cell states to colors
Matplotlibβs FuncAnimation updates the grid for each timestep
pyplot.show() begins the animation
Add true parallel acceleration (Numba JIT)
Add GUI interface
Add export feature (GIF/MP4)
Add adjustable rules (wind, humidity, obstacles)