fix duplicates bug
parent
7fcf514d7a
commit
3cf3ad2159
|
|
@ -105,12 +105,25 @@ public class Game {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a list of all legal moveable squares from the current board state.
|
||||||
|
*
|
||||||
|
* @return a List of Square objects representing all legal moveable squares.
|
||||||
|
*/
|
||||||
public List<Square> getAllLegalMoveableSquares() {
|
public List<Square> getAllLegalMoveableSquares() {
|
||||||
return this.board.legalMoves().stream()
|
return this.board.legalMoves().stream()
|
||||||
.map(move -> move.getFrom())
|
.map(move -> move.getFrom())
|
||||||
|
.distinct()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a list of legal moveable squares for a given square.
|
||||||
|
*
|
||||||
|
* @param square the Square from which to retrieve legal moveable squares
|
||||||
|
* @return a List of Square objects representing the legal moveable squares
|
||||||
|
* from the specified square.
|
||||||
|
*/
|
||||||
public List<Square> getLegalMoveableSquares(Square square) {
|
public List<Square> getLegalMoveableSquares(Square square) {
|
||||||
return this.board.legalMoves().stream()
|
return this.board.legalMoves().stream()
|
||||||
.filter(move -> move.getFrom() == square)
|
.filter(move -> move.getFrom() == square)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue