Inspiration

I created this project as part of an APCS assignment at my school, and I am very proud of how it turned out.

What it does

The game of life uses the following rules to go through multiple generations of bacteria, starting with generation 0: 1) A “neighbor” of a cell is defined as any living cell touching that cell. For example, the eight blue cells in the diagram are the neighbors of the cell in the middle. 2) Any living cell with one or zero neighbors will die of loneliness, while any living cell with four or more living neighbors will die from overcrowding. These are "deaths". 3) Any living cell with two or three neighbors will continue living into the next generation (no change). 4) Any dead cell with exactly three neighbors will come to life in the next generation. These are "births". 5) All births and deaths occur simultaneously.

How I built it

I used 2D arrays to create this game in a grid-like format, while implementing the rules to update the array for each generation. I then created methods to print the board once it is done, go through the next generation, count the number of rows and columns, get the total count, and then run the game of life. In order to get the 0th generation from the text file, I used a scanner to load it into an array, which is used to modify the bacteria for each generation later in the game.

Challenges I ran into

A challenge that I ran into was saving the previous generation while modifying the births and deaths of the next generation. I realized that if I continue changing the array that saves the previous generation, this would alter the bacteria placements when moving on to the next row of the array. Therefore, I realized that I had to create a new 2D array and set every element to dead. While moving through the first array, I had to modify the living elements in the second array and then zero out the first array once I was finished.

Accomplishments that I'm proud of

I'm proud of being able to understand the concept, first of all. This understanding of all the rules and being able to implement them efficiently was one of the hardest parts of creating this program.

What I learned

I learned about how 2D arrays would be practical in creating a game such as this one. Once 2D arrays had been introduced to me, I saw no real practical use for them. However, through this game, I have seen that while 2D arrays may be complicated to loop through in certain ways, they make life much easier when trying to save data table type structures.

What's next for Conway's Game of Life

In the future, I hope to add some of my own rules to the game and watch how this changes the way that bacteria grows or dies.

Built With

Share this project:

Updates