X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fuci.cpp;h=b90240961e56ca803e2f3d30fdf3b7044f4f3a9e;hb=70b7404a63b74a57d4e1d0b9192b00837e9a1af8;hp=b3af1b607a24138d4a87d0b0f327472d9fe0b81d;hpb=d2c2af9e1c4f5711e320555fe31ae4ed940802c6;p=stockfish diff --git a/src/uci.cpp b/src/uci.cpp index b3af1b60..b9024096 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); } @@ -117,7 +118,7 @@ namespace { if (token == "uci") { cout << "id name " << engine_name() - << "\nid author Tord Romstad, Marco Costalba\n"; + << "\nid author Tord Romstad, Marco Costalba, Joona Kiiski\n"; print_uci_options(); cout << "uciok" << endl; } @@ -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; @@ -242,7 +245,10 @@ namespace { } if (token == "value") { - getline(uip, token); // reads until end of line + // Reads until end of line and left trim white space + getline(uip, token); + token.erase(0, token.find_first_not_of(" \n\r\t")); + set_option_value(name, token); } else push_button(name); @@ -315,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; + } }