Cellular-Automata-Wolfram

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

Cellular/Automata/Wolfram version 1.0
=====================================

ABSTRACT

Dr. Steven Wolfram describes in his book, A New Kind of Science, 
ISBN:1-57955-008-8 his path-breaking experiment where he comprehensively 
explored a mathematical function which can be described (by me see the 
reference for a detailed explanation) as follows:

Given an 1d array of numbers A:

[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0]

Call this generation 1 (i.e. t).

Generation 2 (i.e. t+1) will be created by applying a rule to each number of the form A(i)(t+1) = rules(A(i-1)(t),A(i)(t),A(i+1)(t)), where A(i)(t) is the current value at position i for generation t in the array, and A(i)(t+1) is the next generation...

For an array limited to 0 and 1 as possible values in each position
the complete rules function can be described as follows:

Given array rule_input:

[111,110,101,100,011,010,001,000]

This is all the possible values that can be given as inputs to the rule 
function for an 0,1 array of numbers.  The return for the rule function 
can be defined as follows:

[111,110,101,100,011,010,001,000]
  |   |   |   |   |   |   |   |
  0   1   1   0   1   1   1   0

This number 01101110 can be treated as a decimal number expressed as
110, as the result of the following standard binary to decimal formula.
0x128+1x64+1x32+0x16+1x8+1x4+1x2+0x1 = 110.

This number 110 can be used to define the entire rules function that is 
needed
to determine the next generation.

Since all the possbile rules can be described from a eight digit binary 
number 
they run from 0 to 255 decimal, each number describes a different rules 
function and every possible rules function for an array limited to 0 and 1 

and whose input is three values drawn from that array.  The three values 
are
chosen in the formula descibed above.

The choice of i-1, the left adjacent cell, and, i+1, the right adjacent 
cell, as the number of left and right ajacent cells to consider for the 
next 
generation can be defined as radius R.  The number of values each cell can 

take can be described as K (in drawing the number of colors).  The 
examples 
short description is therefore (rule 110, K=2,R=1).  This module allows 
you 
to explore every one dimensional cellular automata for any valid rule for 
a 
given K and R.  The array wraps by default.

The result of rule 110 with K=2 [0,1] R=1 for 80 generations in an array 
of K 
values width 80 where the values wrap:


00000000000000000000000000000000000000010000000000000000000000000000000000000000
00000000000000000000000000000000000000110000000000000000000000000000000000000000
00000000000000000000000000000000000001110000000000000000000000000000000000000000
00000000000000000000000000000000000011010000000000000000000000000000000000000000
00000000000000000000000000000000000111110000000000000000000000000000000000000000
00000000000000000000000000000000001100010000000000000000000000000000000000000000
00000000000000000000000000000000011100110000000000000000000000000000000000000000
00000000000000000000000000000000110101110000000000000000000000000000000000000000
00000000000000000000000000000001111111010000000000000000000000000000000000000000
00000000000000000000000000000011000001110000000000000000000000000000000000000000
00000000000000000000000000000111000011010000000000000000000000000000000000000000
00000000000000000000000000001101000111110000000000000000000000000000000000000000
00000000000000000000000000011111001100010000000000000000000000000000000000000000
00000000000000000000000000110001011100110000000000000000000000000000000000000000
00000000000000000000000001110011110101110000000000000000000000000000000000000000
00000000000000000000000011010110011111010000000000000000000000000000000000000000
00000000000000000000000111111110110001110000000000000000000000000000000000000000
00000000000000000000001100000011110011010000000000000000000000000000000000000000
00000000000000000000011100000110010111110000000000000000000000000000000000000000
00000000000000000000110100001110111100010000000000000000000000000000000000000000
00000000000000000001111100011011100100110000000000000000000000000000000000000000
00000000000000000011000100111110101101110000000000000000000000000000000000000000
00000000000000000111001101100011111111010000000000000000000000000000000000000000
00000000000000001101011111100110000001110000000000000000000000000000000000000000
00000000000000011111110000101110000011010000000000000000000000000000000000000000
00000000000000110000010001111010000111110000000000000000000000000000000000000000
00000000000001110000110011001110001100010000000000000000000000000000000000000000
00000000000011010001110111011010011100110000000000000000000000000000000000000000
00000000000111110011011101111110110101110000000000000000000000000000000000000000
00000000001100010111110111000011111111010000000000000000000000000000000000000000
00000000011100111100011101000110000001110000000000000000000000000000000000000000
00000000110101100100110111001110000011010000000000000000000000000000000000000000
00000001111111101101111101011010000111110000000000000000000000000000000000000000
00000011000000111111000111111110001100010000000000000000000000000000000000000000
00000111000001100001001100000010011100110000000000000000000000000000000000000000
00001101000011100011011100000110110101110000000000000000000000000000000000000000
00011111000110100111110100001111111111010000000000000000000000000000000000000000
00110001001111101100011100011000000001110000000000000000000000000000000000000000
01110011011000111100110100111000000011010000000000000000000000000000000000000000
11010111111001100101111101101000000111110000000000000000000000000000000000000000
11111100001011101111000111111000001100010000000000000000000000000000000000000001



( run in 0.501 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )