How can I create a function that would have as its argument an array mat of 0s, 1s, and 2s where the 2s are burning trees and the function would give an array that represents the forest after one time step?
I have tried using
mat=RandomChoice[{0,1,2},{10,10}]
nextstep[mat_]:=Sequence[mat2 + {1, 0}, mat2 + {0, 1}, mat2 + {-1, 0}, mat2 + {0,-1}]
but that doesn't seem to work. After one time step, every tree, represented by 1s, that is in the von Neumann neighborhood of a burning tree would catch fire, but the 0s, which means there are no trees, would remain the same.
EDIT: How can I further develop this so as to have a function that has as its argument the array mat and can iterate nextstep, until the array doesn't change anymore? So, essentially this new function would return {mat, nextstep[mat], nextstep[nextstep[mat]],...}. I tried using finalstate[mat_]:=NestList[nextstep, mat, 5], but it's not returning what I'm looking for.




