diff --git a/source/main.cpp b/source/main.cpp index d8b68ef..b9e95c1 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -9,7 +9,7 @@ int main() { initSliderAttacks(); Board board; - Perft(board, 4); + Perft(board, 2); return 0; } \ No newline at end of file diff --git a/source/perft.cpp b/source/perft.cpp index 2abc68e..5ab91d9 100644 --- a/source/perft.cpp +++ b/source/perft.cpp @@ -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(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"; } \ No newline at end of file diff --git a/source/types.h b/source/types.h index 7b1cd65..a1767c9 100644 --- a/source/types.h +++ b/source/types.h @@ -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,