
while playing around with processing, trying to learn the fundamentals (if/else/boolean/for/while/{}/arrays/etc.etc.etc) i hadn’t been giving much time to a concept behind the ‘mirrors’ theme. i had been thinking of creating an evolving mirror or a degenerating mirror, something that related to fractal mathematics, maybe even horoscopes… then through experiments with logic sequences, attempting to change rectangle colours in relation to their position and the colour of their neighbours, i was introduced to ‘the game of life’ (not the one pictured above, but the example featured below.)

explanation provided by the wikipedia entry….
“The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.[1] It is the best-known example of a cellular automaton.
The “game” is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input from humans. One interacts with the Game of Life by creating an initial configuration and observing how it evolves.
Rules
The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead. Every cell interacts with its eight neighbors, which are the cells that are directly horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
- Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
- Any live cell with more than three live neighbours dies, as if by overcrowding.
- Any live cell with two or three live neighbours lives on to the next generation.
- Any dead cell with exactly three live neighbours becomes a live cell.
The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths happen simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the one before). The rules continue to be applied repeatedly to create further generations.”
various processing sketches exist playing with the algorithm and changing,tweaking,bastardising the original code as is the way with programming. the one i have chosen to play around with comes courtesy of mr daniel shiffman (see below)…
// Daniel Shiffman, Nature of Code
// <http://www.shiffman.net>
// A basic implementation of John Conway's Game of Life CA
// how could this be improved to use object oriented programming?
// think of it as similar to our particle system, with a "cell" class
// to describe each individual cell and a "cellular automata" class
// to describe a collection of cells
int cellsize = 2;
int COLS, ROWS;
// Game of life board
int[][] old_board, new_board;
void setup()
{
size(200, 200);
smooth();
// Initialize rows, columns and set-up arrays
COLS = width/cellsize;
ROWS = height/cellsize;
old_board = new int[COLS][ROWS];
new_board = new int[COLS][ROWS];
// Call function to fill array with random values 0 or 1
initBoard();
}
void draw() {
background(255);
// Loop through every spot in our 2D array and check spots neighbors
for (int x = 0; x < COLS;x++) {
for (int y = 0; y < ROWS;y++) {
int nb = 0;
// Note the use of mod ("%") below to ensure that cells on the edges have
//"wrap-around" neighbors
// above row
if (old_board[(x+COLS-1) % COLS ][(y+ROWS-1) % ROWS ] == 1) { nb++; }
if (old_board[ x ][(y+ROWS-1) % ROWS ] == 1) { nb++; }
if (old_board[(x+1) % COLS ][(y+ROWS-1) % ROWS ] == 1) { nb++; }
// middle row
if (old_board[(x+COLS-1) % COLS ][ y ] == 1) { nb++; }
if (old_board[(x+1) % COLS ][ y ] == 1) { nb++; }
// bottom row
if (old_board[(x+COLS-1) % COLS ][(y+1) % ROWS ] == 1) { nb++; }
if (old_board[ x ][(y+1) % ROWS ] == 1) { nb++; }
if (old_board[(x+1) % COLS ][(y+1) % ROWS ] == 1) { nb++; }
// RULES OF "LIFE" HERE
if ((old_board[x][y] == 1) && (nb < 2)) { new_board[x][y] = 0; }
//loneliness
else if ((old_board[x][y] == 1) && (nb > 3)) { new_board[x][y] = 0; }
//overpopulation
else if ((old_board[x][y] == 0) && (nb == 3)) { new_board[x][y] = 1; }
//reproduction
else { new_board[x][y] = old_board[x][y];
} //stasis
}
}
// RENDER game of life based on "new_board" values
for ( int i = 0; i < COLS;i++) {
for ( int j = 0; j < ROWS;j++) {
if ((new_board[i][j] == 1)) {
fill(0);
stroke(0);
rect(i*cellsize,j*cellsize,cellsize,cellsize);
}
}
}
// Swap old and new game of life boards
int[][] tmp = old_board;
old_board = new_board;
new_board = tmp;
}
// Init board with random "alive" squares
void initBoard() {
background(0);
for (int i =0;i < COLS;i++) {
for (int j =0;j < ROWS;j++) {
if (int(random(2)) == 0) {
old_board[i][j] = 1;
} else {
old_board[i][j] = 0;
}
}
}
}
// reset board when mouse is pressed
void mousePressed() {
initBoard();
}
as seen in the rules of the ‘game’ it is non-player, the only human interaction comes from the initial setup of the board, i am attempting to have the inbuilt webcam capturing and pixelating the viewer until a keypress/mousepress/other signal, indicates to start the game of life useing the viewers face as the initial setup for the board. something like this…..

and the code (bastardised processing example code)….
import processing.video.*;
int videoScale = 8;
int cols, rows;
Capture video;
void setup() {
size(640,480);
noStroke();
cols = width/videoScale;
rows = height/videoScale;
video = new Capture(this,cols,rows,30);
}
void draw() {
if (video.available()) {
video.read();
}
video.loadPixels();
for (int i = 0; i < cols; i++) {
for (int j = 0; j < rows; j++) {
int x = i*videoScale;
int y = j*videoScale;
int loc = (video.width – i – 1) + j*video.width;
float b = brightness(video.pixels[i + j*video.width]);
if(b>=60){
fill(255);
}else{
fill(0);
}
rect(x,y,videoScale,videoScale);
}
}
}
all i have to do now is get them both working together in harmony, booleans/ifs/ands/and all! then sort out the setup… projected again,size and scale issues.
also i like the way it progresses from the MaxMSP echoes project…a further example of mirrored evolution.
best get on with it. POW!