Implement Search
This commit is contained in:
@@ -224,6 +224,18 @@ TEST_CASE_PSEUDO_MOVES("Pseudo-legal bishop moves, empty board", "[Bishop]") {
|
||||
);
|
||||
}
|
||||
|
||||
TEST_CASE_PSEUDO_MOVES("Pseudo-legal bishop moves, empty board side", "[Bishop]") {
|
||||
testPseudoLegalMoves(
|
||||
// https://lichess.org/editor/B7/8/8/8/8/8/8/8_w_-_-_0_1
|
||||
"B7/8/8/8/8/8/8/8 w - - 0 1",
|
||||
"a8",
|
||||
{
|
||||
"b7", "c6", "d5",
|
||||
"e4", "f3", "g2", "h1"
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
TEST_CASE_PSEUDO_MOVES("Pseudo-legal bishop moves, captures", "[Bishop]") {
|
||||
testPseudoLegalMoves(
|
||||
// https://lichess.org/editor/8/8/1p3P2/8/3B4/8/8/8_w_-_-_0_1
|
||||
@@ -252,6 +264,41 @@ TEST_CASE_PSEUDO_MOVES("Pseudo-legal rook moves, empty board", "[Rook]") {
|
||||
);
|
||||
}
|
||||
|
||||
TEST_CASE_PSEUDO_MOVES("Pseudo-legal rook moves, empty board side", "[Rook]") {
|
||||
testPseudoLegalMoves(
|
||||
// https://lichess.org/editor/3R4/8/8/8/8/8/8/8_w_-_-_0_1
|
||||
"3R4/8/8/8/8/8/8/8 w - - 0 1",
|
||||
"d8",
|
||||
{
|
||||
"d1", "d2", "d3", "d4", "d5", "d6", "d7",
|
||||
"a8", "b8", "c8",
|
||||
"e8", "f8", "g8",
|
||||
"h8"
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST_CASE_PSEUDO_MOVES("legal rook moves, king check", "[Rook]") {
|
||||
testPseudoLegalMoves(
|
||||
// https://lichess.org/editor/5R1k/6pp/8/8/8/8/8/K7_b_-_-_0_1
|
||||
"5R1k/6pp/8/8/8/8/8/K7 b - - 0 1",
|
||||
"g7",
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
TEST_CASE_PSEUDO_MOVES("legal king moves, king stale", "[Rook]") {
|
||||
testPseudoLegalMoves(
|
||||
// https://lichess.org/editor/k7/8/8/6n1/r7/4K3/2q5/8_w_-_-_0_1
|
||||
"k7/8/8/6n1/r7/4K3/2q5/8 w - - 0 1",
|
||||
"e3",
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE_PSEUDO_MOVES("Pseudo-legal rook moves, captures", "[Rook]") {
|
||||
testPseudoLegalMoves(
|
||||
// https://lichess.org/editor/8/8/3p4/8/3R1P2/8/8/8_w_-_-_0_1
|
||||
|
@@ -25,6 +25,22 @@ static void testGameEnd(const char* fen, bool isMate) {
|
||||
REQUIRE(pv.length() == 0);
|
||||
}
|
||||
|
||||
static void testMove(const char *fen, const std::vector<std::string> &expectedMoves) {
|
||||
auto engine = createEngine();
|
||||
REQUIRE(engine != nullptr);
|
||||
|
||||
auto board = Fen::createBoard(fen);
|
||||
REQUIRE(board.has_value());
|
||||
|
||||
for (const auto &moveName : expectedMoves) {
|
||||
auto pv = engine->pv(board.value());
|
||||
Move move = *pv.begin();
|
||||
REQUIRE(move == Move::fromUci(moveName));
|
||||
board->makeMove(move);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("Engine detects checkmate", "[Engine][Checkmate]") {
|
||||
auto fen = GENERATE(
|
||||
// https://lichess.org/editor/4R2k/6pp/8/8/8/8/8/K7_b_-_-_0_1
|
||||
@@ -46,3 +62,11 @@ TEST_CASE("Engine detects stalemate", "[Engine][Stalemate]") {
|
||||
|
||||
testGameEnd(fen, false);
|
||||
}
|
||||
|
||||
TEST_CASE("Puzzles mateIn1_simple", "[Engine][Puzzle]") {
|
||||
auto [fen, moves] = GENERATE(table<const char*, std::vector<std::string>>({
|
||||
{"2bQ1k1r/1p3p2/p4b1p/4pNp1/2q5/8/PPP2PPP/1K1RR3 b - - 3 23",{"f6d8", "d1d8"}}, // https://lichess.org/gQa01loO/black#46
|
||||
{"5rk1/ppp5/2n4p/3b2p1/6R1/P1B1P2P/1Pq5/R2Q2K1 b - - 3 29",{"c2f2"}}, // https://lichess.org/haKJxadR#57
|
||||
}));
|
||||
testMove(fen, moves);
|
||||
}
|
||||
|
Reference in New Issue
Block a user