Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophivorus committed May 6, 2016
1 parent f1fa297 commit 67d090f
Show file tree
Hide file tree
Showing 392 changed files with 865 additions and 0 deletions.
Binary file added classic/.DS_Store
Binary file not shown.
Binary file added classic/images/.DS_Store
Binary file not shown.
Binary file added classic/images/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/101.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/102.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/103.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/104.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/105.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/106.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/107.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/108.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/109.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/110.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/111.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/112.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/113.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/114.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/115.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/116.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/117.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/118.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/119.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added classic/images/120.png
Binary file added classic/images/121.png
Binary file added classic/images/122.png
Binary file added classic/images/123.png
Binary file added classic/images/124.png
Binary file added classic/images/125.png
Binary file added classic/images/126.png
Binary file added classic/images/127.png
Binary file added classic/images/128.png
Binary file added classic/images/129.png
Binary file added classic/images/13.png
Binary file added classic/images/130.png
Binary file added classic/images/131.png
Binary file added classic/images/132.png
Binary file added classic/images/133.png
Binary file added classic/images/134.png
Binary file added classic/images/135.png
Binary file added classic/images/136.png
Binary file added classic/images/137.png
Binary file added classic/images/138.png
Binary file added classic/images/139.png
Binary file added classic/images/14.png
Binary file added classic/images/140.png
Binary file added classic/images/141.png
Binary file added classic/images/142.png
Binary file added classic/images/143.png
Binary file added classic/images/144.png
Binary file added classic/images/145.png
Binary file added classic/images/146.png
Binary file added classic/images/147.png
Binary file added classic/images/148.png
Binary file added classic/images/149.png
Binary file added classic/images/15.png
Binary file added classic/images/150.png
Binary file added classic/images/151.png
Binary file added classic/images/152.png
Binary file added classic/images/153.png
Binary file added classic/images/154.png
Binary file added classic/images/155.png
Binary file added classic/images/156.png
Binary file added classic/images/157.png
Binary file added classic/images/158.png
Binary file added classic/images/159.png
Binary file added classic/images/16.png
Binary file added classic/images/160.png
Binary file added classic/images/161.png
Binary file added classic/images/162.png
Binary file added classic/images/163.png
Binary file added classic/images/164.png
Binary file added classic/images/165.png
Binary file added classic/images/166.png
Binary file added classic/images/167.png
Binary file added classic/images/168.png
Binary file added classic/images/169.png
Binary file added classic/images/17.png
Binary file added classic/images/170.png
Binary file added classic/images/171.png
Binary file added classic/images/172.png
Binary file added classic/images/173.png
Binary file added classic/images/174.png
Binary file added classic/images/175.png
Binary file added classic/images/176.png
Binary file added classic/images/177.png
Binary file added classic/images/178.png
Binary file added classic/images/179.png
Binary file added classic/images/18.png
Binary file added classic/images/180.png
Binary file added classic/images/181.png
Binary file added classic/images/182.png
Binary file added classic/images/183.png
Binary file added classic/images/184.png
Binary file added classic/images/185.png
Binary file added classic/images/186.png
Binary file added classic/images/187.png
Binary file added classic/images/188.png
Binary file added classic/images/189.png
Binary file added classic/images/19.png
Binary file added classic/images/190.png
Binary file added classic/images/191.png
Binary file added classic/images/192.png
Binary file added classic/images/193.png
Binary file added classic/images/194.png
Binary file added classic/images/195.png
Binary file added classic/images/196.png
Binary file added classic/images/197.png
Binary file added classic/images/198.png
Binary file added classic/images/199.png
Binary file added classic/images/2.png
Binary file added classic/images/20.png
Binary file added classic/images/200.png
Binary file added classic/images/201.png
Binary file added classic/images/202.png
Binary file added classic/images/203.png
Binary file added classic/images/204.png
Binary file added classic/images/205.png
Binary file added classic/images/206.png
Binary file added classic/images/207.png
Binary file added classic/images/208.png
Binary file added classic/images/209.png
Binary file added classic/images/21.png
Binary file added classic/images/210.png
Binary file added classic/images/211.png
Binary file added classic/images/212.png
Binary file added classic/images/213.png
Binary file added classic/images/214.png
Binary file added classic/images/215.png
Binary file added classic/images/216.png
Binary file added classic/images/217.png
Binary file added classic/images/218.png
Binary file added classic/images/219.png
Binary file added classic/images/22.png
Binary file added classic/images/220.png
Binary file added classic/images/221.png
Binary file added classic/images/222.png
Binary file added classic/images/223.png
Binary file added classic/images/224.png
Binary file added classic/images/225.png
Binary file added classic/images/226.png
Binary file added classic/images/227.png
Binary file added classic/images/228.png
Binary file added classic/images/229.png
Binary file added classic/images/23.png
Binary file added classic/images/230.png
Binary file added classic/images/231.png
Binary file added classic/images/232.png
Binary file added classic/images/233.png
Binary file added classic/images/234.png
Binary file added classic/images/235.png
Binary file added classic/images/236.png
Binary file added classic/images/237.png
Binary file added classic/images/238.png
Binary file added classic/images/239.png
Binary file added classic/images/24.png
Binary file added classic/images/240.png
Binary file added classic/images/241.png
Binary file added classic/images/242.png
Binary file added classic/images/243.png
Binary file added classic/images/244.png
Binary file added classic/images/245.png
Binary file added classic/images/246.png
Binary file added classic/images/247.png
Binary file added classic/images/248.png
Binary file added classic/images/249.png
Binary file added classic/images/25.png
Binary file added classic/images/250.png
Binary file added classic/images/251.png
Binary file added classic/images/252.png
Binary file added classic/images/253.png
Binary file added classic/images/254.png
Binary file added classic/images/255.png
Binary file added classic/images/26.png
Binary file added classic/images/27.png
Binary file added classic/images/28.png
Binary file added classic/images/29.png
Binary file added classic/images/3.png
Binary file added classic/images/30.png
Binary file added classic/images/31.png
Binary file added classic/images/32.png
Binary file added classic/images/33.png
Binary file added classic/images/34.png
Binary file added classic/images/35.png
Binary file added classic/images/36.png
Binary file added classic/images/37.png
Binary file added classic/images/38.png
Binary file added classic/images/39.png
Binary file added classic/images/4.png
Binary file added classic/images/40.png
Binary file added classic/images/41.png
Binary file added classic/images/42.png
Binary file added classic/images/43.png
Binary file added classic/images/44.png
Binary file added classic/images/45.png
Binary file added classic/images/46.png
Binary file added classic/images/47.png
Binary file added classic/images/48.png
Binary file added classic/images/49.png
Binary file added classic/images/5.png
Binary file added classic/images/50.png
Binary file added classic/images/51.png
Binary file added classic/images/52.png
Binary file added classic/images/53.png
Binary file added classic/images/54.png
Binary file added classic/images/55.png
Binary file added classic/images/56.png
Binary file added classic/images/57.png
Binary file added classic/images/58.png
Binary file added classic/images/59.png
Binary file added classic/images/6.png
Binary file added classic/images/60.png
Binary file added classic/images/61.png
Binary file added classic/images/62.png
Binary file added classic/images/63.png
Binary file added classic/images/64.png
Binary file added classic/images/65.png
Binary file added classic/images/66.png
Binary file added classic/images/67.png
Binary file added classic/images/68.png
Binary file added classic/images/69.png
Binary file added classic/images/7.png
Binary file added classic/images/70.png
Binary file added classic/images/71.png
Binary file added classic/images/72.png
Binary file added classic/images/73.png
Binary file added classic/images/74.png
Binary file added classic/images/75.png
Binary file added classic/images/76.png
Binary file added classic/images/77.png
Binary file added classic/images/78.png
Binary file added classic/images/79.png
Binary file added classic/images/8.png
Binary file added classic/images/80.png
Binary file added classic/images/81.png
Binary file added classic/images/82.png
Binary file added classic/images/83.png
Binary file added classic/images/84.png
Binary file added classic/images/85.png
Binary file added classic/images/86.png
Binary file added classic/images/87.png
Binary file added classic/images/88.png
Binary file added classic/images/89.png
Binary file added classic/images/9.png
Binary file added classic/images/90.png
Binary file added classic/images/91.png
Binary file added classic/images/92.png
Binary file added classic/images/93.png
Binary file added classic/images/94.png
Binary file added classic/images/95.png
Binary file added classic/images/96.png
Binary file added classic/images/97.png
Binary file added classic/images/98.png
Binary file added classic/images/99.png
65 changes: 65 additions & 0 deletions classic/index.php
Original file line number Diff line number Diff line change
@@ -0,0 1,65 @@
<?php

