X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fuci.cpp;h=c4c1a03705924516558ac8c5651b7bd63bc13bf5;hp=0a1de3127ae8aa167d6db35032549ee3e5329ac9;hb=403db5a6e9f004e39773dbc6cea9d1a99c81a233;hpb=8225fdd5bb6f74172ba0307d7db12c5ce8416eea diff --git a/src/uci.cpp b/src/uci.cpp index 0a1de312..c4c1a037 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); } @@ -123,7 +124,7 @@ namespace { } else if (token == "ucinewgame") { - push_button("Clear Hash"); + push_button("New Game"); Position::init_piece_square_tables(); RootPosition.from_fen(StartPosition); } @@ -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,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,23 @@ namespace { time, inc, movesToGo, depth, nodes, moveTime, searchMoves); } + void perft(UCIInputParser& uip) { + + string token; + int depth, tm, n; + Position pos = RootPosition; + + if (uip.eof()) + return; + + uip >> depth; + tm = get_system_time(); + + 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; + } }