From 8d5024a4a4d78e364371ed267ca05c7fe352f4d1 Mon Sep 17 00:00:00 2001 From: rektdie Date: Thu, 20 Mar 2025 20:23:22 +0100 Subject: [PATCH] bugfix: perft --- source/perft.cpp | 5 ++++- source/perft.h | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/perft.cpp b/source/perft.cpp index fdddbeb..ed8f828 100644 --- a/source/perft.cpp +++ b/source/perft.cpp @@ -1,7 +1,8 @@ #include "perft.h" #include "stopwatch.h" +#include "movegen.h" -U64 HelperPerft(Board board, int depth) { +static U64 HelperPerft(Board board, int depth) { MOVEGEN::GenerateMoves(board); if (depth == 1) return board.currentMoveIndex; @@ -13,6 +14,7 @@ U64 HelperPerft(Board board, int depth) { Board copy = board; board.MakeMove(board.moveList[i]); nodes += HelperPerft(board, depth - 1); + positionIndex--; board = copy; } return nodes; @@ -28,6 +30,7 @@ void Perft(Board &board, int depth) { Board copy = board; board.MakeMove(board.moveList[i]); U64 nodeCount = HelperPerft(board, depth - 1); + positionIndex--; board = copy; totalNodes += nodeCount; board.moveList[i].PrintMove(); diff --git a/source/perft.h b/source/perft.h index fe787c6..13d0ac6 100644 --- a/source/perft.h +++ b/source/perft.h @@ -1,5 +1,4 @@ #pragma once #include "board.h" -#include "movegen.h" void Perft(Board &board, int depth); \ No newline at end of file