+ // Add custom non-UCI commands, mainly for debugging purposes.
+ // These commands must not be used during a search!
+ else if (token == "flip") pos.flip();
+ else if (token == "bench") bench(pos, is, states);
+ else if (token == "d") sync_cout << pos << sync_endl;
+ else if (token == "eval") trace_eval(pos);
+ else if (token == "compiler") sync_cout << compiler_info() << sync_endl;
+ else if (token == "export_net")
+ {
+ std::optional<std::string> filename;
+ std::string f;
+ if (is >> skipws >> f)
+ filename = f;
+ Eval::NNUE::save_eval(filename);
+ }
+ else if (token == "--help" || token == "help" || token == "--license" || token == "license")
+ sync_cout << "\nStockfish is a powerful chess engine for playing and analyzing."
+ "\nIt is released as free software licensed under the GNU GPLv3 License."
+ "\nStockfish is normally used with a graphical user interface (GUI) and implements"
+ "\nthe Universal Chess Interface (UCI) protocol to communicate with a GUI, an API, etc."
+ "\nFor any further information, visit https://github.com/official-stockfish/Stockfish#readme"
+ "\nor read the corresponding README.md and Copying.txt files distributed along with this program.\n" << sync_endl;
+ else if (!token.empty() && token[0] != '#')
+ sync_cout << "Unknown command: '" << cmd << "'. Type help for more information." << sync_endl;
+
+ } while (token != "quit" && argc == 1); // The command-line arguments are one-shot
+}
+
+
+/// UCI::value() converts a Value to a string by adhering to the UCI protocol specification:
+///
+/// cp <x> The score from the engine's point of view in centipawns.
+/// mate <y> Mate in 'y' moves (not plies). If the engine is getting mated,
+/// uses negative values for 'y'.
+
+string UCI::value(Value v) {
+
+ assert(-VALUE_INFINITE < v && v < VALUE_INFINITE);
+
+ stringstream ss;
+
+ if (abs(v) < VALUE_MATE_IN_MAX_PLY)
+ ss << "cp " << v * 100 / NormalizeToPawnValue;
+ else
+ ss << "mate " << (v > 0 ? VALUE_MATE - v + 1 : -VALUE_MATE - v) / 2;
+
+ return ss.str();
+}
+
+
+/// UCI::wdl() reports the win-draw-loss (WDL) statistics given an evaluation
+/// and a game ply based on the data gathered for fishtest LTC games.
+
+string UCI::wdl(Value v, int ply) {
+
+ stringstream ss;
+
+ int wdl_w = win_rate_model( v, ply);
+ int wdl_l = win_rate_model(-v, ply);
+ int wdl_d = 1000 - wdl_w - wdl_l;
+ ss << " wdl " << wdl_w << " " << wdl_d << " " << wdl_l;
+
+ return ss.str();
+}
+
+
+/// UCI::square() converts a Square to a string in algebraic notation (g1, a7, etc.)