5x5 Conway's Game Of Life mk1

Post Reply
User avatar
Logickin λ
Posts: 165
Joined: Sat Sep 08, 2018 8:31 pm
Contact:

5x5 Conway's Game Of Life mk1

Post by Logickin λ »

3 neighbors live next to you - you life
4 neighbors live next to you - you die

Such a simple rules, it shows a famous example of cellular automaton:

The Conway's Game of Life
Now we have the miniature version on SunVox!

Chapter 1 - Overview


Just like the original thing, the 5x5 grid followed the rules of Conway's game of life:
1. Any live cell with fewer than two live neighbours dies (referred to as underpopulation or exposure).
2. Any live cell with more than three live neighbours dies (referred to as overpopulation or overcrowding).
3. Any live cell with two or three live neighbours lives, unchanged, to the next generation.
4. Any dead cell with exactly three live neighbours will come to life.

Reference: https://www.conwaylife.com/wiki/Conway%27s_Game_of_Life

This module has the following feature:
- Generation stepped by internal clock or midi input
- Adjustable clock speed
- Random pattern generation

And this is it... Currently this module is just a little fidget toy for fun and doing time, which still has a lot of limitation.
I hope that the future version would provide:
- larger grid size
- Editable pattern

Here is the module:
Logickin Conways Game Of Life 5x5.zip
(20.55 KiB) Downloaded 184 times

Since the readability of the module is much better than the pong game, I can demonstrate how this module works:

Let's move on to Chapter 2 - On the surface

The module contains a few main parts:

Image
1. D flip flops
These flip flops stores the data of current (and previous) generation per row, meaning that each flip flops store the data of 5 cells.
The reason of using 2 group of flip flops is that to prevent race conditions after a new result is calculated and update the life detector immediately, and to give a stable result for display.



Image
2. Clock and midi input
The flips flops are triggered by 2 type of inputs: the midi input from user, which each generation are stepped by every note input; the internal clock, which step each generation automatically in a period of time. The speed of the clock is adjustable so that you can skip boring patter and to slow down for studying the change of the patterns. However, it is not recommended to step manually with either rapidly or with internal clock set to on, because it might break the pattern in an unexpected way.



Image
3. Life detectors
These modules calculates the status of next generation, it takes 3 row (actual a column, but let's assume it is a row for this post) of data, the current row, the row next to the current row and the one before it. After taken the data, the modules will determine either the cells of current row live or not for next generation. I will go through with details for the later chapters of how these things works.



Image
4. Random Pattern Generator
Here is the pattern generator. The generator use a random LFO to determine the number of cells enabled for each rows. When the random pattern generator is in on state, it stops the clock for stepping to prevent data corruption. Then the row data is written sequentially, due to the number of delay block to control the sequence. Once every thing is drawn, flipping the generate back to off statue to resume the internal clock stepping.



Image
5. GPU
To render graphics, the row data is extracted from the first group of D flip flop, then the GPU will break down the data into individual cells and display the cells on the correct position, using the idea of multiplexing which showing each cell individually in cycle rapidly to fake a still image.


Chapter 3 - Enter the rabbit hole
Now we reach the Life Detectors, where calculates the result of next generations.
The Life detector has 3 main stages:

Image
1. Integer to Binary Converter
It takes 3 rows of data in integer, where are the current row, the row previous to the current and the one next to it.
The input is a 5 bit integer, where each cells represents each bit of data:
cell 1 = bit 1 = 1
cell 2 = bit 2 = 2
cell 3 = bit 3 = 4
cell 4 = bit 4 = 8
cell 5 = bit 5 = 16



Image
To break down each bit from the input, the input is subtracted with a series of 2^n number. If the number is larger than 0 after the subtraction, the number will be subtracted by the number corresponding to the stage, by disabling the distortion (the module marked as x[i.] <= 0) which acted as a negative detector and switch on the not gate that represent a bit (a cell); otherwise, the subtraction is not processed and passed the remain value to next stage, while the not gate stay off (as dead state for a cell).



Image
Once the conversion is done, the status of each cell is on the not gate, and ready for the next stage:



Image
2. Core logic of the game of life
This is the core logic of the game of life module, which do separation of signal into 2 channels and comparison for the cell status on the next state.



Image
The middle cell is the cells that we extract from the current rows. They are in boolean.



Image
while the cells that is from previous and the following rows, or the cell that is above and bellow the current cell on the current row, acted as neighbours. The count is in integer (DC offset).



Image
While separated the middle cell to right channel and neighbour to the left channel, the signal are feed into the comparator to determine the cell status of next generation.



Image
And here is the inside of the comparator, where stores the Rule of the Conway's Game of Life:



Here to show the rule in action:
Image
Image
For a dead middle cell, if the neighbour is more (over population) or less (under population) than 3, the middle cell is still considered as dead, which you can see that the output is off.



Image
If there are exact 3 living neighbours, the middle cell will become life. (the output is on)



Image
Image
For a living middle cell, it will still lives on if there are 2 or 3 live neighbours around it.



Image
Image
Other than that, they will be killed by under or over population.



Image
3. Binary to Integer Converter
This is the last stage of the life detector. After finished the calculation, the status of each cells are regulated to the value that each bit of integer should represents. This is similar to the concept of DA convertor, which converts digital binary signal to "analog" signal. The regulated value are summed altogether and are stored into the D flip flops for the next iteration.

That's all about the module, hope you enjoy it.
I know there are something not well explained.
If the explanation is not clear, please comment down below. I will update the post if someone find it confusing.
Last edited by Logickin λ on Wed Aug 03, 2022 6:30 am, edited 1 time in total.
nunrgguy
Posts: 29
Joined: Fri Oct 12, 2018 10:47 pm

Re: 5x5 Conway's Game Of Life mk1

Post by nunrgguy »

Wow, there’s been some work put into that
Post Reply