Conway's Game of Life
- A small life simulation
- Written in C++
- Solo
- Source on GitHub
Description and Responsibility
The goal of this project was to practice graphics and C++ programming, and learn about cellular automata by implementing Conway's Game of Life.
Design Process
After deciding on a graphics library (SFML), my first goal was to create a grid pattern on the screen. I wanted to make the pattern generate dynamically when the program loaded rather than in a hard-coded fashion to allow for more or less dense grids in the future. Once the grid was completed, I added interactivity to it to allow the user to toggle cells on or off.
Once the grid was complete, I began work on the actual simulation. I initially made the mistake in iterating and modifying the grid at the same time, which lead to the simulation not working at all. After some additional research, I learned that each step in the simulation requires iterating over an unchanged copy of the grid, then applying those changes to the displayed grid. Once this was correctly implemented, the simulation was working as expected.
One issue after completing this was the simulation was moving way faster than what was usable. I implemented (by making use of code by one of SFML's team members, Mario) this timestep solution. This brought the simulation to acceptable speeds.
After some changes (such as allowing the simulation to wrap around the window), I restructured the project's code. From the problems I had with implementing the simulation, some parts of the grid and simulation code were mixed. In addition, the main function was cluttered with SFML rendering necessities and my own simulation logic. After making these changes, it was a lot easier to understand the logic of the system at a glance and make changes.
The final changes I made were to add randomly generated fills to the grid and add a camera to zoom and pan the simulation.
Screenshots