Skip to content

Commit

Permalink
Adapts to games-core API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fathzer committed Feb 26, 2024
1 parent b0e1782 commit 40007e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/main/java/com/fathzer/jchess/generic/ChessBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;

Expand Down Expand Up @@ -137,8 +136,8 @@ public DirectionExplorer getDirectionExplorer(int index) {
}

@Override
public List<Move> getMoves(boolean quiesce) {
return quiesce ? Collections.emptyList() : movesBuilder.getPseudoLegalMoves();
public List<Move> getMoves() {
return movesBuilder.getPseudoLegalMoves();
}

@Override
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/com/fathzer/jchess/generic/ChessBoardTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void testZobristKey() {
void pawnsMoveGenerationTest() {
final ChessBoard board = (ChessBoard) FENUtils.from("r1b1k2r/1p1pqppp/2n2n1b/pP6/4QN2/B2B1P1N/P1pPP1P1/R3K2R b KQkq - 0 1");
final CoordinatesSystem cs = board.getCoordinatesSystem();
final List<Move> blackMoves = board.getMoves(false);
final List<Move> blackMoves = board.getMoves();
assertEquals(Set.of("a4"), getTo(cs, getMoves(cs, blackMoves, "a5")));
assertEquals(Set.of("g5","g6"), getTo(cs, getMoves(cs, blackMoves, "g7")));
assertEquals(Set.of("b6"), getTo(cs, getMoves(cs, blackMoves, "b7")));
Expand All @@ -278,7 +278,7 @@ void pawnsMoveGenerationTest() {
final String fen = "r1b1k2r/1p1pqppp/2n2n1b/pP6/4QN2/B2B1P1N/P1pPP1P1/R3K2R w KQkq a6 0 1";
board.copy(FENUtils.from(fen));
assertEquals(fen, FENUtils.to(board));
final List<Move> whiteMoves = board.getMoves(false);
final List<Move> whiteMoves = board.getMoves();
assertEquals(Set.of("a6","b6","c6"), getTo(cs, getMoves(cs, whiteMoves, "b5")), asString(whiteMoves, board));


Expand Down Expand Up @@ -322,7 +322,7 @@ void kingsMoveGenerationTest() {
assertEquals(Set.of("d1","f1"), getTo(cs ,getMoves(FENUtils.from("4k3/8/8/8/8/3n4/3PP3/4K2R w K - 0 1"), "e1")), "Problem in king move");

// Can castle
List<Move> moves = FENUtils.from("r3kb1r/ppp2ppp/2nqb2n/P2p4/2P1p3/6R1/1PQPPPPP/1NB1KBNR b Kkq - 1 8").getMoves(false);
List<Move> moves = FENUtils.from("r3kb1r/ppp2ppp/2nqb2n/P2p4/2P1p3/6R1/1PQPPPPP/1NB1KBNR b Kkq - 1 8").getMoves();
moves = moves.stream().filter(m->"e8".equals(cs.getAlgebraicNotation(m.getFrom()))).collect(Collectors.toList());
assertEquals(Set.of("c8","d8", "d7", "e7"), getTo(cs, moves));
assertEquals(4, moves.size(), asString(moves, board));
Expand All @@ -333,7 +333,7 @@ void enPassantPinned() {
final Board<Move> board = FENUtils.from("2Q1B3/8/8/KP4p1/1R3pPk/5R2/4P3/8 b - g3 0 1");
List<Move> moves = board.getLegalMoves();
assertTrue(moves.isEmpty(), "Should have no legal moves but obtain "+asString(moves, board));
moves = board.getMoves(false);
moves = board.getMoves();
assertTrue(moves.contains(move(board, "f4", "g3")), "Should contains en-passant move");
}

Expand All @@ -344,7 +344,7 @@ void checkTest() {
// Only king can move
final Board<Move> board = FENUtils.from("r1b1k2r/1p1pqppp/2nN1n1b/pP6/4Q3/B2B1P1N/P1pPP1P1/R3K2R b KQkq - 0 1");
final CoordinatesSystem cs = board.getCoordinatesSystem();
List<Move> moves = board.getMoves(false);
List<Move> moves = board.getMoves();
assertEquals(Set.of("e8"), getFrom(cs, moves), "Only king can move");
assertEquals(Set.of("d8", "f8"), getTo(cs, moves));
}
Expand Down

0 comments on commit 40007e2

Please sign in to comment.