Пример #1
0
 /// <summary>
 /// Implementation of the rules of Conway's Game of Life.
 /// Any live cell with fewer than two live neighbors dies, as if caused by under-population.
 ///  Any live cell with two or three live neighbors lives on to the next generation.
 ///  Any live cell with more than three live neighbors dies, as if by over-population.
 ///  Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
 /// </summary>
 /// <param name="cell">Cell in current move</param>
 /// <param name="isAlive">State of cell</param>
 /// <returns>Whether will be given cell alive in next move.</returns>
 private bool WillBeCellAliveInNextTurn(Cell cell,bool isAlive)
 {
     int countOfNeighbors = cell.GetCountOfNeighbors(_cells);
     if (isAlive)
         return countOfNeighbors == 2 || countOfNeighbors == 3;
     return countOfNeighbors == 3;
 }