Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7464 > unrolled thread

Cellular Automaton Syntax

Started byMark Perrin <m.perrin@me.com>
First post2011-12-29 07:53 +0000
Last post2011-12-29 07:53 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Cellular Automaton Syntax Mark Perrin <m.perrin@me.com> - 2011-12-29 07:53 +0000

#7464 — Cellular Automaton Syntax

FromMark Perrin <m.perrin@me.com>
Date2011-12-29 07:53 +0000
SubjectCellular Automaton Syntax
Message-ID<jdh69f$kjs$1@smc.vnet.net>
Hello,

I was wondering if I could get some help with syntax (if that is my 
problem) for CellularAutomaton.

Rather than using the prespecified rules I want to simply replace 
neighbouring cells according to a pattern.

If the cells number/color is "1" for instance, I want to change all 
neighboring cells with a value of 0 to 1, and any cell with a value of 
2,3,4 etc. to a number 1 higher, I also want to change the original cell 
to a number higher.

Here is what I have:

(* I have an array 10x10, with a single seed *)

w = Array[0&, {10,10}];
w[[2,2]] = 1;

(* these are my neighboring cells (using a hexagonal lattice with six 
neighbors) *)

n = {{0, 0}, {1, -1}, {-1, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};

(* my replacement function; if the 'focus' cell is = 1 change it to 2 
and increment all neighboring by 1, otherwise, increment all by 1 except 
if they are = 0*)

f[x_]:= If[x[[1]]==1, x /. {0 -> 1, 1 -> 2, 2 -> 3, 3 -> 4}, x/. 
{1 -> 2, 2 -> 3, 3 -> 4, 4->0}]

CellularAutomaton[{f[#] &, {}, n}, w, 1]


=97=97=97=97=97=97=97=97

The problem is quickly apparent that the function returns a list of the 
neighboring cells which now populates the array, instead of replacing 
the neighboring cells with their new value.

Question: how do I return the new values (after rule replacement) to the 
array?

I am very new to cellular automata, so forgive me if I am ignoring some 
basic principles.

Regards,

Mark


[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web