made some optimizations in PopBit and other parts
This commit is contained in:
1 parent
119a87f227
commit
986b49b503
8 files changed
+32
-37
No files matched your search
+8
-10
@@ -4,16 +4,15 @@
|
||||
U64 HelperPerft(Board board, int depth) {
|
||||
GenerateMoves(board);
|
||||
|
||||
if (depth == 1) return board.moveList.size();
|
||||
if (depth == 1) return board.currentMoveIndex;
|
||||
if (depth == 0) return 1ULL;
|
||||
|
||||
U64 nodes = 0;
|
||||
|
||||
for (int i = 0; i < board.moveList.size(); i++) {
|
||||
for (int i = 0; i < board.currentMoveIndex; i++) {
|
||||
Board copy = board;
|
||||
board.MakeMove(board.moveList[i]);
|
||||
nodes += HelperPerft(board, depth - 1);
|
||||
board = copy;
|
||||
copy.MakeMove(board.moveList[i]);
|
||||
nodes += HelperPerft(copy, depth - 1);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
@@ -24,11 +23,10 @@ void Perft(Board &board, int depth) {
|
||||
U64 totalNodes = 0;
|
||||
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
for (int i = 0; i < board.moveList.size(); i++) {
|
||||
for (int i = 0; i < board.currentMoveIndex; i++) {
|
||||
Board copy = board;
|
||||
board.MakeMove(board.moveList[i]);
|
||||
U64 nodeCount = HelperPerft(board, depth - 1);
|
||||
board = copy;
|
||||
copy.MakeMove(board.moveList[i]);
|
||||
U64 nodeCount = HelperPerft(copy, depth - 1);
|
||||
totalNodes += nodeCount;
|
||||
std::cout << squareCoords[board.moveList[i].MoveFrom()]
|
||||
<< squareCoords[board.moveList[i].MoveTo()];
|
||||
@@ -56,4 +54,4 @@ void Perft(Board &board, int depth) {
|
||||
std::cout << "Total nodes: " << totalNodes << '\n';
|
||||
std::cout << "Time took: " << elapsed_seconds << "s (";
|
||||
std::cout << int(totalNodes / elapsed_seconds) << " nodes/sec)\n";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user