X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fuci.cpp;h=f6b27114b13d64f60fafbd24c74c9550b7053afe;hp=1f1ba096ca6aa38edf39889d5e359dc07c96f9e9;hb=5e340346db94446587c78e791507ab9e2cffe3fa;hpb=174b40c28dd6f907ca093864ecaa73136694a7c5 diff --git a/src/uci.cpp b/src/uci.cpp index 1f1ba096..f6b27114 100644 --- a/src/uci.cpp +++ b/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); } @@ -147,14 +148,16 @@ namespace { else if (token == "eval") { EvalInfo ei; - cout << "Incremental mg: " << RootPosition.mg_value() - << "\nIncremental eg: " << RootPosition.eg_value() + cout << "Incremental mg: " << mg_value(RootPosition.value()) + << "\nIncremental eg: " << eg_value(RootPosition.value()) << "\nFull eval: " << evaluate(RootPosition, ei, 0) << endl; } else if (token == "key") 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; @@ -242,12 +245,10 @@ namespace { } if (token == "value") { - // Skip whitespace. There should be a better way to do this, but - // I don't know how... - while(isspace(uip.get())); - uip.unget(); + // Reads until end of line and left trim white space + getline(uip, token); + token.erase(0, token.find_first_not_of(" \n\r\t")); - getline(uip, token); // reads until end of line set_option_value(name, token); } else push_button(name); @@ -320,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; + } }