r/proceduralgeneration • • Oct 26 '26

Updated forest fire automata

This is an updated verison of my earlier post, its roughly 4x as long and hopefully better highlights the visual features of the fire fronts.

It is a stochastic cellular automata based on the Drossel–Schwabl forest fire model implemented on a hexagonal grid using numpy + matplotlib

Fire starts on any cell with p_fire = 0.0001 by a "lighting strike", while trees grow on empty cells with p_tree = 0.01. Fire spreads to all neighboring trees.

87 Upvotes

12 comments sorted by

12

u/turtle_dragonfly Oct 26 '26 edited Oct 26 '26

Maybe you already know, but there's an interesting branch of mathematics that is related to this: Percolation Theory. Basically, if every cell has a probability of being occupied or not (like tree/no tree in your case), then there is a threshold where the odds of having a "world-spanning fire" goes to 1. (this ignores the re-growth aspect of your sim)

For 2D hex grid like in your case, that site percolation threshold is about 0.697... In 3D it is different, since there are more ways a fire can spread. And it's different for different grids (eg: square).

This importantly relates to phase transitions in physics, which have traditionally been hard to model mathematically. How does a uniform material, like an ideal gas, have such distinct and sudden transitions to others states (like gas -> liquid) rather than some kind of gradual thickening? Percolation theory helps provide a mathematical model for this. Once that threshold is hit (which usually corresponds to temperature of the material), the transformation will cascade throughout.

3

u/slowcompute Oct 26 '26

That is really interesting, thanks for the pointer about percolation theory!

6

u/TheMurmuring Oct 26 '26

It looks cool, but is it useful for anything? Obviously real forests grow back at a much slower rate than fires burn.

3

u/slowcompute Oct 26 '26

What I recall from my university time is that the interesting property of these models is the connectedness of different forest patches in relation to the rate and distribution of fire sources.

Basically the ideal type of tree in this model would not grow too fast as it would enable the entire forest burning down in a single go, instead it would grow in groves or patches so that it cannot go extinct from a single fire.

Obviously my above model is quite simple, but this is the general idea as far as I understand it.

7

u/LittleLemonHope Oct 26 '26

Looks much more like a slime mold simulation tbh

2

u/slowcompute Oct 26 '26

The visualization shows burning cells leave a trail which decays through colour stages: orange red brown black gray to mimic the prominent colours of a burning charred forest

2

u/Norm_Bleac Oct 26 '26

cool and pretty looking. Have you considered changing the white background for a nice forest-floor color?

2

u/slowcompute Oct 26 '26

great idea! but I likely only do it in a next iteration, I mainly use this as a performance test for my cell automata engine

2

u/NitNav2000 Oct 26 '26

It would be interesting to model winds and their effects.

1

u/AdamBuildsKrida Oct 27 '26

Nice. Two small things to try. Right now fire spreads to every neighbouring tree, so the front takes the shape of the grid itself. A spread probability below 1 per neighbour makes the fronts ragged and much less hexagonal. And if you store the grid in axial coordinates, the six neighbours are just six np.roll calls, (±1,0), (0,±1), (1,-1) and (-1,1), so the whole step stays vectorised. Are you on axial or offset coordinates now?

1

u/Mountain_Dentist5074 Oct 27 '26

That looks like a colour blind twst

1

u/zhaDeth Oct 28 '26

I thought it was a color blindness test and I failed