问题
Can anyone please confirm for game of life:
if inputs
- - - -
- x x x
x x x -
- - - -
and
- x x x
x x x -
are similar . If yes. how ?? please explain.
For background on "game of life" problem .. please refer Toad pattern in game of life it is basically toad pattern input.
回答1:
From a theoretical perspective, the two are identical, since the grid of cells is infinite, and all cells not denoted are assumed to be initially dead.
In practice, however, it depends on how your implementation of Life handles cells that are on the "edge" of the current grid. Depending on the implementation, there are three common ways of treating "edge" cells:
- The grid is expanded to accommodate new cells coming to life outside the current grid (up to some limit, since there is only finite memory available).
- Cells that would come to life outside the grid are ignored.
- Cells on the edges are considered adjacent to the cells on the opposite edge (i.e. the grid wraps around).
If your implementation takes the second or third approach, the patterns will produce different results.
To avoid this confusion, patterns which stay contained within a certain space can be denoted including any necessary initially dead space, so as to avoid the edge problem all together. This is the approach that has been taken in the first pattern.
回答2:
They're similar only in that the inputs look similar. The results are very different:
Pattern 1
- - - -
- x x x
x x x -
- - - -
- - x -
x - - x
x - - x
- x - -
- - - -
- x x x
x x x -
- - - -
Pattern 2
- x x x
x x x -
x - - x
x - - x
- - - -
- - - -
来源:https://stackoverflow.com/questions/12191404/game-of-life-input-for-toad-pattern