Skip to content

Commit

Permalink
Add castling test when both rooks at the queen side
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Nov 5, 2023
1 parent 6c0b135 commit 76fd6e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/format/FenReader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ trait FenReader:
val color = Color.fromWhite(ch.isUpper)
val backRank = Bitboard.rank(color.backRank)
// rooks that can be used for castling
val rooks = board.rooks & board(color) & backRank
val rooks = board.rooks & board(color) & backRank
{
for
kingSquare <- (board.kingOf(color) & backRank).first
Expand Down
7 changes: 6 additions & 1 deletion test-kit/src/test/scala/format/FenTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ class FenTest extends ChessTest:
assertEquals(Fen.writeOpening(Fen.read(fen).get), fen)

test("catsling rights with 2 rooks on the same side"):
val fen = Fen.Epd("4k3/8/8/8/8/8/8/4K1RR w K - 0 1")
val fen = Fen.Epd("4k3/8/8/8/8/8/8/4K1RR w K - 0 1")
val situation = Fen.read(Standard, fen).get
assertEquals(situation.legalMoves.filter(_.castles), Nil)

test("catsling rights with 2 rooks on the same side"):
val fen = Fen.Epd("4k3/8/8/8/8/8/8/RR2K3 w Q - 0 1")
val situation = Fen.read(Standard, fen).get
assertEquals(situation.legalMoves.filter(_.castles), Nil)

0 comments on commit 76fd6e7

Please sign in to comment.