";
echo ".on { width: ". $fillW ."px; height: ". $fillH ."px; }";
echo ".off { width: ". $fillW ."px; height: ". $fillH ."px; }";
echo "\n";
/*
1 Rule contains 8 Choices
Choice Table
------- ------- -------
| | | |
| A | B | C |
| | | |
------- ------- -------
| |
| X |
| |
-------
*/
//echo "";
// Create 8 Choices (Read it Backward)
for( $bit = 7; $bit >= 0; $bit -- )
{
$bitNeg = ((( $bit + 1 ) * - 1 ) + 8 );
// Each Choice has 3 cells
$choice = str_pad( decbin( $bit ), 3, "0", STR_PAD_LEFT );
//echo " | $bit, $choice | ";
for( $j = 0; $j < 3; $j ++ )
{
$choiceCell = $choice[ $j ];
//echo "^^ $choiceCell ";
$xNew = $xOffset + ($j * $cellW) + ($bitNeg * 20) + ($xMax * $cellW) - ((24+6) * $cellW);
$yNew = $yOffset - ($cellW * 4);
if( $choiceCell > 0 )
{
echo "
";
echo "RULE ". $rule ."
\n\n\n\n";
// Initialize first row to zero
for( $i = 0; $i <= $xMax; $i ++ )
{
$cell[ $i ][0] = 0;
};
// Insert genesis cells
// Middle Cell
$cell[(int)($xMax/2)+1][0] = 1;
// Random Cells
$randomWhile = $random;
while ($randomWhile--) {
$cell[rand(0, $xMax)][0] = 1;
}
// WHIP IT GOOD!!
for ($y = 0; $y < $yMax+1; $y++) {
echo " \n";
for ($x = 1; $x < $xMax+1; $x++) {
if ($y > 0) {
// Get parents' values
$a = str_pad($cell[$x-1][$y-1], 1, "0", STR_PAD_LEFT );
$b = str_pad($cell[$x ][$y-1], 1, "0", STR_PAD_LEFT );
$c = str_pad($cell[$x+1][$y-1], 1, "0", STR_PAD_LEFT );
$abc = $a.$b.$c;
$bit = binDec($abc);
$cell[$x][$y] = $ruleVal[$bit];
}
$xNew = $x * $cellW + $xOffset;
$yNew = $y * $cellH + $yOffset;
if ($cell[$x][$y]) {
echo "
8-BIT CELLULAR AUTOMATA
This small () 8B-CA generator is based on work presented by
Stephen Wolfram in his book
A New Kind of Science. It demonstrates the ability of certain simple systems to manifest great complexity. For instance RULE 30 creates areas of texture that do not repeat and cannot be predicted ahead of the execution of the rule. Wolfram argues that this behavior is the essence of randomness. (This is similar to claiming that the distribution of prime numbers is random although numbers themselves do not spontaneously change between prime and composite.)
Each RULE consists of 8 outcomes, one for each of the 8 possible states of 3 consecutive ON/OFF cells. The 8 outcomes of a rule are either ON (1) or OFF (0), yielding an 8 digit binary number (8 bits) and 256 possible rules (0 to 255 inclusive). For the execution of a rule each cell's immediate predecessor and predecessor's neighbors are examined (3 consecutive cells). The rule dictates what the outcome will be for each of the 8 possible states of 3 consecutive cells. This is applied to each cell, row by row.
See more projects at
stewd.io.
SELECT RULE (0–255)
ADOBE ILLUSTRATOR
Generate
Adobe Illustrator 3 file.
Save output text with a ".ai" extension then open in Adobe Illustrator 3 or higher.