public RowCol FindAdjacentEmptyCell(BattleshipBoard board) { RowCol AdjacentEmptyCell; bool IsAdjacentEmpty() { return(AdjacentEmptyCell.IsValid() && board.findPossibleTarget(AdjacentEmptyCell)); } AdjacentEmptyCell = new RowCol(Row + 1, Col); if (IsAdjacentEmpty()) { return(AdjacentEmptyCell); } AdjacentEmptyCell = new RowCol(Row, Col + 1); if (IsAdjacentEmpty()) { return(AdjacentEmptyCell); } AdjacentEmptyCell = new RowCol(Row - 1, Col); if (IsAdjacentEmpty()) { return(AdjacentEmptyCell); } AdjacentEmptyCell = new RowCol(Row, Col - 1); if (IsAdjacentEmpty()) { return(AdjacentEmptyCell); } return(new RowCol(-1, -1)); }