Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.4K Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Increase efficiency of cellular automaton and combine values in datasets

POSTED BY: Jon Rickett
3 Replies

Hi Sam,

I recently found some code which has helped:

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]

However, this is for a 9-neighbourhood region. Do you know how I can implement a 5-neighbourhood totalistic region for this?

POSTED BY: Jon Rickett

I'm sure it probably could, however I have been struggling to interpret the implementation of the required rules into the CellularAutomaton function.

I labelled each site as:

0 - black site
1 - green site
2 - red site

The rules required for update at each time step are: i) red site becomes black ii) green site becomes red if one of it's neighbors is red, otherwise it becomes red with probability f iii) a black site becomes green with probability p.

Any assistance with the CellularAutomaton function is welcome too though.

POSTED BY: Jon Rickett

Are you sure your algorithm cannot be implemented via CellularAutomaton function? See Details section (especially "general function to apply to each list of neighbors ") and many examples.

POSTED BY: Sam Carrettie
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard