# Tag Info

## Hot answers tagged cellular-automata

13

Conway's game of life is a 2D, two-state, outer totalistic, cellular automaton. I guess the natural thing is to try such CAs in 3D. Here's the evolution of one such CA: twos = Array[2 &, {3, 3}]; twosWithOne = twos; twosWithOne[[2, 2]] = 1; outerTotalisticCA3D[ruleNumber_Integer, duration_Integer, init_List] := CellularAutomaton[ {ruleNumber, ...

12

Unfortunately, the approach of using Apply[Plus, Flatten[nbhd]] is fatal to your algorithm because summing up the cell-values introduces ambiguities. As an example take these rules from your excel file (White (0), Red (1) and Black (2)). This is in the Excel-file at A43: {{2,2,2},{2,2,0},{0,0,0}} -> 2 And this is in A179: {{1,1,1},{1,2,1},{1,1,1}} -&...

9

This is a sample problem that I hope can be helpful; a fire that can spread in four directions (the Von Neumann neighborhood). Only trees can catch fire though. A typical fire looks like this: Any of the methods below can generate it. There appears to be a name collision between method 1 and 2, so you may need to restart the kernel before you can try the ...

8

Simulating only a single generation is trivial. Just omit the Dynamic and the tspec. gameOfLife = {224, {2, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1, 1}}; board = RandomInteger[1, {64, 64}]; ArrayPlot@board ArrayPlot[board = CellularAutomaton[gameOfLife, board]] The trickier part is understanding the rule specification. There are many forms of these ...

7

Given the rule as explained by Halirutan... If the number of Red cells is equal to the number of Black cells, then the center cell gets White. Otherwise the center gets the color Red, if we have more Red cells and Black if we have more Black cells. ...it's interesting to note how things work if we use the following mapping of colours to numbers: ...

6

The "rule" for CAs defines the mapping that is used to calculate successive generations. When you have 3-neighborhoods (one to each side of the current element) there are 8 patterns that can occur: 111, 110, 101, 100, 011, 010, 001, 000. Each of these patterns must be mapped to some binary value. For example the rule that takes 111->0, 110->0, 101->0, 100->1,...

5

Here's a way to model @Anon's forest fire with image processing. ImageFilter is not very fast, of which the documentation warns you. However it's acceptable, especially because it makes a nice Dynamic animation. Perhaps it could be adapted - certainly if any of Anon's methods can - to the OP's question. One difference is that in the OP's problem, the ...

5

Here is a visualization of what bill s told: GraphicsRow[ GraphicsColumn[ {Style[2^#, Medium], ArrayPlot[ {#, {0, CellularAutomaton[30, #, {{1}, {1}}][[1, 1]], 0}}, Mesh -> All] &@IntegerDigits[#, 2, 3]} ] & /@ Range[0, 7]] First row of cells represents eight 3-bit binary values from 0 to 7. The middle cell ...

5

Update: The original post below computes the commonest color in the NeighborhoodGraph of a vertex v including the vertex v itself. To exclude a vertex in counting the colors in its neighborhood, we can use the following helper function: ClearAll[newClrF]; newClrF = Module[{nc=#, oc=First@#, c1= Commonest[Rest@#][[1]], c2= Quiet@Commonest[Rest@#, 2]}, ...

5

First, let's whip up a random graph: n = RandomInteger[{10, 15}]; m = RandomInteger[{Floor[n^2/20], n (n - 1)/2}]; G = RandomGraph[{n, m}]; For[i = 1, i <= n, i++, chi[0, i] = {Red, Blue}[[RandomInteger[] + 1]] ]; Graph[G, VertexStyle -> Table[i -> chi[0, i], {i, 1, n}]] The coloring at step k will be denoted chi[k,i], where i indicates a ...

4

The higher order CellularAutomaton is not well documented. Anyway, this is my attempt to define 37R automaton. I am not completely sure if it works correctly, but for me, for a while, it works OK. First I define the function that gives the new cell depending on two 3-cell neighborhoods. The 37R rule function is defined by d37 = IntegerDigits[37, 2, 8]...

4

According to this Wikipedia entry (also A New Kind of Science), the number system used by CellularAutomaton is called Wolfram Code. Inspired by the 1D system, this is how I think the 2D system works. First we generate all 2D 9-neighbor cases: baseSet = Tuples[{1, 0}, {3, 3}]; Then we apply the transformation rules on the baseSet one-by-one, and combine ...

4

Here's a code that seems a bit more in the functional-programming spirit of Mathematica. I divide the tree into active and inactive components to save time that might be wasted updating already-fruited branches. Then I can use a very simple rule to grow the tree. I use a Sow/Reap to quickly scan the tree for collided branches. root={{},{{e},{w}}}; grow[{...

3

Here are two more ways. lst = {{0, 0}, {1, 0}, {2, 0}}; init = {7, 3, 9}; MapThread[{#1[[1]], #1[[2]], #2} &, {lst, init}] and helper[{a_, b_}, c_] := {a, b, c} Thread[helper[lst, init]] Both produce {{0, 0, 7}, {1, 0, 3}, {2, 0, 9}} P.S. Just for fun and as my entry into this month's obfuscated Mathematica contest: Inner[Append, Hold @@ lst, ...

3

More an extended comment than a complete answer or "how to". Vialiy's comment and the few pages Stephen Wolfram writes on the subject in A New Kind of Science, certainly provide a good place to start. Adding some basic understanding of types of participants might improve your chances of analyzing this problem with CellularAutomaton. Within any ...

3

No, the CelluluarAutomaton command works is specifically designed to model cellular automata on grids. It's certainly feasible to roll your own, though. Your example using GraphPlot3D I generated the following graph using your code. rules = {1 -> 5, 1 -> 1, 1 -> 8, 1 -> 6, 1 -> 2, 2 -> 5, 2 -> 2, 2 -> 7, 2 -> 7, 2 -> 5, 3 ...

3

Please read Documentation HERE - especially Details section and all the examples. Not enough specification: is it general, totalistic or outer totalistic rule CA? What is the rule? By 4 neighbors you mean Von Neumann neighborhood? 100 colors are too many - hard to find interesting rules. Perhaps you want continuos color CA? Well, assuming Von Neumann ...

2

Here's a way to seed the game of life with a glider, using the built-in game of life CellularAutomaton and the OPs glider (starting at 10,10). glider[x_, y_] := {{x, y}, {x + 1, y}, {x + 2, y}, {x + 2, y + 1}, {x + 1, y + 2}}; gameOfLife = {224, {2, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1, 1}}; board = SparseArray[Flatten[{Thread[glider[10, 10] -> 1], {50,...

2

More is better, other variation: upDateColor[g_] := Block[{color, vlist, c}, color = Association[PropertyValue[g, VertexStyle]]; vlist = VertexList[g]; SetProperty[g, VertexStyle -> Table[v -> If[Length[c = Commonest[color /@ AdjacencyList[g, v]]] == 1, First[c], color[v]], {v, vlist}]] ] example: g = PetersenGraph[...

1

There are many ways to do this. For instance, lst = {{0, 0}, {1, 0}, {2, 0}}; init = {7, 3, 9}; MapThread[Append[#1, #2] &, {lst, init}] (* {{0, 0, 7}, {1, 0, 3}, {2, 0, 9}} *) or lst1 = {{0, 0, 0}, {1, 0, 0}, {2, 0, 0}}; MapThread[ReplacePart[#1, 3 -> #2] &, {lst1, init}] which produces the same result. See Adding, Removing, and Modifying ...

1

My final solution After working on the code a little bit more, I've come up with a much better way to tackle the problem that I will leave here for posterity First I define the size of the simulation, create the seed and launch kernels if they aren't already running. (*Define some variables, generate the seed and launch the kernels.*) gridSize = 50; ...

1

Is this what you want? MatrixPlot /@ CellularAutomaton[{100 (4 (100 - 1) + 1), {100, 1}, {1, 1}}, Table[RandomInteger[], {20}, {20}], 1]

1

The answer is "yes," any function you can represent in a computer can also be represented by a cellular automata. This is because some CAs are "universal Turing machines," which means that anything that can be computed algorithmically can be computed by the CA. Perhaps the best known example is a CA called the game of life. This is only an existence ...

Only top voted, non community-wiki answers of a minimum length are eligible