Conway's Game of Life Sandbox on PIC32

David Wolfers (dsw247), Ian Riley (ikr5), Connor Thomas (cpt37)

About

This project created a Sandbox for Conway's Game of Life which is manipulated through a Python GUI, run through the PIC32 and course development board, while displaying the progress of the simulation to the TFT screen.

This project was done to encourage others to explore how Conway's Game of Life works and the almosts infinite possiblilties that come with it. We were able to explore many of the fascinating elements of this game when completing this project, and we hope that others can appreciate the fascinating structures and things that can be created.

High Level Description

This project was done so that we could explore and create cool structures within Conway’s Game of Life. However, we also wanted other users to be able to do this, so we decided to create a Sandbox where users can build anything they want on our system.

Conway’s Game of Life has a specific set of rules that it follows:

  • Any live cell with two or three live neighbours survives.
  • Any dead cell with three live neighbours becomes a live cell.
  • All other live cells die in the next generation. Similarly, all other dead cells stay dead.
These rules were directly implemented in our code to update the game. To perform these updates, we iterate over each cell on the screen and check it’s neighbors to see if any of these rules apply. Then the array that holds the status of each cell is updated depending on the rules. When doing neighbor checks, the use array is a copy of the previous state’s statuses. All updates are done only from the previous state and does not take into account any updates that were done to its neighboring cells that would appear in the next generation. This essentially means that all updates are done simultaneously.

In addition to the update rule part of the c-code, there are also threads that allow for use of the ADC to read the update speed dial, and threads that allow for serial communication between the board and the Python GUI that updates the grid size and state of the game. Finally, there’s a main function that initializes all of the threads and starts the game. Separately, there is also a Python GUI which allows users to change the number of cells, change the status of different cells, and place down premade structures that have interesting effects, such as a blinker, or a glider gun.

This project is mostly software based, but we decided to use hardware, specifically a dial, to manipulate the update speed of the game. However, this project could have been entirely software-based. Initially, we had the update speed dial implemented as software in the Python GUI. We decided to change this to hardware because the dial felt a little more satisfying to use and was simple to set up. It also had a nice feature where the value wrapped around. Just by moving the dial a little bit, the speed would go from the slowest speed to the fastest. It was nice to not have to move the dial much to have this effect, while a software slider on the GUI could be more annoying to use. We also implemented a write-back feature where pausing the game would cause the GUI grid to update to the state displayed on the board. To have this done, we had to increase the Baud rate, so offloading the dial to hardware may have also helped to decrease the use of the serial bandwidth.

Components

GUI

Grid Window

C Code

Hardware

Results

An early version of the project, where lines were kept on the screen to separate cells

The Conway’s Game of Life that we implemented fortunately, does not have any features that are interfered with by outside stimulus. It also does not include any parts of it that might be considered dangerous. Conway’s Game of Life does not have any ethical considerations with its creation or use. Our simulation does not provide any utility to those who are blind as it is a visual simulation, and we have not built any usability features for the blind due to this. Otherwise this simulation is visible and requires rudimentary inputs to a computer and spinning a dial to fully manipulate.

Our game was designed to try and eliminate as much variability as possible so that it creates a consistent repeatable simulation. Like in the Boids! project we knew that there could be issues with the updating speeds hurting the frame rate of the simulation, so we took this into consideration as we worked on each step of the project. However, this was a non-issue for us. There are a set number of calculations for each frame of the simulation no matter how many cells are alive at any given point. Even at our most intense number of calculations, the 80 by 60 cell simulation, and our highest speeds determined by the Speed Dial the pick was able to maintain the desired number of updates per second. We did find some latency when adjusting the speed dial though. When adjusting the speed it would take a second (not literally a second but the phrase) to update to the new speed of the dial. However, due to this not impacting the accuracy of the simulation nor did the latency delay for two long, we left it as is without any additional modifications.

