={<SMOKE>}=
Member
hey guys, i've got this project and i'm just not sure how to set it up... the assignment is as follows:
Game of Life:
Game of Life is a cellular automaton on an infinite rectangular grid. Each grid cell is either alive/on or dead/off. The new state of each cell is computed in discrete steps and is determined by its current state and the number of the live cells among it's surrounding 8 nearest neighboring cells. example:
1 2 3
4 * 5
6 7 8
where * is the cell in question. the rules are as follows:
death: if a live cell has 0 or 1 live neighbors, the cell dies of lonliness, or if a live cell has 4,5,6,7, or 8 live neighbors, the cell dies of overcrowding.
survival: if a live cell has 2 or 3 live neighbors, the cell survives to the next generation.
birth: if a dead cell has 3 live neighbors, the cell becomes alive; otherwise, a dead cell stays dead in the next generation.
For clarity, we display dead cells using '.' and live cells using '|'. for example, a game of life 10 by 10 grid with initial pattern of "cross" would look like:
. . . . | . . . .
. . . . | . . . .
. . . . | . . . .
. . . . | . . . .
| | | | | | | | | |
. . . . | . . . .
. . . . | . . . .
. . . . | . . . .
. . . . | . . . .
note that if a cell is on a boundary, we imagine it raps around...
here are the specifications:
syntax: game pattern
game pattern width height steps(# of generations)
for example: game cross
game cross 10 7 15
note that the "game" "cross" "width" "height" and "steps" are command line arguments.
okay, now my question is this. i must use two classes for this project. one "board" and one "cell". what is the best way to go about this? it seems to me that it would be much easier to use one class, but the specifications are the specifications. can anyone point me in the right direction? any help is appreciated!
ps: i'm not looking for an answer to the overall problem, just what the most efficient way to set up the two classes is.
Game of Life:
Game of Life is a cellular automaton on an infinite rectangular grid. Each grid cell is either alive/on or dead/off. The new state of each cell is computed in discrete steps and is determined by its current state and the number of the live cells among it's surrounding 8 nearest neighboring cells. example:
1 2 3
4 * 5
6 7 8
where * is the cell in question. the rules are as follows:
death: if a live cell has 0 or 1 live neighbors, the cell dies of lonliness, or if a live cell has 4,5,6,7, or 8 live neighbors, the cell dies of overcrowding.
survival: if a live cell has 2 or 3 live neighbors, the cell survives to the next generation.
birth: if a dead cell has 3 live neighbors, the cell becomes alive; otherwise, a dead cell stays dead in the next generation.
For clarity, we display dead cells using '.' and live cells using '|'. for example, a game of life 10 by 10 grid with initial pattern of "cross" would look like:
. . . . | . . . .
. . . . | . . . .
. . . . | . . . .
. . . . | . . . .
| | | | | | | | | |
. . . . | . . . .
. . . . | . . . .
. . . . | . . . .
. . . . | . . . .
note that if a cell is on a boundary, we imagine it raps around...
here are the specifications:
syntax: game pattern
game pattern width height steps(# of generations)
for example: game cross
game cross 10 7 15
note that the "game" "cross" "width" "height" and "steps" are command line arguments.
okay, now my question is this. i must use two classes for this project. one "board" and one "cell". what is the best way to go about this? it seems to me that it would be much easier to use one class, but the specifications are the specifications. can anyone point me in the right direction? any help is appreciated!
ps: i'm not looking for an answer to the overall problem, just what the most efficient way to set up the two classes is.