void test_perft_pos(const char *input, const int depth, const uint64_t *expected_nodes) { for (int i = 1; i <= depth; i++) { Chess chess; chess.start_game(); chess.table->setboard(input); uint64_t start_time = Util::get_ms(); uint64_t nodes = chess.perft(i); uint64_t stop_time = Util::get_ms(); uint64_t duration = stop_time - start_time; printf("depth: %d nodes: %lu time: %lu ms knps: %lu\n", i, nodes, duration, duration == 0 ? 0 : nodes / duration); assert(nodes == expected_nodes[i - 1]); } }
void test_perft_startpos(const int depth) { const char input[] = "position startpos"; puts(input); for (int i = 1; i <= depth; i++) { Chess chess; chess.start_game(); chess.nodes = 0; chess.uci->position_received(input); chess.max_time = 0; uint64_t start_time = Util::get_ms(); uint64_t nodes = chess.perft(i); uint64_t stop_time = Util::get_ms(); uint64_t duration = stop_time - start_time; printf("depth: %d nodes: %lu time: %lu ms knps: %lu\n", i, nodes, duration, duration == 0 ? 0 : nodes / duration); switch (i) { case 1: assert(nodes == 20); break; case 2: assert(nodes == 400); break; case 3: assert(nodes == 8902); break; case 4: assert(nodes == 197281); break; case 5: assert(nodes == 4865609); break; default: break; } } puts(""); }