bugfix: perft
This commit is contained in:
1 parent
20ab2f476a
commit
8d5024a4a4
2 files changed
+4
-2
No files matched your search
+4
-1
@@ -1,7 +1,8 @@
|
|||||||
#include "perft.h"
|
#include "perft.h"
|
||||||
#include "stopwatch.h"
|
#include "stopwatch.h"
|
||||||
|
#include "movegen.h"
|
||||||
|
|
||||||
U64 HelperPerft(Board board, int depth) {
|
static U64 HelperPerft(Board board, int depth) {
|
||||||
MOVEGEN::GenerateMoves(board);
|
MOVEGEN::GenerateMoves(board);
|
||||||
|
|
||||||
if (depth == 1) return board.currentMoveIndex;
|
if (depth == 1) return board.currentMoveIndex;
|
||||||
@@ -13,6 +14,7 @@ U64 HelperPerft(Board board, int depth) {
|
|||||||
Board copy = board;
|
Board copy = board;
|
||||||
board.MakeMove(board.moveList[i]);
|
board.MakeMove(board.moveList[i]);
|
||||||
nodes += HelperPerft(board, depth - 1);
|
nodes += HelperPerft(board, depth - 1);
|
||||||
|
positionIndex--;
|
||||||
board = copy;
|
board = copy;
|
||||||
}
|
}
|
||||||
return nodes;
|
return nodes;
|
||||||
@@ -28,6 +30,7 @@ void Perft(Board &board, int depth) {
|
|||||||
Board copy = board;
|
Board copy = board;
|
||||||
board.MakeMove(board.moveList[i]);
|
board.MakeMove(board.moveList[i]);
|
||||||
U64 nodeCount = HelperPerft(board, depth - 1);
|
U64 nodeCount = HelperPerft(board, depth - 1);
|
||||||
|
positionIndex--;
|
||||||
board = copy;
|
board = copy;
|
||||||
totalNodes += nodeCount;
|
totalNodes += nodeCount;
|
||||||
board.moveList[i].PrintMove();
|
board.moveList[i].PrintMove();
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "movegen.h"
|
|
||||||
|
|
||||||
void Perft(Board &board, int depth);
|
void Perft(Board &board, int depth);
|
||||||
Reference in new issue
Block a user