When we were implementing the two way communication across the serial there were some time issues with our large grids. If there were too many points in the grid then the serial could not transmit them all back to the GUI in time and data would be lost. This resulted in our GUI and display not matching up. We tried to fix this by increasing the delay so that there would be more time for the serial to transmit this data but this created a long delay (many seconds) and we looked for another solution. In the end we were able to adjust the baud rate so that there was only a minimal delay needed to transmit the data and the two way connection was made very smooth.

The only part of our simulation that is not perfectly consistent with repetition is the speed adjustment dial. It is fairly sensitive with the data it returns to the PIC and can be a little fickle when trying to reproduce a previously used speed. While the speed adjustment dial does require a relatively precise touch to get the exact timing that you may desire, it does work properly on a square root scale. Originally, we used a linear scale, however we switched it so that you can reach all of the desired timings without having as extreme bunching on the extremes. Our game is very accurate and does not have any glitches that we have been able to discover. Not only do the components each communicate with each other quickly and accurately, but, we have no real visual glitches that detract from the user experience.

The final result, running multiple Galaxies on a resolution with many cells

Conclusion

Our design pretty effectively met our expectations. We wanted to simulate Conway’s Game of Life through the PIC32 and display the progression of the game on the TFT screen. We also wanted to create a Python GUI that would allow users to make anything they wanted in the game, in a sort of sandbox. Ultimately, this goal was met. Our GUI allowed users to select any cell to be alive or dead, and it included premade structures that users could place down. Users could also pause the progression of the game and even make changes in the middle. We also included functionality to change how many cells were shown on the screen. However, there were some expectations that we had that were not entirely met. We hoped to implement more freedom with the premade structures. There is no option to place them in a different orientation or rotate them so that they work in a different direction. We had quite a bit of difficulty implementing the pause functionality, so we ran out of time to do this.

Next time, we could make many improvements to the GUI. We could implement an undo button to undo an incorrect placement of one of the premade structures. This would be a good quality of life change because it would no longer require manually removing anything. We could also implement the entire GUI into one window. Currently a separate window must be opened to add things to the grid. It may be better to have everything in one place so it is easier for users. Another improvement could be our dial that affects the speed of updates of the simulation. It currently either operates very quickly or quite slowly. Even though we tried to make the scale smoother, we could spend more time on this to allow noticeably different update speeds.

Our design did conform to acceptable standards. The GUI was mostly easy to use and was intuitive for users. There is no formal standard for this type of project, however. The only real standard is that Conway’s Game of Life operates on a grid. One aspect that the project may not have conformed to typical standards was the implementation of wrap-around on our system. When doing research on Conway’s Game of Life simulators, we did not notice any that had wrap-around features. However, this feature does not significantly change the game, so we thought it would be interesting to allow users to enable and disable wrap-around effects.

This project does not really include any intellectual property considerations. All of our code was original or built based off of code used in this course. Our code implementation of Conway’s Game of Life was original, but of course the rules that govern the game are standard. Our project could be published as another simulator for Conway’s Game of Life, especially since it implements wrap-around features while other simulators do not. However, many other simulators are very good and work in browsers, which is very convenient.

This project did not have any significant ethical concerns. The IEE code of ethics was upheld during completion of this project. There were also not many significant safety concerns. When building the circuit for the update speed dial, caution was taken to avoid shorting incorrect wires that may cause issues. Otherwise, everything was software based, so no one’s safety was at risk. There are also no legal considerations for this project, since our work was original and Conway’s Game Of Life is not proprietary.

Appendix

The group approves this report for inclusion on the course website.

The group approves the video for inclusion on the course youtube channel.

Source Code:

Tasks Breakdown:

  • Connor:
    • Wrote initial game update code
    • Implemented optional wrapping
  • Ian:
    • Made Python GUI
  • David:
    • Wrote initial game update code
    • Implemented parameter updates through serial
    • Built update speed dial circuit

Costs:

    This project had no costs because all parts used were already present in the ECE 4760 lab.