o=. @:

ca110=. 3 (0 1 1 1 0 1 1 0 {~ #.)\ 0 0 , ] , 0:

load_j_ 'graph'
display=. viewmat o (>: o i. o {. o $ |."0 1 ])

200 (display o ((ca110 o ])^:(i. o [)) ) 1

rule=. |. o ((8$2)&#:)
rule 110
0 1 1 1 0 1 1 0

NB. See http://www.jsoftware.com/pipermail/general/2002-July/011652.html
NB. and http://ccl.northwestern.edu/netlogo/models/CA1DRule110

ca=. (((("_)(`({~`#.)))(`:6))\(3:`)((`(0 0 , ] , 0:))(`:6))) ((o])(^:(i. o [)) 
(display o))

200 (rule 30) ca 1
200 (rule 90) ca 1
200 (rule 150) ca 1
512 (rule 137) ca 1
512 (rule 137) ca (?64$2)

________________________________________
From: programming-boun...@jsoftware.com [programming-boun...@jsoftware.com] On 
Behalf Of Marshall Lochbaum [mwlochb...@gmail.com]
Sent: Thursday, December 15, 2011 7:32 AM
To: Programming forum
Subject: Re: [Jprogramming] A one-dimensional cellular automaton

Rule 30 (i.e. replace (1 3 5 6 e.~) with ((8{.|.#:30) {~)) generally looks
the best, because it's chaotic. Rule 110 (same, but with 110) is
interesting because it's Turing complete.

Marshall

On Thu, Dec 15, 2011 at 7:00 AM, Zsbán Ambrus <amb...@math.bme.hu> wrote:

> The following code runs a one-dimensional cellular automaton.
>
> Code runs until interrupted.  You can change the definitions in the
> first two lines to set the scrolling speed of the simulation and the
> number of cells to be simulated (which should be less than the width
> of your terminal so that lines aren't broken).
>
>   sleepamt=: %40
>   columns=: 70
>   sleep=: '/lib/libm.so.6 select > i i x x x *x' (15!:0) 0;0;0;0;
> [:<._ 1e6#:*&1e6
>   0[ (([:sleep]&sleepamt)] [:1!:2&2&.({&' #') 1 3 5 6 e.~ 3 #.\ 0
> 0&,) ^:_]columns$1
> ##
> ###
> ## #
> ####
> ##  #
> ### #
> ## ##
> ######
> ##    #
> ###   #
> ## #  #
> ####  #
> ##  # #
> ### # #
> ## ## #
> #######
> ##     #
> ###    #
> ## #   #
> ####   #
> ##  #  #
> ### #  #
> ...
>
>
> It would be nice if I could use the definition (sleep=: 6!:3) for the
> delays, but that doesn't work because it seems it rounds the time to
> whole seconds.
>
> What's your favorite one-dimensional cellular automaton?  Is there one
> with simple enough rules to code it in one line (such as this one)
> that gives a more interesting output?
>
> Ambrus
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to