# How to Update a Finite-Width Cellular Automaton

How does one instruct CellularAutomaton to wrap at the edges? (I want a 2d finite-width CA, so it evolves on a torus.) I cannot tell from the docs if this is possible.

From some experiments and from reading between the lines of the documentation, if the second argument is a vector, then the system set up with periodic boundary conditions. See for example this one:

ArrayPlot[CellularAutomaton[30, PadLeft[{1}, 100], 150]]


• If you can elaborate a bit more on which documentation you are relying on and how it applies to the 2D (instead of 1d) case, that would help. I am guessing you are referring to this: "a_1,a_2,... explicit list of values a_i, assumed cyclic". I suppose that is suppose to mean that this init is implicitly 1d wrapping at the bounderies). In which case, I suppose, a 2d rectangular array for init should implicitly be 2d wrapping at the boundaries. – Alan Jul 24 '18 at 2:37
• Yes, exactly there. I only found it by searching for "cyclic" and "periodic" (with ctrl + f). I am not sure, but the 2D case should work exactly as you have just anticipated. – Henrik Schumacher Jul 24 '18 at 7:03

An alternative way to specify the initial condition:

ArrayPlot[CellularAutomaton[30, SparseArray[1 -> 1, 50], 50]]


Explicit initial conditions are assumed cyclic