const char* StartFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
-// position() is called when the engine receives the "position" UCI command.
+// Called when the engine receives the "position" UCI command.
// It sets up the position that is described in the given FEN string ("fen") or
// the initial position ("startpos") and then makes the moves given in the following
// move list ("moves").
-
void position(Position& pos, std::istringstream& is, StateListPtr& states) {
Move m;
}
}
-// trace_eval() prints the evaluation of the current position, consistent with
-// the UCI options set so far.
-
+// Prints the evaluation of the current position,
+// consistent with the UCI options set so far.
void trace_eval(Position& pos) {
StateListPtr states(new std::deque<StateInfo>(1));
}
-// setoption() is called when the engine receives the "setoption" UCI command.
+// Called when the engine receives the "setoption" UCI command.
// The function updates the UCI option ("name") to the given value ("value").
void setoption(std::istringstream& is) {
}
-// go() is called when the engine receives the "go" UCI command. The function
-// sets the thinking time and other parameters from the input string, then starts
-// with a search.
+// Called when the engine receives the "go" UCI command. The function sets the
+// thinking time and other parameters from the input string then stars with a search
void go(Position& pos, std::istringstream& is, StateListPtr& states) {
}
-// bench() is called when the engine receives the "bench" command.
+// Called when the engine receives the "bench" command.
// First, a list of UCI commands is set up according to the bench
// parameters, then it is run one by one, printing a summary at the end.
uint64_t num, nodes = 0, cnt = 1;
std::vector<std::string> list = setup_bench(pos, args);
- num = count_if(list.begin(), list.end(),
- [](const std::string& s) { return s.find("go ") == 0 || s.find("eval") == 0; });
+
+ num = count_if(list.begin(), list.end(),
+ [](const std::string& s) { return s.find("go ") == 0 || s.find("eval") == 0; });
TimePoint elapsed = now();
} // namespace
-// UCI::loop() waits for a command from the stdin, parses it, and then calls the appropriate
+// Waits for a command from the stdin, parses it, and then calls the appropriate
// function. It also intercepts an end-of-file (EOF) indication from the stdin to ensure a
// graceful exit if the GUI dies unexpectedly. When called with some command-line arguments,
// like running 'bench', the function returns immediately after the command is executed.
// In addition to the UCI ones, some additional debug commands are also supported.
-
void UCI::loop(int argc, char* argv[]) {
Position pos;
// without treatment of mate and similar special scores.
int UCI::to_cp(Value v) { return 100 * v / UCI::NormalizeToPawnValue; }
-// UCI::value() converts a Value to a string by adhering to the UCI protocol specification:
+// 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'.
-
std::string UCI::value(Value v) {
assert(-VALUE_INFINITE < v && v < VALUE_INFINITE);
if (abs(v) < VALUE_TB_WIN_IN_MAX_PLY)
ss << "cp " << UCI::to_cp(v);
- else if (abs(v) < VALUE_MATE_IN_MAX_PLY)
+ else if (abs(v) <= VALUE_TB)
{
- const int ply = VALUE_MATE_IN_MAX_PLY - 1 - std::abs(v); // recompute ss->ply
+ const int ply = VALUE_TB - std::abs(v); // recompute ss->ply
ss << "cp " << (v > 0 ? 20000 - ply : -20000 + ply);
}
else
}
-// UCI::wdl() reports the win-draw-loss (WDL) statistics given an evaluation
+// Reports the win-draw-loss (WDL) statistics given an evaluation
// and a game ply based on the data gathered for fishtest LTC games.
-
std::string UCI::wdl(Value v, int ply) {
std::stringstream ss;
}
-// UCI::square() converts a Square to a string in algebraic notation (g1, a7, etc.)
-
+// Converts a Square to a string in algebraic notation (g1, a7, etc.)
std::string UCI::square(Square s) {
return std::string{char('a' + file_of(s)), char('1' + rank_of(s))};
}
-// UCI::move() converts a Move to a string in coordinate notation (g1f3, a7a8q).
+// Converts a Move to a string in coordinate notation (g1f3, a7a8q).
// The only special case is castling where the e1g1 notation is printed in
// standard chess mode and in e1h1 notation it is printed in Chess960 mode.
// Internally, all castling moves are always encoded as 'king captures rook'.
-
std::string UCI::move(Move m, bool chess960) {
if (m == MOVE_NONE)
}
-// UCI::to_move() converts a string representing a move in coordinate notation
+// Converts a string representing a move in coordinate notation
// (g1f3, a7a8q) to the corresponding legal Move, if any.
-
Move UCI::to_move(const Position& pos, std::string& str) {
if (str.length() == 5)