removed time measurement from perft (temporarily)
This commit is contained in:
1 parent
693cfd07ac
commit
7dd2bd8823
3 files changed
+5
-14
No files matched your search
+1
-1
@@ -9,7 +9,7 @@ int main() {
|
||||
initSliderAttacks();
|
||||
|
||||
Board board;
|
||||
Perft(board, 4);
|
||||
Perft(board, 2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+3
-12
@@ -5,6 +5,7 @@ U64 HelperPerft(Board board, int depth) {
|
||||
GenerateMoves(board, board.sideToMove);
|
||||
|
||||
if (depth == 1) return board.moveList.size();
|
||||
if (depth == 0) return 1ULL;
|
||||
|
||||
U64 nodes = 0;
|
||||
|
||||
@@ -17,31 +18,21 @@ U64 HelperPerft(Board board, int depth) {
|
||||
}
|
||||
|
||||
void Perft(Board &board, int depth) {
|
||||
using std::chrono::high_resolution_clock;
|
||||
using std::chrono::milliseconds;
|
||||
using std::chrono::duration_cast;
|
||||
|
||||
GenerateMoves(board, board.sideToMove);
|
||||
|
||||
int totalNodes = 0;
|
||||
U64 totalNodes = 0;
|
||||
|
||||
for (int i = 0; i < board.moveList.size(); i++) {
|
||||
board.MakeMove(board.moveList[i]);
|
||||
int nodeCount = HelperPerft(board, depth - 1);
|
||||
U64 nodeCount = HelperPerft(board, depth - 1);
|
||||
totalNodes += nodeCount;
|
||||
board.moveList[i].PrintMove();
|
||||
board.UnmakeMove();
|
||||
std::cout << ": " << nodeCount << '\n';
|
||||
}
|
||||
|
||||
auto start = high_resolution_clock::now();
|
||||
U64 nodes = HelperPerft(board, depth);
|
||||
auto end = high_resolution_clock::now();
|
||||
|
||||
auto duration = duration_cast<milliseconds>(end - start);
|
||||
|
||||
std::cout << "\nDepth: " << depth << '\n';
|
||||
std::cout << "Total nodes: " << totalNodes << '\n';
|
||||
std::cout << "Total time taken: " << duration.count() << " ms";
|
||||
std::cout << " (" << (nodes / duration.count()) * 1000 << " nodes/sec)\n";
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
using U64 = uint64_t;
|
||||
|
||||
constexpr char StartingFen[] = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
|
||||
constexpr char StartingFen[] = "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1";
|
||||
|
||||
enum COLOR {
|
||||
White,
|
||||
|
||||
Reference in new issue
Block a user