b'//pjs related preloading, not necessary for standalone processing\n/* @pjs preload="./landscape.jpg"; */\n\n\n// Size of cells\nint cellSize = 1;\n\n// How likely for a cell to be alive at start (in percentage)\nfloat probabilityOfAliveAtStart = 15;\n\n// Variables for timer\nint interval = 100;\nint lastRecordedTime = 0;\n\n// Colors for active/inactive cells\ncolor alive = color(0, 200, 0);\ncolor dead = color(0);\n\n// Array of cells\nint[][] cells;\n// Buffer to record the state of the cells and use this while changing the others in the interations\nint[][] cellsBuffer;\n\n// Pause\nboolean pause = false;\n\nPImage bg;\n\nvoid setup() {\n size (640, 360);\n\n // Instantiate arrays\n cells = new int[width/cellSize][height/cellSize];\n cellsBuffer = new int[width/cellSize][height/cellSize];\n\n // This stroke will draw the background grid\n stroke(0);\n\n noSmooth();\n\n // Initialization of cells\n for (int x=0; x probabilityOfAliveAtStart) {\n state = 0;\n }\n else {\n state = 1;\n }\n cells[x][y] = int(state); // Save state of each cell\n }\n }\n //background(0); // Fill in black in case cells don\'t cover all the windows\n bg = loadImage("landscape.jpg");\n background(bg);\n\n}\n\n\nvoid draw() {\n loadPixels();\n //Draw grid\n for (int x=0; xinterval) {\n if (!pause) {\n iteration();\n lastRecordedTime = millis();\n }\n }\n updatePixels();\n}\n\n\n\nvoid iteration() {\n for (int x=0; x=0)&&(xx=0)&&(yy 3) {\n cells[x][y] = 0; // Die unless it has 2 or 3 neighbours\n }\n }\n else { // The cell is dead: make it live if necessary\n if (neighbours == 3 ) {\n cells[x][y] = 1; // Only if it has 3 neighbours\n }\n } // End of if\n } // End of y loop\n } // End of x loop\n} // End of function\n\nvoid keyPressed() {\n if (key==\' \') { // On/off of pause\n pause = !pause;\n }\n}\n'