From df20060075f0fb2d543e344bb322f62095bd9a5c Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Tue, 4 Feb 2025 21:51:58 +0100 Subject: [PATCH] added global peft --- cpp/src/stickfosh.cpp | 12 +++++++++++- cpp/src/stickfosh.hpp | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cpp/src/stickfosh.cpp b/cpp/src/stickfosh.cpp index dece87a..702fd1b 100644 --- a/cpp/src/stickfosh.cpp +++ b/cpp/src/stickfosh.cpp @@ -1,3 +1,5 @@ +#include "stickfosh.hpp" + #include "board.hpp" #include "move.hpp" @@ -65,7 +67,13 @@ int move_generation_test(Board& b, int depth, int max_depth) { return num_pos; } +void perft() { + for (auto& [key, value] : pos2expected) + perft(key); +} + void perft(std::string pos) { + std::cout << pos << std::endl; std::map expected = pos2expected[pos]; Board b = Board::setup_fen_position(pos); @@ -85,7 +93,9 @@ void perft(std::string pos) { std::cout << cross << " (expected " << expected_n_moves << ") "; std::cout << "positions Time: " << elapsed << " milliseconds" << std::endl; - if (moves != expected_n_moves) + if (moves != expected_n_moves) { std::cout << std::endl << res.str(); + exit(1); + } } } diff --git a/cpp/src/stickfosh.hpp b/cpp/src/stickfosh.hpp index c560c39..8d37fa3 100644 --- a/cpp/src/stickfosh.hpp +++ b/cpp/src/stickfosh.hpp @@ -3,3 +3,4 @@ #include void perft(std::string pos); +void perft();