Skip to content

A forest fire model implemented with cellular automata, featuring tunable parameters for burn probability, tree growth, and spontaneous ignition. Useful for studying emergent behavior and dynamic systems.

Notifications You must be signed in to change notification settings

yazy7991/forest-fire-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌲πŸ”₯ Forest Fire Simulation (Cellular Automaton)

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)

πŸ“Œ Features

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)

🧠 How the Simulation Works

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.

πŸ§ͺ Example Output

The simulation animates a visual representation where:

Yellow = Empty

Green = Tree

Red = Burning

Matplotlib animates the spread of the fire over time.

πŸ›  Installation & Setup

  1. Clone the repository git clone https://github.com/yourusername/forest-fire-simulation.git cd forest-fire-simulation

  2. 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

πŸ”’ Key Variables

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.

🧩 How the Animation Works

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

πŸ“˜ Future Improvements

Add true parallel acceleration (Numba JIT)

Add GUI interface

Add export feature (GIF/MP4)

Add adjustable rules (wind, humidity, obstacles)

About

A forest fire model implemented with cellular automata, featuring tunable parameters for burn probability, tree growth, and spontaneous ignition. Useful for studying emergent behavior and dynamic systems.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published