error_reporting( E_ALL );

ini_set( 'display_errors', 1 );
ini_set( 'memory_limit', '1024M' );
ini_set( 'max_execution_time', '9999' );

for ( $rule = 0; $rule <= 255; $rule ) {

$width = 256;
$height = 128;

$image = imagecreatetruecolor( $width, $height );

$color = imagecolorallocate( $image, 255, 255, 255 );

imagesetpixel( $image, $width / 2, 0, $color ); // Draw the initial cell

$current = array( $width / 2 );
$next = array();

for ( $y = 0; $y < $height; $y ) {

// We need to calculate from way before the start of the image until way before the end
// because if not the code will asume that everything beyond the image is just black
// but under many rules it isn't
for ( $x = -$width; $x < $width * 2; $x ) {

$left = in_array( $x - 1, $current );
$center = in_array( $x, $current );
$right = in_array( $x 1, $current );

$binary = sprintf( "d", decbin( $rule ) ); // Convert to binary keeping the leading zeros

if ( $left and $center and $right ) {
$state = $binary[0];
} else if ( $left and $center and !$right ) {
$state = $binary[1];
} else if ( $left and !$center and $right ) {
$state = $binary[2];
} else if ( $left and !$center and !$right ) {
$state = $binary[3];
} else if ( !$left and $center and $right ) {
$state = $binary[4];
} else if ( !$left and $center and !$right ) {
$state = $binary[5];
} else if ( !$left and !$center and $right ) {
$state = $binary[6];
} else if ( !$left and !$center and !$right ) {
$state = $binary[7];
}

if ( $state == 0 ) {
continue;
} else if ( $state == 1 ) {
imagesetpixel( $image, $x, $y 1, $color );
}
$next[] = $x;
}
$current = $next;
$next = array();
}
imagepng( $image, "images/$rule.png" );
}
Binary file added failed-but-interesting/.DS_Store
Binary file not shown.
78 changes: 78 additions & 0 deletions failed-but-interesting/Image.php
Original file line number Diff line number Diff line change
@@ -0,0 1,78 @@
<?php

