Skip to content
This repository was archived by the owner on Apr 26, 2025. It is now read-only.

Commit 2f53863

Browse files
Add files via upload
1 parent c3961eb commit 2f53863

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

mayhem.hpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ namespace mayhem {
6969
#define R50_ARR (FIFTY + 2) // Checkmate overrules 50 move rep so extra space here
7070
#define SHUFFLE 30 // Allow shuffling then scale
7171
#define BOOK_MS 100 // At least 100ms+ for the book lookup
72+
#define PERFT_DEPTH 6 // Perft at depth 6
7273
#define BENCH_DEPTH 14 // Bench at depth 14
7374
#define BENCH_SPEED 10000 // Bench for 10s
7475
#define BOOK_BEST false // Nondeterministic opening play
@@ -2778,17 +2779,10 @@ void UciPrintBoard() {
27782779
std::cout << '\n' << g_board->to_s() << std::endl;
27792780
}
27802781

2781-
// Calculate perft split numbers
2782-
// Nodes: 119060324
2783-
// Time(ms): 1797
2784-
// NPS: 66255049
2785-
void UciPerft() {
2782+
void PerftUtil(const int depth, const std::string fen) {
27862783
const Save save{};
2787-
const std::string depth2 = TokenGetNth(0);
2788-
const std::string fen = TokenGetNth(1);
2789-
const auto depth = depth2.length() ? std::max(0, std::stoi(depth2)) : 6;
2790-
std::uint64_t nodes = depth >= 1 ? 0 : 1, total_ms = 0;
2791-
SetFen(fen.length() ? fen : STARTPOS);
2784+
std::uint64_t nodes = depth >= 1 ? 0 : 1, total_ms = 0;
2785+
SetFen(fen);
27922786
MgenRoot();
27932787
for (auto i = 0; i < g_root_n; i += 1) {
27942788
g_board = g_boards[0] + i;
@@ -2808,7 +2802,7 @@ void UciPerft() {
28082802

28092803
void Bench(const int depth, const int time) {
28102804
const Save save{};
2811-
SetHashtable(); // Set hash and reset
2805+
SetHashtable(); // Reset hash
28122806
g_max_depth = depth;
28132807
g_noise = 0; // Make search deterministic
28142808
g_nnue_exist = false;
@@ -2837,28 +2831,39 @@ void Bench(const int depth, const int time) {
28372831
"NPS: " << Nps(nodes, total_ms) << std::endl;
28382832
}
28392833

2840-
// Signature of the program
2834+
// Show signature of the program
28412835
// Result: 70 / 70
28422836
// Nodes: 247216819
2843-
// Time(ms): 29170
2844-
// NPS: 8475036
2837+
// Time(ms): 28076
2838+
// NPS: 8805272
28452839
void UciBench() {
28462840
const std::string depth = TokenGetNth();
28472841
Bench(!depth.length() ? BENCH_DEPTH : (depth == "inf" ? MAX_SEARCH_DEPTH : std::clamp(std::stoi(depth), 0, MAX_SEARCH_DEPTH)),
28482842
WEEK);
28492843
}
28502844

2851-
// Speed of the program
2845+
// Show speed of the program
28522846
// Result: 70 / 70
2853-
// Nodes: 6031111110
2854-
// Time(ms): 579009
2855-
// NPS: 10416264
2847+
// Nodes: 6294221730
2848+
// Time(ms): 578852
2849+
// NPS: 10873628
28562850
void UciSpeed() {
28572851
const std::string ms = TokenGetNth();
28582852
Bench(MAX_SEARCH_DEPTH,
28592853
!ms.length() ? BENCH_SPEED : std::max(0, std::stoi(ms)));
28602854
}
28612855

2856+
// Calculate perft split numbers
2857+
// Nodes: 119060324
2858+
// Time(ms): 1779
2859+
// NPS: 66925421
2860+
void UciPerft() {
2861+
const std::string depth = TokenGetNth(0);
2862+
const std::string fen = TokenGetNth(1);
2863+
PerftUtil(depth.length() ? std::max(0, std::stoi(depth)) : PERFT_DEPTH,
2864+
fen.length() ? fen : STARTPOS);
2865+
}
2866+
28622867
void UciPrintLogo() {
28632868
std::cout <<
28642869
"___ ___ _ \n"

0 commit comments

Comments
 (0)