simfire.game.managers.fire#

Defines the different FireManager`s (`ConstantSpreadFireManager and RothermelFireManager) that determine how a fire moves about a fire_map.

Module Contents#

Classes#

FireManager

Base class to manage the spread of the fire as well as the map of which

RothermelFireManager

This FireManager will spread the fire based on the basic `Rothermel

ConstantSpreadFireManager

This FireManager will spread fire at a constant rate in all directions.

Attributes#

simfire.game.managers.fire.log#
simfire.game.managers.fire.NewLocsType#
simfire.game.managers.fire.SpriteParamsType#
class simfire.game.managers.fire.FireManager(init_pos, fire_size, max_fire_duration, attenuate_line_ros=True, headless=False, diagonal_spread=True)#

Base class to manage the spread of the fire as well as the map of which pixels have already burned. Child classes should create their own update() method to describe how the fire spreads.

Initialize the class by recording the initial fire location and size.

Create the fire sprite and fire_map and mark the location of the initial fire.

Parameters:
  • init_pos (Tuple[int, int]) – The (x,y) location of the initial fire

  • fire_size (int) – The (n,n) pixel size of the fire sprite. Note that the sprite pixel size does not affect which tiles/pixels are actually burning. This is for display purposes only. Each fire is only burning on one pixel at a time.

  • max_fire_duration (int) – The number of frames/updates a fire will burn for before going out. This is moslty useful so that fires that have spread and are now on the interior do not have to keep being rendered.

  • attenuate_line_ros (bool) – Whether or not to attenuate the rate of spread. Defaults to True. If set to True, will subtract values found in enums.RoSAttenuation from the initial rate of spread calculation. If set to False, all different control lines will completely stop the fire.

  • headless (bool) – Flag to run in a headless state. This will allow PyGame objects to not be initialized.

  • diagonal_spread (bool) – Whether or not to have the fire spread calculation apply to diagonal pixels. If this is True, the fire may spread past firelines that don’t take this into account.

Returns:

None

update(fire_map)#

Method that describes how the fires in `self.sprites`should spread.

Should be updated in child classes.

Parameters:

fire_map (numpy.ndarray) – All possible fire conditions at each pixel location

Return type:

Any

class simfire.game.managers.fire.RothermelFireManager(init_pos, fire_size, max_fire_duration, pixel_scale, update_rate, fuel_particle, terrain, environment, max_time=None, attenuate_line_ros=True, headless=False, diagonal_spread=True)#

Bases: FireManager

This FireManager will spread the fire based on the basic `Rothermel Model <https://www.fs.fed.us/rm/pubs_series/rmrs/gtr/rmrs_gtr371.pdf`_.

Initialize the class by recording the initial fire location and size. Create the fire sprite and fire_map and mark the location of the initial fire.

Parameters:
  • init_pos (Tuple[int, int]) – The (x,y) location of the initial fire

  • fire_size (int) – The (n,n) pixel size of the fire sprite. Note that the sprite pixel size does not affect which tiles/pixels are actually burning. This is for display purposes only. Each fire is only burning on one pixel at a time.

  • max_fire_duration (int) – The number of frames/updates a fire will burn for before going out. This is moslty useful so that fires that have spread and are now on the interior do not have to keep being rendered.

  • pixel_scale (float) – The amount of ft each pixel represents. This is needed to track how much a fire has burned at a certain location since it may take more than one update for a pixel/location to catch on fire depending on the rate of spread.

  • update_rate (float) – The amount of time in minutes that passes for each simulation update step

  • fuel_particle (simfire.world.parameters.FuelParticle) – The parameters that describe the fuel particle

  • terrain (simfire.game.sprites.Terrain) – The Terrain that describes the simulation/game

  • environment (simfire.world.parameters.Environment) – The Environment that describes the simulation/game

  • max_time (Optional[int]) – The maximum amount of time that the fire can spread for, in minutes.

  • attenuate_line_ros (bool) – Whether or not to attenuate the rate of spread. Defaults to True. If set to True, will subtract values found in enums.RoSAttenuation from the initial rate of spread calculation. If set to False, all different control lines will completely stop the fire.

  • headless (bool) – Flag to run in a headless state. This will allow PyGame objects to not be initialized.

  • diagonal_spread (bool) – Whether or not to have the fire spread calculation apply to diagonal pixels. If this is True, the fire may spread past firelines that don’t take this into account.

draw_spread_graph(game_screen=None)#

Create a matplotlib Figure with the fire spread graph overlain on the terrain image.

Parameters:

game_screen (Optional[pygame.surface.Surface]) – The game’s screen to use as the background. If None, use the terrain image

Returns:

A matplotlib.pyplot.Figure containing the graph on top of the

terrain image

Return type:

matplotlib.pyplot.Figure

update(fire_map)#

Update the spreading of the fires. This function will remove any fires that have exceded their duration and will spread fires that have reached the correct rate of spread for a long enough time.

Parameters:

fire_map (numpy.ndarray) – The numpy array that tracks the fire’s burn status for each pixel in the simulation

Returns:

A NumPy array of the updated fire_map and the current GameStatus

Return type:

Tuple[numpy.ndarray, simfire.enums.GameStatus]

class simfire.game.managers.fire.ConstantSpreadFireManager(init_pos, fire_size, max_fire_duration, rate_of_spread)#

Bases: FireManager

This FireManager will spread fire at a constant rate in all directions.

Initialize the class by recording the initial fire location and size. Create the fire sprite and fire_map and mark the location of the initial fire.

Parameters:
  • init_pos (Tuple[int, int]) – The (x,y) location of the initial fire

  • fire_size (int) – The (n,n) pixel size of the fire sprite. Note that the sprite pixel size does not affect which tiles/pixels are actually burning. This is for display purposes only. Each fire is only burning on one pixel at a time.

  • max_fire_duration (int) – The number of frames/updates a fire will burn for before going out. This is moslty useful so that fires that have spread and are now on the interior do not have to keep being rendered.

  • rate_of_spread (int) – The number of frames that must pass before a fire can spread to adjacent pixels.

update(fire_map)#

Spread the fire and add new fire sprites to the display. The fire will spread at a constant rate in all directions based on self.rate_of_spread. self.fire_map is updated accordingly based on which fires have started/spread/stopped.

Parameters:

fire_map (numpy.ndarray) – All possible fire conditions at each pixel location

Returns:

An updated NumPy array of the current fire_map

Return type:

numpy.ndarray