Machine Problem 3, due Oct 20
Part of
the assignments for 22C:60, Fall 2004
|
All assignments will be due at the start of class on the day indicated, and unless there is what insurance companies call "an act of God" - something outside your control; the only exceptions to this rule will be by advance arrangement.
In the 1960's, John Conway invented a "game" he called Life; this game is actually a set of rules for a 2-dimensional cellular automaton. Each generation of the game of life is represented as a two-dimensional array where each cell is either dead or alive. The rules for moving from one generation to the next are: If a cell is lonely (it fewer than 2 living neighbors), it dies. If a cell is crowded (it has over 3 living neighbors), it dies. If a dead cell is surrounded by exactly 3 living neighbors, it comes alive. Each cell has a total of 8 neighbors.
See http://www.bitstorm.org/gameoflife/ for a demo and information.
Implement the Game of Life on an array of the dimensions returned by DSPINI. It should animate the generations using X for living cells and blank for dead cells, running continuously until stopped by control C. The initial state should be something that evolves in an interesting way.