Influence Mapped Fire Propagation Simulation

This is a simulation of fire propagating on a two-dimensional grid. There are agents thrown in that avoid the fire and try find safety away from eminent danger. They do this by making use of a combined influence map for movement (which has been generated ignoring obstacles, dumb of me, I know!).

I at least generated the potential maps taking obstacles into account on my other post, thus creating a graph to traverse instead of evaluating a flat grid. Something to note for the next implementation. Best of all is that I knew of this and it was detailed in this article mentioned in a previous post. SO I worked around it for my first implementation and then forgot on my second!

Click the image at the bottom to overlay the influence map

There are a few parameters you can tweak.

  • Initial tree ratio – is the ratio of the grid size which will be trees on setup
  • Number of goals – is the number of goals that the agents will be attracted to
  • Goal decay rate – is the ratio at which the influence will decay (current influence * rate)
  • Fire decay rate – is the ratio at which  the influence will decay (current influence * rate)
  • Number of agents – is the number of initial agents on setup
  • Number of fires – is the number of fires to start when clicking the start fires button
  • Regrowth chance – is the chance that a burnt tree (brown) will regrow

The graph shows the number of fires over time.

Representation

Normal View (default)

  • Green = healthy tree
  • Blue = agent
  • Brown = burnt tree
  • Red = fire

Influence Map (after clicking the normal image)

  • Red = negative and avoid
  • Blue = positive and follow
  • Climb gradient
  • Opacity of the color = strength (1 = full blue [1] or full red [-1], 0 = transparent)

Assumptions / Hacks

  • Gave a 1px border by assigning a negative influence  to that space, preventing agents from moving there to avoid border check calculations.
  • Goals were introduced to attract the agents towards the center, otherwise they just run to the edge of the grid and stay there (could negatively charge the outside to rectify this, but lazy)
  • Fire & Agents can move in 8 directions (not just up, down, left, right)
  • The various influence maps are generated over a few frames to spread out the calculation.
  • The agents move every frame, fire propagates every 3 and trees regrow every 5

Bugs / Errors

  • Have local minima / maxima issues with the influence map because of a generic influence generation method, which does not take obstacles into account! [Causes agents to get stuck behind trees on the way to their goals]
  • Movement code does not account for an error rate, so 0.0000001 != 0.00001 [Causes cycling movement of agents back and forth]

Interesting points

  • Lots of fire quickly dies out
  • Densely populated trees cause that almost all trees burn
  • Higher regrowth and dense population increase probability of continued fire
  • Continued fire lowers the effect of the local minima / maxima

Know of any other “bugs” (hidden features) or other interesting points that I should include? Post them in the comments. Here is the really bad source code for this project.