Ejemplo n.º 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)));
 }
Ejemplo n.º 2
0
 private bool AliveCellWillSurvive(Cell cell)
 {
     return (cell.CellValue == CellValue.Alive && (GetAliveNeighbours(cell) == 2 || (GetAliveNeighbours(cell) == 3)));
 }
Ejemplo n.º 3
0
 private bool DeadCellWillBeReborn(Cell cell)
 {
     return (cell.CellValue == CellValue.Dead && (GetAliveNeighbours(cell) == 3 || GetAliveNeighbours(cell) == 6));
 }
Ejemplo n.º 4
0
 private bool AliveCellDies(Cell cell)
 {
     return (cell.CellValue == CellValue.Alive && ((GetAliveNeighbours(cell) >= 4) || (GetAliveNeighbours(cell) <= 1))) ;
 }