private int CountAliveNeighbourCells(CellState[,] grid, int x, int y) { int count = 0; if (aliveBorders) { grid.VisitMooreNeighbours(x, y, false, (neighbourX, neighbourY) => { if (grid.IsInBounds(neighbourX, neighbourY)) { if (grid[neighbourX, neighbourY] == CellState.Alive) { count++; } } else { count++; } }); } else { grid.VisitMooreNeighbours(x, y, true, (neighbourX, neighbourY) => { if (grid[neighbourX, neighbourY] == CellState.Alive) { count++; } }); } return(count); }
private int CountAliveNeighbourCells(int x, int y) { aliveNeighbours = 0; if (config.aliveBorders) { copy.VisitMooreNeighbours(x, y, false, visitAliveBorders); } else { copy.VisitMooreNeighbours(x, y, true, visitDeadBorders); } return(aliveNeighbours); }