MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Cellular Automaton in Mathematica and OOP

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21982] Re: [mg21895] Cellular Automaton in Mathematica and OOP
  • From: "Dr. Andrew A. de Laix" <delaix at wolfram.com>
  • Date: Mon, 7 Feb 2000 13:02:33 -0500 (EST)
  • References: <12387@hack.wri.com>
  • Sender: owner-wri-mathgroup at wolfram.com

It may interest you to know that Stephen Wolfram's long awaited magnum
opus "A New Kind of Science" (http://www.wolframscience.com) has many
pieces of Mathematica code in the notes at the back of the book.

One of the early ones is for doing one-dimensional cellular automata.

Here it is:   (num is Wolfram's standard rule number for "elementary" 1D

cellular automata)

ElementaryRule[num_Integer] := IntegerDigits[num, 2, 8]

CenterList[n_Integer] := ReplacePart[Table[0, {n}], 1, Ceiling[n/2]]

CAStep[rule_List, a_List] := rule[[ 8-ListConvolve[{1,2,4},a,2] ]]

CAEvolveList[rule_List, init_List, t_Integer] := NestList[CAStep[rule,
#]&, init, t]

CAGraphics[history_List] := Graphics[Raster[1 - Reverse[history]],
AspectRatio -> Automatic]

Having set up these definitions, you can make a picture of some of
Stephen Wolfram's favorite cellular automata by doing:

Show[CAGraphics[ CAEvolveList[ElementaryRule[150], CenterList[103], 50]]

]

Show[CAGraphics[ CAEvolveList[ElementaryRule[30], CenterList[103], 50]]
]


An alternative version of CAStep that works in earlier versions than
Mathematica 4 is:

CAStep[rule_,a_]:=rule[[ 8 - (RotateLeft[a] + 2 (a + 2 RotateRight[a]))
]]

Another neat version that uses the rule number directly is
Sign[BitAnd[2^ListConvolve[{1,2,4},a,2],num]].


There are many little Mathematica programming examples like this in
Wolfram's book.

And as it turns out, we're looking right now for experienced Mathematica

programmers who'd like to help us check them, see if they can be
optimized further, and particularly write expositions and explanations
of them that can eventually be used in the web site about the book.

People who might be interested in this should contact me.


Andrew de Laix
Project Leader
Stephen Wolfram Science Group


Johannes Ludsteck wrote:

> Dear mathgroup members.
> Some days ago someone asked whether is is sensible to program
> a complex cellular automaton in Mathematica.
> I started programming a simple cellular automaton in Smalltalk
> (Dolphin Smalltalk 2.1, it's free!) and made the following three
> observations:
>
> 1) You can create a much more intuitive simulation language in
> OOP. The pattern matching strategy in Mathematica may be
> elegant, but the resulting code is not very readable. (See for
> example the walk-rules in the book of Gaylord & D'andria).
>
> 2) The Smalltalk code is five times faster in my simple application.
> This may be an important advantage if the automaton is very
> complex.
>
> 3) Smalltalk provides no visualization tools. Since Mathematica
> provides an rich toolbox of visualization tools, it seems to be
> sensible to run the simulation in Smalltalk and to export them to
> Mathematica in order to visualize them.
>
> I hope, the answer is not to late
>
> Best regards,
>         Johannes Ludsteck
>
> Johannes Ludsteck
> Centre for European Economic Research (ZEW)
> Department of Labour Economics,
> Human Resources and Social Policy
> Phone (+49)(0)621/1235-157
> Fax (+49)(0)621/1235-225
>
> P.O.Box 103443
> D-68034 Mannheim
> GERMANY
>
> Email: ludsteck at zew.de



  • Prev by Date: multiple subscripted variables in NDSolve; dsfun
  • Next by Date: Re: MathLink MLGetRealArray
  • Previous by thread: Cellular Automaton in Mathematica and OOP
  • Next by thread: Re: How to Break[] out of nested loops?