From 76fd6e76b729331f3bb2124e6f9375c4944d41e6 Mon Sep 17 00:00:00 2001 From: Thanh Le Date: Sun, 5 Nov 2023 11:45:32 +0100 Subject: [PATCH] Add castling test when both rooks at the queen side --- src/main/scala/format/FenReader.scala | 2 +- test-kit/src/test/scala/format/FenTest.scala | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/scala/format/FenReader.scala b/src/main/scala/format/FenReader.scala index 8ba72b6f2..0f5b49d12 100644 --- a/src/main/scala/format/FenReader.scala +++ b/src/main/scala/format/FenReader.scala @@ -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 diff --git a/test-kit/src/test/scala/format/FenTest.scala b/test-kit/src/test/scala/format/FenTest.scala index 7d53c470e..1d93bb61c 100644 --- a/test-kit/src/test/scala/format/FenTest.scala +++ b/test-kit/src/test/scala/format/FenTest.scala @@ -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)