mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-18 16:16:23 +08:00
Implemented perft
Patch from Joona with extension to benchmark and inclusion of Depth(0) moves generation by me. Note that to test also qsearch and in particulary checks generations a change in the end condition is needed. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
committed by
Marco Costalba
parent
d9b920acfb
commit
fa49311b36
23
src/uci.cpp
23
src/uci.cpp
@@ -61,6 +61,7 @@ namespace {
|
||||
void set_option(UCIInputParser& uip);
|
||||
void set_position(UCIInputParser& uip);
|
||||
bool go(UCIInputParser& uip);
|
||||
void perft(UCIInputParser& uip);
|
||||
}
|
||||
|
||||
|
||||
@@ -155,6 +156,8 @@ namespace {
|
||||
cout << "key: " << hex << RootPosition.get_key()
|
||||
<< "\nmaterial key: " << RootPosition.get_material_key()
|
||||
<< "\npawn key: " << RootPosition.get_pawn_key() << endl;
|
||||
else if (token == "perft")
|
||||
perft(uip);
|
||||
else
|
||||
{
|
||||
cout << "Unknown command: " << command << endl;
|
||||
@@ -318,4 +321,24 @@ namespace {
|
||||
time, inc, movesToGo, depth, nodes, moveTime, searchMoves);
|
||||
}
|
||||
|
||||
void perft(UCIInputParser& uip) {
|
||||
|
||||
string token;
|
||||
int depth = 0;
|
||||
|
||||
while (!uip.eof())
|
||||
{
|
||||
uip >> token;
|
||||
|
||||
if (token == "depth")
|
||||
uip >> depth;
|
||||
}
|
||||
Position pos = RootPosition;
|
||||
int tm = get_system_time();
|
||||
int n = perft(pos, depth * OnePly);
|
||||
tm = get_system_time() - tm;
|
||||
std::cout << "\nNodes " << n
|
||||
<< "\nTime (ms) " << tm
|
||||
<< "\nNodes/second " << (int)(n/(tm/1000.0)) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user