// UCIInputParser is a class for parsing UCI input. The class
// is actually a string stream built on a given input string.
// UCIInputParser is a class for parsing UCI input. The class
// is actually a string stream built on a given input string.
- // The root position. This is set up when the user (or in practice, the GUI)
- // sends the "position" UCI command. The root position is sent to the think()
- // function when the program receives the "go" command.
- Position RootPosition(0);
-
- void set_position(UCIInputParser& uip);
- bool go(UCIInputParser& uip);
- void perft(UCIInputParser& uip);
+ void set_position(Position& pos, UCIInputParser& uip);
+ bool go(Position& pos, UCIInputParser& uip);
+ void perft(Position& pos, UCIInputParser& uip);
// and calls the appropriate functions. In addition to the UCI
// commands, the function also supports a few debug commands.
// and calls the appropriate functions. In addition to the UCI
// commands, the function also supports a few debug commands.
else if (token == "isready")
cout << "readyok" << endl;
else if (token == "position")
else if (token == "isready")
cout << "readyok" << endl;
else if (token == "position")
- EvalInfo ei;
- cout << "Incremental mg: " << mg_value(RootPosition.value())
- << "\nIncremental eg: " << eg_value(RootPosition.value())
- << "\nFull eval: " << evaluate(RootPosition, ei) << endl;
+ Value evalMargin;
+ cout << "Incremental mg: " << mg_value(pos.value())
+ << "\nIncremental eg: " << eg_value(pos.value())
+ << "\nFull eval: " << evaluate(pos, evalMargin) << endl;
- cout << "key: " << hex << RootPosition.get_key()
- << "\nmaterial key: " << RootPosition.get_material_key()
- << "\npawn key: " << RootPosition.get_pawn_key() << endl;
+ cout << "key: " << hex << pos.get_key()
+ << "\nmaterial key: " << pos.get_material_key()
+ << "\npawn key: " << pos.get_pawn_key() << endl;
// ("position"), and is ready to read the second token ("startpos"
// or "fen", if the input is well-formed).
// ("position"), and is ready to read the second token ("startpos"
// or "fen", if the input is well-formed).
- move = move_from_string(RootPosition, token);
- RootPosition.do_move(move, st);
- if (RootPosition.rule_50_counter() == 0)
- RootPosition.reset_game_ply();
+ move = move_from_string(pos, token);
+ pos.do_move(move, st);
+ if (pos.rule_50_counter() == 0)
+ pos.reset_game_ply();
- set_option_value(name, value);
- } else
- push_button(name);
+ if (Options.find(name) == Options.end())
+ {
+ cout << "No such option: " << name << endl;
+ return;
+ }
+
+ if (token != "value" || !(uip >> value))
+ {
+ Options[name].set_value("true");
+ return;
// parameters. Returns false if a quit command is received while
// thinking, returns true otherwise.
// parameters. Returns false if a quit command is received while
// thinking, returns true otherwise.
string token;
int time[2] = {0, 0}, inc[2] = {0, 0};
int movesToGo = 0, depth = 0, nodes = 0, moveTime = 0;
bool infinite = false, ponder = false;
string token;
int time[2] = {0, 0}, inc[2] = {0, 0};
int movesToGo = 0, depth = 0, nodes = 0, moveTime = 0;
bool infinite = false, ponder = false;
- return think(RootPosition, infinite, ponder, time, inc, movesToGo,
+ return think(pos, infinite, ponder, time, inc, movesToGo,
depth, nodes, moveTime, searchMoves);
}
depth, nodes, moveTime, searchMoves);
}