A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
8
Task/Forest-fire/Mathematica/forest-fire.mathematica
Normal file
8
Task/Forest-fire/Mathematica/forest-fire.mathematica
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
evolve[nbhd_List, k_] := 0 /; nbhd[[2, 2]] == 2 (*burning->empty*)
|
||||
evolve[nbhd_List, k_] := 2 /; nbhd[[2, 2]] == 1 && Max@nbhd == 2 (*near_burning&nonempty->burning*)
|
||||
evolve[nbhd_List, k_] := RandomChoice[{f, 1 - f} -> {2, nbhd[[2, 2]]}] /; nbhd[[2, 2]] == 1 && Max@nbhd < 2 (*spontaneously combusting tree*)
|
||||
evolve[nbhd_List, k_] := RandomChoice[{p, 1 - p} -> {1, nbhd[[2, 2]]}] /; nbhd[[2, 2]] == 0 (*random tree growth*)
|
||||
|
||||
r = 100; c = 100; p = 10^-2; f = 10^-4;
|
||||
init = RandomInteger[BernoulliDistribution[0.05], {r, c}];
|
||||
MatrixPlot[CellularAutomaton[{evolve, {}, {1, 1}}, {init, 0}, {{{300}}}], ColorRules -> {0 -> White, 1 -> Green, 2 -> Red}, Frame -> False]
|
||||
Loading…
Add table
Add a link
Reference in a new issue