Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm trying to write in Mathematica for a 20x20 grid, with 100 colours, with 4 neighbours. I want the initial conditions to be a 20x20 matrix consisting mainly of zeros.

CellularAutomaton[{100 (4 (100 - 1) + 1), {100, 1}, {1, 1}}, 
MatrixForm[Table[RandomInteger[], {20}, {20}]], 1]

Apparently init is not in the right form?

share|improve this question
    
If you are looking for ways to visualize your cellular automaton there are several examples in the documentation. –  Pickett Mar 11 at 22:00
    
Don't use MatrixForm; it is only intended for formatting output. CellularAutomaton wants a list for its 2nd argument (i.e., an expression with head List), not an expression with head MatrixForm, which is what you are giving it. Table returns a list that can be used without further processing. –  m_goldberg Mar 12 at 0:58
add comment

2 Answers 2

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 neighborhood, totalistic, 5 color CA you have (change 5 to 100 if you want but it will be boring):

Single non-zero cell initial condition:

dat = CellularAutomaton[
        {173452345235, {5, {{0, 1, 0}, {1, 1, 1}, {0, 1, 0}}}, {1, 1}}, 
         SparseArray[{{11, 11} -> 3}, {20, 20}], 13];

Image3D[Rescale@dat, ColorFunction -> "RainbowOpacity"]

enter image description here

Random initial condition:

dat = CellularAutomaton[
       {14524645253, {5, {{0, 1, 0}, {1, 1, 1}, {0, 1, 0}}}, {1, 1}}, 
        RandomInteger[4, {20, 20}], 20];

Image3D[Rescale@dat, ColorFunction -> "RainbowOpacity"]

enter image description here

share|improve this answer
add comment

Is this what you want?

MatrixPlot /@ CellularAutomaton[{100 (4 (100 - 1) + 1), {100, 1}, {1, 1}}, 
                                Table[RandomInteger[], {20}, {20}], 1]

Mathematica graphics

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.