Project 2: Conway’s Game of Life
The purpose of this project was to work with our newly-found knowledge of arrays, a more confined list data structure than an array-list, which we worked with last week. We also learned how to implement a landscape window in Java. We did this in order to illustrate Conway’s game of Life, which represents how cells switch from alive to dead based on their neighbor’s values. Firstly, we had to create the cells and the conditions for whether they lived or died at the next time step; this was the Cell class. In the lab we created a Grid class which created a space for which the cells would be represented. We also created landscape and edited existing LandscapeVisualiztion classes which allowed us to create a window to display the game of life. In conclusion, I created many different lifeSimulation classes in order to view the interesting effects of editing the cell’s parameters
One of the methods in the landscape class was draw, which drew the landscape by calling the draw method found within the Cell class. It used a double for-loop which allowed the method to be called throughout the entriety of the rows and cols within the grid, then the method multiplied the index of the col or grid by the scale of the grid in order to put it in the right place.
For my toString method I created a new string which would be returned later rather than printed because that is what a toString method does. I then looped through the entirety of the grid, adding the values of each index to the string. After the loop, I returned the value of the string, giving me every value in the array.
these are some of the displays that I worked on:
This project was a great dive into visualization in java. It also exposed me to arrays, a data structure that I’m sure will be very useful in the future. It was a lot of fun to ‘see’ my code manifesting itself like in cs151, I made a bunch of different visualizations just for the fun of it knowing I would not get late credit for extensions, because seeing my code come to life for me is the most rewarding part of computer science.
office hours: Layton