Ejemplo n.º 1
0
 public bool WouldStayAlive(Point cell)
 {
     var aliveNeighbourCount = GetAliveNeighbourCount(cell);
     return aliveNeighbourCount == 2 || aliveNeighbourCount == 3;
 }
Ejemplo n.º 2
0
 public IEnumerable<Point> GetNeighbours(Point cell)
 {
     int[] d = {-1, 0, 1};
     return d.SelectMany(x => d.Select(y => new Point(cell.X + x, cell.Y + y)))
         .Where(point => (cell.X != point.X) || (cell.Y != point.Y));
 }
Ejemplo n.º 3
0
 public bool WouldRevive(Point cell)
 {
     return GetAliveNeighbourCount(cell) == 3;
 }
Ejemplo n.º 4
0
 public int GetAliveNeighbourCount(Point cell)
 {
     return GetNeighbours(cell).Count(point => Cells.Contains(point));
 }