COMP3201 Assignment 1: Game of Life
Tasks
Write a java program called Sim134.java that simulates the Game of Life.
The user must be able to provide these two parameters as arguments when executing the program from Console (see below):
- The number of iterations as an integer ≥ 0.
- Which pattern type to initialize the cells with:
- R for Random (with 50% chance of each cell starting alive or dead)
- J for Jam (osciallator pattern)
- D for Dart (glider pattern)
Example run command in Console: java Sim134 500 R will run life for 500 iterations, beginning with a random initial pattern of cells.
You must not ask the user to enter the arguments after the program has begun execution, and you must not ask for them in the graphical display.
It's important that you learn how to write programs that accept command line arguments - look at the Code and Demos module in the course shell to see how to do that.
These are the other requirements:
- You must include code comments that explain how your simulation works.
- The simulation must use a graphical display to show the iterations.
- The simulation must implement a square grid of 80 x 80 cells. No other size.
- There must be sufficient delay between each iteration for the user to be able to see what's happening (not too fast, not too slow!)
- The user must be able to see the individual cells (don't draw them too small!)
- The grid must wrap around. See Class Slides #2: "Game of Life: Topology".
Patterns: Initial Layouts and Behaviours
You can place the patterns anywhere in your grid. Top left is usually the easiest location to place them.
Here is the initial layout for the Jam oscillator, and how it should behave when the program runs:
→
And here is the initial layout for the Dart glider, and how it should behave when the program runs:
→
All images above are taken from and © conwaylife.com.
Video Demo
Watch this to get a good idea of what is required:
© Mark Hatcher, Department of Computer Science, Memorial University