mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Retire push_button() and button_was_pressed()
Directly access the underlying bool option. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
9f626725ae
commit
fb50e16cdd
4 changed files with 22 additions and 43 deletions
|
@ -425,8 +425,11 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[
|
||||||
|
|
||||||
// Read UCI option values
|
// Read UCI option values
|
||||||
TT.set_size(get_option_value_int("Hash"));
|
TT.set_size(get_option_value_int("Hash"));
|
||||||
if (button_was_pressed("Clear Hash"))
|
if (get_option_value_bool("Clear Hash"))
|
||||||
|
{
|
||||||
|
set_option_value("Clear Hash", "false");
|
||||||
TT.clear();
|
TT.clear();
|
||||||
|
}
|
||||||
|
|
||||||
CheckExtension[1] = Depth(get_option_value_int("Check Extension (PV nodes)"));
|
CheckExtension[1] = Depth(get_option_value_int("Check Extension (PV nodes)"));
|
||||||
CheckExtension[0] = Depth(get_option_value_int("Check Extension (non-PV nodes)"));
|
CheckExtension[0] = Depth(get_option_value_int("Check Extension (non-PV nodes)"));
|
||||||
|
|
20
src/uci.cpp
20
src/uci.cpp
|
@ -122,7 +122,7 @@ namespace {
|
||||||
}
|
}
|
||||||
else if (token == "ucinewgame")
|
else if (token == "ucinewgame")
|
||||||
{
|
{
|
||||||
push_button("New Game");
|
set_option_value("New Game", "true");
|
||||||
pos.from_fen(StartPositionFEN);
|
pos.from_fen(StartPositionFEN);
|
||||||
}
|
}
|
||||||
else if (token == "isready")
|
else if (token == "isready")
|
||||||
|
@ -227,20 +227,22 @@ namespace {
|
||||||
if (!(uip >> token)) // operator>>() skips any whitespace
|
if (!(uip >> token)) // operator>>() skips any whitespace
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (token == "name" && uip >> name)
|
if (token != "name" || !(uip >> name))
|
||||||
{
|
return;
|
||||||
|
|
||||||
while (uip >> token && token != "value")
|
while (uip >> token && token != "value")
|
||||||
name += (" " + token);
|
name += (" " + token);
|
||||||
|
|
||||||
if (token == "value" && uip >> value)
|
if (token != "value" || !(uip >> value))
|
||||||
{
|
{
|
||||||
|
set_option_value(name, "true");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while (uip >> token)
|
while (uip >> token)
|
||||||
value += (" " + token);
|
value += (" " + token);
|
||||||
|
|
||||||
set_option_value(name, value);
|
set_option_value(name, value);
|
||||||
} else
|
|
||||||
push_button(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,7 +262,7 @@ namespace {
|
||||||
int time[2] = {0, 0}, inc[2] = {0, 0};
|
int time[2] = {0, 0}, inc[2] = {0, 0};
|
||||||
int movesToGo = 0, depth = 0, nodes = 0, moveTime = 0;
|
int movesToGo = 0, depth = 0, nodes = 0, moveTime = 0;
|
||||||
bool infinite = false, ponder = false;
|
bool infinite = false, ponder = false;
|
||||||
Move searchMoves[500];
|
Move searchMoves[MOVES_MAX];
|
||||||
|
|
||||||
searchMoves[0] = MOVE_NONE;
|
searchMoves[0] = MOVE_NONE;
|
||||||
|
|
||||||
|
@ -317,6 +319,6 @@ namespace {
|
||||||
tm = get_system_time() - tm;
|
tm = get_system_time() - tm;
|
||||||
std::cout << "\nNodes " << n
|
std::cout << "\nNodes " << n
|
||||||
<< "\nTime (ms) " << tm
|
<< "\nTime (ms) " << tm
|
||||||
<< "\nNodes/second " << (int)(n/(tm/1000.0)) << std::endl;
|
<< "\nNodes/second " << int(n / (tm / 1000.0)) << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,7 +286,7 @@ void set_option_value(const string& name, const string& value) {
|
||||||
if (opt.type == CHECK && v != "0" && v != "1")
|
if (opt.type == CHECK && v != "0" && v != "1")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
else if (opt.type == SPIN)
|
if (opt.type == SPIN)
|
||||||
{
|
{
|
||||||
int val = atoi(v.c_str());
|
int val = atoi(v.c_str());
|
||||||
if (val < opt.minValue || val > opt.maxValue)
|
if (val < opt.minValue || val > opt.maxValue)
|
||||||
|
@ -294,26 +294,3 @@ void set_option_value(const string& name, const string& value) {
|
||||||
}
|
}
|
||||||
opt.currentValue = v;
|
opt.currentValue = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// push_button() is used to tell the engine that a UCI parameter of type
|
|
||||||
/// "button" has been selected:
|
|
||||||
|
|
||||||
void push_button(const string& buttonName) {
|
|
||||||
|
|
||||||
set_option_value(buttonName, "true");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// button_was_pressed() tests whether a UCI parameter of type "button" has
|
|
||||||
/// been selected since the last time the function was called, in this case
|
|
||||||
/// it also resets the button.
|
|
||||||
|
|
||||||
bool button_was_pressed(const string& buttonName) {
|
|
||||||
|
|
||||||
if (!get_option_value<bool>(buttonName))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
set_option_value(buttonName, "false");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
|
@ -36,9 +36,6 @@ extern void print_uci_options();
|
||||||
extern bool get_option_value_bool(const std::string& optionName);
|
extern bool get_option_value_bool(const std::string& optionName);
|
||||||
extern int get_option_value_int(const std::string& optionName);
|
extern int get_option_value_int(const std::string& optionName);
|
||||||
extern std::string get_option_value_string(const std::string& optionName);
|
extern std::string get_option_value_string(const std::string& optionName);
|
||||||
extern bool button_was_pressed(const std::string& buttonName);
|
|
||||||
extern void set_option_value(const std::string& optionName,const std::string& newValue);
|
extern void set_option_value(const std::string& optionName,const std::string& newValue);
|
||||||
extern void push_button(const std::string& buttonName);
|
|
||||||
|
|
||||||
|
|
||||||
#endif // !defined(UCIOPTION_H_INCLUDED)
|
#endif // !defined(UCIOPTION_H_INCLUDED)
|
||||||
|
|
Loading…
Add table
Reference in a new issue