Introduction: The Beauty of Math - Conway's Game of Life Art

I've never been in good relationship with math. Especially with high school math. I don't think I'm alone with this problem, am I right? :)

But I cannot deny the importance of mathematics, and when I have the opportunity, I use its results shamelessly. The same is in this article where I decided to present you an attempt to visualize some art created by math and simulated on an Arduino Pro Mini microcontroller module. For this I used a game created by a Cambridge mathematician, John Conway. It's about Conway’s Game of Life.

The first appearance of this concept was in an article by Martin Gardner in the Scientific American (october 1970) - MATHEMATICAL GAMES - The fantastic combinations of John Conway's new solitaire game "life". It is not a game in the strict sense of the word but it is a so-called cellular automaton, a mathematical structure, an observer creates the start structure and follows the structure evolution without any further intervention. This kind of mathematical structures began to be researched since the 1940's when the concept was invented by von Neumann, but only with the appearance of the article in the Scientific American this concept came to the public's attention.

Since then, more and more discoveries have been made in this field, more and more research, and if you search the Internet, you will be completely spoiled when you will see the latest findings in this field of mathematical research. Moreover... WIth this “game” you can simulate complex biological, chemical, social processes… and this cellular automaton can also have applications in computing and cryptography. Insane!

Ok ok

As I have told you, since I don't have too much affinity with math, it is too high for me but I want to show you that math can be beautiful. With a 16x16 RGB LED display available, I'll try to visualize the artificial world from Conway's Game of Life and other ''Life Like" worlds.

Step 1: What Is the Game?

Let's see, first of all, what this game is.

Everything happens in a two-dimensional grid of squares where we start from randomly arranged squares (cells). There may be more or less cells. Each cell can have more or fewer neighbors either horizontally or vertically or on the two diagonals, maximum eight neighbors, as in the picture below.

The following move, state, generation, is established according to three simple rules (in the images there are only some examples not every possible configuration):

If a cell is dead (non-existent on the grid) and has exactly 3 neighbors it will become alive (birth);

If the cell has 2 or 3 neighbors it will live on (it will survive);

In all other cases: less than 2 neighbors (loneliness) or more than three neighbors (overcrowding) the cell will die (will disappear from the grid);

Of course the rules apply at the same time to all cells of a certain generation (before any of the rules are applied). This rule is thus written B3/S23 (birth at 3 neighbors, survival at 2 and 3 neighbors) We will see later that there are many other interesting worlds with other rules.

Step 2: Software

For the software implementation I have adapted Jason Coon’s code, you can find it here on github.

For displaying color effects I used a few color palettes from cpt_city.

After the initialization of some variables and a "cell" class that stores the properties of the 256 possible cells, there are some functions I used in the program:

  • random initialization of the generation Zero - randomFillWorld;
  • calculation of the number of neighbors for a cell in the grid - neighbors;
  • calculation of the order number of the RGB LED in the display matrix - XY;
  • random choice of a new color palette - chooseNewPalette;
  • in the setup function, the random number generator and the display are initialized
  • in the loop function every 256 iterations, the display is deleted, a new generation is initialized, a new color palette is displayed, the cells of generation 0 are displayed, the calculations for the new generation are made, these calculations are saved, and the cycle is resumed.

I have uploaded the source code to github, I hope you will not have problems using it. Some observations:

  • I could not used Jason Coon’s original code due to the memory limitations of the Arduino Pro Mini module, the original code is for teensy 3.1;
  • The rules for calculating the new generation of cells can be changed and the color effects in this way can be drastically changed; Also some initial variables (density, fading_step) can be changed, other color palettes can be used and the color effects will be different in this way also;
  • The display I used is quite small, with a 32x32 pixel display for example, the effects can be much more interesting, of course with another microcontroller (maybe ESP32), with a web control interface, so this project can even become a real art object, a point of attraction of a working or living space :)

Step 3: Hardware

The electronic components used are: an Arduino Pro Mini module, four 8x8 RGB WS2812 arrays and a 5v 1A power supply. The electronic scheme is very simple, you can see it above in the first diagram.

If you decide to increase the number of RGB arrays, say to 16 ( ie a 32x32 pixel display) then you should use a microcontroller module with larger RAM (an Arduino Mega or ESP12) and also a larger power supply: 2.5 - 3A. The RGB LED matrices could be arranged as shown in the second diagram above.

All this electronics can be mounted in a box as in my instructable about chess on the arduino. An interesting plus can be brought if you slightly move away the display from the smoked plexiglas sheet and the paper piece, the LED light will become more blurred and the effect of the changing color patterns will be more organic, more natural, you can see this in the video materials at the next step. In the photos below you can see the Arduino Chess Master display used for this demo :)

Wooden photo frame, smoked plexiglas, piece of paper, plastic frame (10mm height) for moving away the electronic board from the display (as in the second photo).

Title

Step 4: Conclusions

After uploading the software you can play with the birth and survival rules. There are theoretically 218 = 262144 possible Life-like rules, only some of them was studied extensively, many rules are still waiting to be discovered :) These rules can have different notations. I will use the so called Golly/RLE format where the rules are in the form Bx/Sy. The x number next to B ("Born") means how many neighbors are needed for a cell to become (or remain) alive, the y number next to S ("Survive") means how many neighbors are needed for a cell to survive in the next generation. So Conway's Game of Life notation would be in this case B3/S23. From Mirek Wojtowicz Cellular Automata explorer's site I choose seven other rules beside Conway's basic rule, in the source code on github you can see how I coded these rules in the software (simply uncomment the new rule and comment the previous rule used to experiment with them).

Finally you can look at the video materials bellow to see how everything works (turn on closed captions for info).

Non blurred display, four rules

Same rules, but blurred display (with the electronic board mounted away from the displays plexiglas sheet)

Blurred, four other rules

Made with Math Contest

First Prize in the
Made with Math Contest