How to Make the Conway's Game of Life Cellular Automaton
Since a cellular automaton produces visual phenomena, you will need to use a programming language in which you know how to render graphics to the screen., Assuming that you have a programming language in which you know how to create simple graphics...
Step-by-Step Guide
-
Step 1: Since a cellular automaton produces visual phenomena
It doesn't have to be anything fancy
- just blobs will do for the Game of Life.
It may also be possible to render the Game of Life as text characters on a terminal. , The Game of Life is a two-dimensional grid of cells, each of which can either be ON or OFF.
Every timestep (normally called a 'generation'), every cell in the grid is checked, and it is turned ON or OFF depending on the rules of the CA.
The rules of the Game of Life will be explained later.
This yields a new configuration of the CA.
The process then repeats, such that the configuration of the CA keeps changing after every timestep.
The result is surprisingly complex, and the shifting patterns of cells are often compared to the behaviour of single-celled organisms. , The easiest way to model this is as a two-dimensional array.
You can use any datatype you want, although since the Game of Life's cells have only two states, you only need a boolean datatype (ie.
TRUE for ON, FALSE for OFF)., For example, if you have 100x100 cells, and you want the grid on screen to stretch from screen coordinates (0,0) to (600, 600), then the cell at index should be placed at position (x*6, y*6).
You can represent the cells however you like: for example, filled blue blobs for ON cells, white blobs for OFF cells.,, If an ON cell has fewer than 2 cells surrounding it as described above, it becomes OFF.
If an ON cell has more than 3 cells surrounding it, it becomes OFF. ,,, However, you won't see anything unless you provide an initial generation of ON cells for it to work from, since OFF cells don't do anything by themselves in the Game of Life.
A suggestion for that is made below., For example, how about 'all cells with one ON cell next to them become ON'? -
Step 2: you will need to use a programming language in which you know how to render graphics to the screen.
-
Step 3: Assuming that you have a programming language in which you know how to create simple graphics
-
Step 4: the first task is to understand what a cellular automaton looks like and how it evolves over time.
-
Step 5: That's basically all the Game of Life is - just a 2D grid of cells.
-
Step 6: To draw this grid to the screen
-
Step 7: you need a double-nested loop which reads each cell
-
Step 8: calculating each position depending on its place in the grid.
-
Step 9: You will then need a loop which constantly reads the cells and generates the next generation from them using the Game of Life's rules.
-
Step 10: The rules of the Game of Life are as follows: If a cell (whether ON or OFF) has exactly 2 or 3 ON cells in the 8 cells surrounding it
-
Step 11: then that cell becomes (or remains) ON.
-
Step 12: After the new generation has been created
-
Step 13: it should replace the old one and become the current generation.
-
Step 14: Now the process repeats: clear the screen
-
Step 15: redraw the grid
-
Step 16: calculate the next generation as described above.
-
Step 17: That's it!
-
Step 18: Once you've got it working and have had fun watching it
-
Step 19: you might want to try making your own rules.
Detailed Guide
It doesn't have to be anything fancy
- just blobs will do for the Game of Life.
It may also be possible to render the Game of Life as text characters on a terminal. , The Game of Life is a two-dimensional grid of cells, each of which can either be ON or OFF.
Every timestep (normally called a 'generation'), every cell in the grid is checked, and it is turned ON or OFF depending on the rules of the CA.
The rules of the Game of Life will be explained later.
This yields a new configuration of the CA.
The process then repeats, such that the configuration of the CA keeps changing after every timestep.
The result is surprisingly complex, and the shifting patterns of cells are often compared to the behaviour of single-celled organisms. , The easiest way to model this is as a two-dimensional array.
You can use any datatype you want, although since the Game of Life's cells have only two states, you only need a boolean datatype (ie.
TRUE for ON, FALSE for OFF)., For example, if you have 100x100 cells, and you want the grid on screen to stretch from screen coordinates (0,0) to (600, 600), then the cell at index should be placed at position (x*6, y*6).
You can represent the cells however you like: for example, filled blue blobs for ON cells, white blobs for OFF cells.,, If an ON cell has fewer than 2 cells surrounding it as described above, it becomes OFF.
If an ON cell has more than 3 cells surrounding it, it becomes OFF. ,,, However, you won't see anything unless you provide an initial generation of ON cells for it to work from, since OFF cells don't do anything by themselves in the Game of Life.
A suggestion for that is made below., For example, how about 'all cells with one ON cell next to them become ON'?
About the Author
Larry Webb
Specializes in breaking down complex lifestyle topics into simple steps.
Rate This Guide
How helpful was this guide? Click to rate: