Java Programming: ConWay World Conway’s game of life is a simple simulation of life forms in a two dimensional grid. The ConwayCell implements the standard behavior of a call in Conway’s Game of Life. You only need to implement and test two new classes. You will create two different cells, derived from AbstractCell. 1. Alternating Cell The first class that you should create is a class named AlternatingCell. This is a cell that should alternate between being alive and dead with each generation. Add one or more of your AlternatingCells to your ConwayWorld. You can see how to add a cell in line 15 - 20 of Main.java. Give your AlternatingCell a unique display character when it is alive so that you can see it in your conway world.
Java
Conway’s game of life is a simple simulation of life forms in a two dimensional grid. The ConwayCell implements the standard behavior of a call in Conway’s Game of Life. You only need to implement and test two new classes. You will create two different cells, derived from AbstractCell.
1. Alternating Cell
The first class that you should create is a class named AlternatingCell. This is a cell that should alternate between being alive and dead with each generation. Add one or more of your AlternatingCells to your ConwayWorld. You can see how to add a cell in line 15 - 20 of Main.java. Give your AlternatingCell a unique display character when it is alive so that you can see it in your conway world.
2. Your own cell
For the second cell you should feel free to implement any behavior that you want. If you are having trouble thinking of ideas then post up a question.
You can add your custom cell in just a few places in the world, or you might choose to replace all of the ConwayCells with your own cell. If you would like to replace all of the ConwayCells then you'll need to modify the line in the ConwyWorld constructor that instantiates the first ConwayCells:
public ConwayWorld() {
for (int r = 0; r < ROWS; r++) {
for (int c = 0; c < COLS; c++) {
grid[r][c] = new MyCustomCell(r, c, this);
}
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images