Example #1
0
 private int GetAliveNeighbours(Cell cell)
 {
     return CurrentGeneration.Count(neighbour =>
                     ((((Math.Abs(cell.X - neighbour.X) <= 1) && (Math.Abs(cell.Y - neighbour.Y) <= 1)) &&
                     (neighbour.CellValue == CellValue.Alive)) &&
                     (cell != neighbour)));
 }
Example #2
0
 private bool AliveCellWillSurvive(Cell cell)
 {
     return (cell.CellValue == CellValue.Alive && (GetAliveNeighbours(cell) == 2 || (GetAliveNeighbours(cell) == 3)));
 }
Example #3
0
 private bool DeadCellWillBeReborn(Cell cell)
 {
     return (cell.CellValue == CellValue.Dead && (GetAliveNeighbours(cell) == 3 || GetAliveNeighbours(cell) == 6));
 }
Example #4
0
 private bool AliveCellDies(Cell cell)
 {
     return (cell.CellValue == CellValue.Alive && ((GetAliveNeighbours(cell) >= 4) || (GetAliveNeighbours(cell) <= 1))) ;
 }