public IEnumerable <Cell> GetNeighbours(Cell cell) { var result = new List <Cell>(); for (var row = cell.X - 1; row <= cell.X + 1; row++) { for (var col = cell.Y - 1; col <= cell.Y + 1; col++) { if (CellHelpers.IsValidCell(row, col, size) && (row != cell.X || col != cell.Y)) { result.Add(GetCell(row, col)); } } } return(result); }
public void ComputeWarnCount(Cell[,] cells, int size) { foreach (var cell in cells) { if (cell.IsMine) { continue; } for (var row = cell.X - 1; row <= cell.X + 1; row++) { for (var col = cell.Y - 1; col <= cell.Y + 1; col++) { if (CellHelpers.IsValidCell(row, col, size) && cells[row, col].IsMine) { cell.WarnCount++; } } } } }