OpenEnv documentation

Wildfire Environment

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.8.0).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Wildfire Environment

A wildfire-control simulation for reinforcement learning. The agent contains spreading fires with water and firebreaks under wind and humidity, with limited resources. The spread model is inspired by the Rothermel surface fire spread model and MITRE Fireline’s SimFire.

Quick Start

Build and run the server from envs/wildfire_env/:

docker build -t wildfire-env:latest -f server/Dockerfile .
docker run -p 8000:8000 wildfire-env:latest

The image enables the web interface at http://localhost:8000/web.

from wildfire_env import WildfireAction, WildfireEnv

with WildfireEnv(base_url="http://localhost:8000").sync() as env:
    result = env.reset()
    obs = result.observation
    print(f"Grid: {obs.width}x{obs.height}, Fires: {obs.burning_count}, Water: {obs.remaining_water}")

    result = env.step(WildfireAction(action="water", x=10, y=15))  # water a cell
    result = env.step(WildfireAction(action="break", x=12, y=15))  # build a firebreak
    result = env.step(WildfireAction(action="wait"))               # let the fire evolve
    print(f"Reward: {result.reward:.2f}, Burning: {result.observation.burning_count}")

To run without Docker, pip install -e envs/wildfire_env and start server (or python -m wildfire_env.server.app).

Grid

The observation’s grid is a flat list of width * height cells. Cell (x, y) is grid[y * width + x]:

import numpy as np
grid_2d = np.array(obs.grid).reshape(obs.height, obs.width)  # grid_2d[y][x]
CodeCellBehavior
0AshBurned out, can’t reignite
1FuelCan ignite
2BurningSpreads to neighbors, turns to ash after 3 ticks
3FirebreakFire can’t cross it
4Water/dampCan’t ignite, reverts to fuel after 6 ticks

Actions

WildfireAction: action ("water", "break" or "wait"), plus x and y for water and break.

  • water uses 1 water unit. It extinguishes a burning cell or dampens fuel (both become 4).
  • break uses 1 firebreak unit and turns the cell into a firebreak (3).
  • wait does nothing, and the fire keeps spreading.

Observation

WildfireObservation:

  • grid, width, height: the grid (see above)
  • step: step number (0 after reset)
  • wind_dir: N, NE, E, SE, S, SW, W, NW or CALM
  • humidity: 0.0 to 1.0, higher means less spread
  • burning_count, burned_count: cells on fire and ash cells
  • remaining_water, remaining_breaks: resources left
  • reward_hint: same value as the step reward
  • reward, done

env.state() returns a WildfireState with episode_id, step_count, total_burned, total_extinguished, last_action and the full grid and timers.

The episode ends when no cell is burning or after max_steps steps (default 128).

Reward

Each step sums the action reward, the fire dynamics and a time penalty:

EventReward
Water a burning cell+0.25
Water a fuel cell-0.10
Water a damp, ash or firebreak cell-0.05
Firebreak on fuel or a damp cell+0.15
Firebreak on a burning cell-0.02
Firebreak on ash-0.02
Firebreak on a firebreak-0.01
Invalid action (unknown, out of bounds, missing coordinates, no resources left)-0.05
Fire spread: each extra burning cell after the fire update-0.15
Fire shrink: each burning cell fewer after the fire update+0.10
Each new ash cell-0.05
Every step-0.01

When the episode ends, it adds 0.2 * (1 - burned_ratio), plus 0.5 + 0.5 * saved_ratio if the fire is out.

Fire Spread

Each burning cell can ignite its 8 neighbors. The ignition probability is 0.30 * (1 - humidity), times 2.0 downwind, 0.5 upwind and 1.0 across the wind, and times 0.6 for diagonal neighbors. Humidity varies by ±0.05 around the configured value at each reset.

Configuration

Set these environment variables before starting the server:

VariableDefaultDescription
WILDFIRE_WIDTH16Grid width
WILDFIRE_HEIGHT16Grid height
WILDFIRE_HUMIDITY0.25Base humidity
WILDFIRE_WINDrandomFixed wind direction (N … NW, CALM)
ENABLE_WEB_INTERFACEtrue in the Docker imageServe the web interface at /web
docker run -p 8000:8000 -e WILDFIRE_WIDTH=32 -e WILDFIRE_HEIGHT=32 -e WILDFIRE_WIND=N wildfire-env:latest

Other settings (init_sources=2 initial fires, max_steps=128, water_capacity=8, break_capacity=50, seed=3407) are constructor arguments of WildfireEnvironment in server/wildfire_environment.py.

Web Interface

The web interface shows the grid as colored cells. Click a cell to fill in the coordinates, pick an action and run it. It also shows the remaining resources, wind, humidity and an action log.

References

Citation

@techreport{rothermel2022surface,
  title     = {The Rothermel Surface Fire Spread Model and Associated Developments},
  author    = {Andrews, Patricia L. and Rothermel, Richard C.},
  year      = {2022},
  institution = {USDA Forest Service},
  number    = {RMRS-GTR-371},
  url       = {https://www.fs.usda.gov/rm/pubs_series/rmrs/gtr/rmrs_gtr371.pdf}
}

@article{tapley2023reinforcement,
  title   = {Reinforcement Learning for Wildfire Mitigation in Simulated Disaster Environments},
  author  = {Tapley, A. and Dotter, M. and Doyle, M. and others},
  journal = {arXiv preprint arXiv:2311.15925},
  year    = {2023},
  url     = {https://arxiv.org/abs/2311.15925}
}

@misc{mitrefireline2023simfire,
  author = {{MITRE Fireline Project}},
  title  = {SimFire: Wildfire Simulator for Decision-Support and AI Research},
  year   = {2023},
  howpublished = {\url{https://github.com/mitrefireline/simfire}}
}

@misc{wildfire-openenv-2025,
  title  = {Wildfire Environment for OpenEnv: Containment-Focused RL Simulation},
  author = {OpenEnv Contributors},
  year   = {2025},
  url    = {https://github.com/huggingface/OpenEnv}
}
Update on GitHub