Machine Learning Art
How can we tell stories with code?
Learn to use AI, data and machine learning for your art
This article will be about how to make the Game of Life. If you are interested, then keep reading! 🟣 Subscribe here to never miss another article on AI Art
80 Lines of code? No sweat!

The Game of Life is a game for zero players that follows four simple rules and can end in chaotic, beautiful, and excellent results. This uncomplicated game can even be used to emulate a Turing machine. This fantastic program is one of the oldest computer games still being written about today!
“It’s important that we talk about games. We need them as a medium for artistic expression, as an outlet for our creativity, as an escape from reality.” Dariusz Gross #DATAsculptor
The Game of Life is the mathematical modeling of living beings’ born, evolve, and die. This simulation helps understand how species organize food webs and energy networks. The Game of Life model has also been used by software developers to study how dynamics lead to emergence in natural systems and digital environments.
John Conway’s Game of Life: 1. Each cell is either alive or dead. 2. Each cell interacts with its 8 neighbors. 3. If a cell has 3 or more neighbors, it is alive. 4. If a cell has 2 or fewer neighbors, it is dead.
I will teach you how to create this game independently with only 80 lines of code. p5.js is a JavaScript library for creative coding P5.js is free and accessible to everyone. Whether you’re a beginner or an expert, P5.js has a project for you. It’s free! This library is perfect for creative coding, focusing on making coding accessible and inclusive for artists, designers, educators, beginners, and anyone else!
”In fact, one could argue that games themselves are more like art than anything else.” Dariusz Gross #DATAsculptor
p5.js is easy to use and has many helpful built-in tools like blend shapes and pixel dragging to help you create your art projects. This could be a great way to teach programming skills while making games or animations using p5.js.
Start creating here: Game of Life A basic implementation of John Conway’s Game of Life CA
let w;
let columns;
let rows;
let board;
let next;function setup() {
createCanvas(720, 400);
w = 20;
// Calculate columns and rows
columns = floor(width / w);
rows = floor(height / w);
// Wacky way to make a 2D array is JS
board = new Array(columns);
for (let i = 0; i < columns; i++) {
board[i] = new Array(rows);
}
// Going to use multiple 2D arrays and swap them
next = new Array(columns);
for (i = 0; i < columns; i++) {
next[i] = new Array(rows);
}
init();
}function draw() {
background(255);
generate();
for ( let i = 0; i < columns;i++) {
for ( let j = 0; j < rows;j++) {
if ((board[i][j] == 1)) fill(0);
else fill(255);
stroke(0);
rect(i * w, j * w, w-1, w-1);
}
}}
// reset board when mouse is pressed
function mousePressed() {
init();
}// Fill board randomly
function init() {
for (let i = 0; i < columns; i++) {
for (let j = 0; j < rows; j++) {
// Lining the edges with 0s
if (i == 0 || j == 0 || i == columns-1 || j == rows-1) board[i][j] = 0;
// Filling the rest randomly
else board[i][j] = floor(random(2));
next[i][j] = 0;
}
}
}// The process of creating the new generation
function generate() {// Loop through every spot in our 2D array and check spots neighbors
for (let x = 1; x < columns - 1; x++) {
for (let y = 1; y < rows - 1; y++) {
// Add up all the states in a 3x3 surrounding grid
let neighbors = 0;
for (let i = -1; i <= 1; i++) {
for (let j = -1; j <= 1; j++) {
neighbors += board[x+i][y+j];
}
}// A little trick to subtract the current cell's state since
// we added it in the above loop
neighbors -= board[x][y];
// Rules of Life
if ((board[x][y] == 1) && (neighbors < 2)) next[x][y] = 0; // Loneliness
else if ((board[x][y] == 1) && (neighbors > 3)) next[x][y] = 0; // Overpopulation
else if ((board[x][y] == 0) && (neighbors == 3)) next[x][y] = 1; // Reproduction
else next[x][y] = board[x][y]; // Stasis
}
}// Swap!
let temp = board;
board = next;
next = temp;
}How can we tell stories with code? 1. start on the p5.js website by clicking on the EDITOR button. 2. the window EDITOR opens 3. click on PLAY ( or copy the above code and paste it into the editor) Launching is quite simple : )

Start creating with the p5 Examples
Multiple Particle Systems (Simulate)



Art is all about expression and can be viewed from several perspectives. Gaming is a creative process that broadens the minds of both players and spectators. Both AI art projects and games can go hand in hand to provide an interactive experience that will excite countless people. It is essential to understand the vast differences between AI art projects and gaming to make sense of those differences in meaning, message, execution, etc.
For more interesting AI articles and tutorials, click HERE Machine Learning is making art more accessible
Art is everywhere 🟣 But the question is, how much do you love it?
I am an Art Curator, founder at EvArtology, and ML consultant at MLearning.ai. I advise companies and institutions in the creative industries on using AI tools in their daily work. Human collaboration with ML models can be very creative and bring huge benefits. The new era begins now.
