using fixed size array instead of vector to store moves
This commit is contained in:
1 parent
d566c6d0e4
commit
6e8f7e3d86
5 files changed
+19
-14
No files matched your search
+4
-4
@@ -4,12 +4,12 @@
|
||||
U64 HelperPerft(Board board, int depth) {
|
||||
GenerateMoves(board, board.sideToMove);
|
||||
|
||||
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);
|
||||
@@ -24,7 +24,7 @@ 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);
|
||||
@@ -56,4 +56,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