Jacob Kessinger

From www.norsemathology.org

Jump to: navigation, search

Contents

Conway's Game of Life

Predictably enough, Conway's Game of Life was created by John Conway. It's a small game with only a few rules. It begins with a grid of squares that can either be created manually or randomly. Each square has two states, alive or dead. If a live square has less than 2 alive neighboring squares or more than 3 alive neighboring squares, then it dies. If a dead square has exactly 3 neighboring squares, then it becomes alive.

Each square is supposed to represent a population. If a live square has fewer than 2 alive neighbors, then it dies due to underpopulation. If a live square has more than 3 alive neighbors, then it dies due to overpopulation. A dead square becomes populated if it has 3 neighbors due to reproduction.

At its core, the Game of Life is a recursive algorithm. The current board is used to find the next board, and the board after is dependent upon the next board.

My Implementation

I recreated the Game of Life using C++ and SDL2, which stands for Simple DirectMedia Library 2.0. I used a 2-dimensional array filled with booleans, values that are either true or false. Each boolean in the array represents the state of one square. True means that the square is alive, and false means that the square is dead.

After randomly determining which squares are alive, I used SDL2 to draw the board in a window. Yellow squares are alive and white squares are dead. For every update, I used a function to determine which squares live and die. To do this, I created another 2-dimensional array to represent the new board. Each square's neighbors would be examined and the square updated according to the rules. Afterward, the new board would be drawn.

I added a counter to stop the program after 1000 iterations; otherwise, the game would go on forever.

The most notable difference between my implementation and the original game is the fact that I included an option to change the minimum and maximum values for underpopulation and overpopulation.


The Experiment

For this project, I wanted to examine how changing the rules would change the board state after 1000 iterations. I modified the rules for underpopulation and overpopulation and allowed the game to run.

In each of the games I ran, I randomly generated the starting board with each square has a 30% chance of beginning the game alive.


For the original ruleset, the most common outcome was as shown in the first picture. In this state, little to no change is seen going forward. Most of the structures are in such a way that they are stable. This state was reached most commonly near the end of the 1000 iterations.


In the first modified ruleset, an alive square would die if it had less than 2 or more than 4 alive neighbors. A dead square could live if it had 4 alive neighbors. The game reached a stable state much quicker, within about 100 iterations. This is due to the leniency of being alive. Unlike the original rules, it is harder for squares to die so they die less frequently. This is reflected in the fact that the end result appears to be similar to the starting state. However, in the original rules, the ending state was far different from the starting state.


In the next modified ruleset, I required less than 3 or more than 4 alive neighbors for a square to die. A dead square could live if it had 4 neighbors. The result is a combination of the previous results. Similar to the second set of rules, a stable state was reached very quickly. However, the ending state was much different than the beginning state. It is more difficult for squares to survive in this ruleset due to a narrow window for life and more squares being required for sustained life. This resulted in a large number of squares dying very quickly with a few lucky squares living on in stable formations.


In the final modified ruleset, having less than 1 or more than 2 alive neighbors results in a square dying. A dead square would live if it had exactly 2 neighbors. I ran 10 trials with this ruleset with each stopping at 1000 iterations, no trial reached a stable state. This is likely due to the low requirement for dead squares to live. The new life that emerged after each iteration only caused more cells to live and die. The other rulesets had a relatively high requirement for life, resulting in more squares dying than those being revived. This ultimately forced the game into a stable state. However, the opposite occurred with this ruleset, with new life emerging fast enough to prevent the game from becoming stable.


Program

This is the source code for my version of Conway's Game of Life: Media:KessingerMAT385_conwayCode.pdf

Personal tools