class Image {

public $width;
public $height;
public $image;
public $color;

function __construct( $width, $height ) {
$this->width = $width;
$this->height = $height;
$this->image = imagecreatetruecolor( $width, $height );
}

function save( $filename ) {
imagepng( $this->image, $filename );
return $this;
}

function draw() {
header( 'Content-Type: image/png' );
imagepng( $this->image );
return $this;
}

function destroy() {
imagedestroy( $this->image );
return null; //Or return $this?
}

function __destruct() {
$this->destroy();
}

//Drawers

function drawPoint( $x, $y ) {
return imageline( $this->image, $x, $y, $x, $y, $this->color );
}

function drawLine( $x1, $y1, $x2, $y2 ) {
return imageline( $this->image, $x1, $y1, $x2, $y2, $this->color );
}

function drawArc( $cx, $cy, $width, $height, $start, $end ) {
return imagearc( $this->image, $cx, $cy, $width, $height, $start, $end, $this->color );
}

function drawCircle( $x, $y, $radius ) {
return imagearc( $this->image, $x, $y, $radius * 2, $radius * 2, 0, 0, $this->color );
}

function drawRectangle( $x1, $y1, $x2, $y2 ) {
return imagerectangle( $this->image, $x1, $y1, $x2, $y2, $this->color );
}

function drawString( $string, $x = 0, $y = 0, $font = 0 ) {
return imagestring( $this->image, $font, $x, $y, $string, $this->color );
}

//Getters

function getWidth() {
return imagesx( $this->image );
}

function getHeight() {
return imagesy( $this->image );
}

//Setters

function setColor( $red, $blue, $green ) {
$this->color = imagecolorallocate( $this->image, $red, $blue, $green );
return $this;
}
}
Binary file added failed-but-interesting/images/.DS_Store
Binary file not shown.
Binary file added failed-but-interesting/images/0.png
Binary file added failed-but-interesting/images/100.png
Binary file added failed-but-interesting/images/10500.png
Binary file added failed-but-interesting/images/10700.png
Binary file added failed-but-interesting/images/11500.png
Binary file added failed-but-interesting/images/1200.png
Binary file added failed-but-interesting/images/12300.png
Binary file added failed-but-interesting/images/12600.png
Binary file added failed-but-interesting/images/12900.png
Binary file added failed-but-interesting/images/13400.png
Binary file added failed-but-interesting/images/13600.png
Binary file added failed-but-interesting/images/13700.png
Binary file added failed-but-interesting/images/14000.png
Binary file added failed-but-interesting/images/14200.png
Binary file added failed-but-interesting/images/1500.png
Binary file added failed-but-interesting/images/15000.png
Binary file added failed-but-interesting/images/15500.png
Binary file added failed-but-interesting/images/16500.png
Binary file added failed-but-interesting/images/17000.png
Binary file added failed-but-interesting/images/17200.png
Binary file added failed-but-interesting/images/17800.png
Binary file added failed-but-interesting/images/1800.png
Binary file added failed-but-interesting/images/2500.png
Binary file added failed-but-interesting/images/3200.png
Binary file added failed-but-interesting/images/3400.png
Binary file added failed-but-interesting/images/3600.png
Binary file added failed-but-interesting/images/4200.png
Binary file added failed-but-interesting/images/4300.png
Binary file added failed-but-interesting/images/5200.png
Binary file added failed-but-interesting/images/5600.png
Binary file added failed-but-interesting/images/6100.png
Binary file added failed-but-interesting/images/6400.png
Binary file added failed-but-interesting/images/6600.png
Binary file added failed-but-interesting/images/7500.png
Binary file added failed-but-interesting/images/8200.png
Binary file added failed-but-interesting/images/8600.png
80 changes: 80 additions & 0 deletions failed-but-interesting/index.php
Original file line number Diff line number Diff line change
@@ -0,0 1,80 @@
<?php

require 'Image.php';

// There are 19682 possible rules
$RULES = array( 0, 100, 1200, 1500, 1800, 2500, 3200, 3400, 3600, 4200, 4300, 5200, 5600, 6100, 6400, 6600, 7500, 8200, 8600, 10500, 10700, 11500, 12300, 12600, 12900, 13400, 13600, 13700, 14000, 14200, 15000, 15500, 16500, 17000, 17200, 17800 );

foreach ( $RULES as $key => $rule ) {

$ROW = array();
$ROWS = array();

$rule = base_convert( $rule, 10, 3 ); //Convert to ternary
$rule = str_pad( $rule, 9, 0, STR_PAD_LEFT ); //Add leading zeroes

$width = 1000;
$height = 1000;

//Define the first row
$ROW[ 0 ] = 2;
$ROWS[ 0 ] = $ROW;

//Calculate the rest
for ( $y = 1; $y < $height; $y ) {

$PREVIOUS = $ROWS[ $y - 1 ];

for ( $x = 0; $x < $width; $x ) {

if ( $PREVIOUS[ $x ] == 2 and $PREVIOUS[ $x - 1 ] == 2 )
$CURRENT[ $x ] = $rule[ 0 ];

if ( $PREVIOUS[ $x ] == 2 and $PREVIOUS[ $x - 1 ] == 1 )
$CURRENT[ $x ] = $rule[ 1 ];

if ( $PREVIOUS[ $x ] == 2 and $PREVIOUS[ $x - 1 ] == 0 )
$CURRENT[ $x ] = $rule[ 2 ];

if ( $PREVIOUS[ $x ] == 1 and $PREVIOUS[ $x - 1 ] == 2 )
$CURRENT[ $x ] = $rule[ 3 ];

if ( $PREVIOUS[ $x ] == 1 and $PREVIOUS[ $x - 1 ] == 1 )
$CURRENT[ $x ] = $rule[ 4 ];

if ( $PREVIOUS[ $x ] == 1 and $PREVIOUS[ $x - 1 ] == 0 )
$CURRENT[ $x ] = $rule[ 5 ];

if ( $PREVIOUS[ $x ] == 0 and $PREVIOUS[ $x - 1 ] == 2 )
$CURRENT[ $x ] = $rule[ 6 ];

if ( $PREVIOUS[ $x ] == 0 and $PREVIOUS[ $x - 1 ] == 1 )
$CURRENT[ $x ] = $rule[ 7 ];

if ( $PREVIOUS[ $x ] == 0 and $PREVIOUS[ $x - 1 ] == 0 )
$CURRENT[ $x ] = $rule[ 8 ];
}

$ROWS[ $y ] = $CURRENT;
}

$image = new Image( $width, $height );

foreach ( $ROWS as $y => $ROW ) {
foreach ( $ROW as $x => $value ) {
if ( $value == 1 ) {
$image->setColor( 0, 200, 0 );
$image->drawPoint( $x, $y );
}
if ( $value == 2 ) {
$image->setColor( 200, 0, 0 );
$image->drawPoint( $x, $y );
}
}
}

//$image->draw();

$rule = base_convert( $rule, 3, 10 );
$image->save( $rule . '.png' );
}
Binary file added only-left-and-right-ternary/.DS_Store
Binary file not shown.
Loading

0 comments on commit 67d090f

Please sign in to comment.