Conway's Game of Life
The applet that you will learn to create in this chapter is shown in Figure 4.1.
Figure 4.1: Conway's Game of Life
CODEBASE = "/code/67/"
CODE = "GameOfLife.class"
NAME = "Applet"
WIDTH = 450
HEIGHT = 330
HSPACE = 0
VSPACE = 0
ALIGN = middle
>
This is "Conway's Game of Life". This is a cellular simulation. The white squares that you see are individual "living" cells. The Game of Life uses a beautifully simple algorithm to decide where new cells should be placed, and old ones removed. The algorithm is as follows.
- Any live cell with fewer than two neighbors dies of loneliness.
- Any live cell with more than three neighbors dies of crowding.
- Any dead cell with exactly three neighbors comes to life.
- Any live cell with two or three neighbors lives, unchanged, to the next generation.
The user is also allowed to interact with the program. First, by clicking the start/stop button the simulation can be started/stopped. Second, the "Randomize" button can be clicked to start over with a new "random"' cell structure.
Additionally, the user can place and remove cells. To do this, click somewhere inside of the "cell grid", which is the area where all of the cells are displayed. This will toggle the presense/absense of a cell.
Though the rules to the Game of Life are very simple, there are many amazing "mini-lifeforms" that can be created.



