Game of life - input for toad pattern

瘦欲@ 提交于 2020-01-25 03:17:11

问题


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:

  1. 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).
  2. Cells that would come to life outside the grid are ignored.
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!