public Minefield Explore(Coordinates coordinates) { var grid = Enumerable.Range(0, _height) .Select(rowIndex => ExploreRow(rowIndex, coordinates)).ToList(); return new Minefield(_width, _height, grid); }
/* public int GetBombsInRange(Coordinates coordinate) { int counter = 0; for (int rowCounter = -1; rowCounter <= 1; rowCounter++) { for (int columnCounter = -1; columnCounter <= 1; columnCounter++) { //check for valid index if (InBounds(coordinate.RowIndex + rowCounter, coordinate.ColumnIndex + columnCounter)) { } } } } public bool InBounds(int rowIndex, int columnIndex) { return rowIndex } */ public Minefield ExploreNeighbors(Coordinates coordinates) { return this; }
private IList<bool> ExploreRow(int rowIndex, Coordinates coordinates) { if (rowIndex == coordinates.RowIndex) { return Enumerable.Range(0, _width) .Select(columnIndex => (coordinates.ColumnIndex == columnIndex)? true: _isExplored[rowIndex][columnIndex]) .ToList(); } else { return _isExplored[rowIndex]; } }
/* * * public int GetBombsInRange(Coordinates coordinate) * { * int counter = 0; * for (int rowCounter = -1; rowCounter <= 1; rowCounter++) * { * for (int columnCounter = -1; columnCounter <= 1; columnCounter++) * { * //check for valid index * if (InBounds(coordinate.RowIndex + rowCounter, * coordinate.ColumnIndex + columnCounter)) * { * * } * } * } * } * * public bool InBounds(int rowIndex, int columnIndex) * { * return rowIndex * } */ public Minefield ExploreNeighbors(Coordinates coordinates) { return(this); }