]> git.sesse.net Git - stockfish/commitdiff
Retire push_button() and button_was_pressed()
authorMarco Costalba <mcostalba@gmail.com>
Wed, 3 Nov 2010 08:32:14 +0000 (09:32 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 3 Nov 2010 12:19:55 +0000 (13:19 +0100)
Directly access the underlying bool option.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp
src/uci.cpp
src/ucioption.cpp
src/ucioption.h

index 9649c2da76b269d00ae9380e1fbfd4c018883fbb..c5c8b839db343d9ec4396e2f74d759965465aa4c 100644 (file)
@@ -425,8 +425,11 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[
 
   // Read UCI option values
   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();
+  }
 
   CheckExtension[1]         = Depth(get_option_value_int("Check Extension (PV nodes)"));
   CheckExtension[0]         = Depth(get_option_value_int("Check Extension (non-PV nodes)"));
index e59df6dd737f79b9f66eb832b6ef6eeaa68a35a6..c9ecbf234fc16f993582e30bf1a9e62aac3ab1d8 100644 (file)
@@ -122,7 +122,7 @@ namespace {
     }
     else if (token == "ucinewgame")
     {
-        push_button("New Game");
+        set_option_value("New Game", "true");
         pos.from_fen(StartPositionFEN);
     }
     else if (token == "isready")
@@ -227,20 +227,22 @@ namespace {
     if (!(uip >> token)) // operator>>() skips any whitespace
         return;
 
-    if (token == "name" && uip >> name)
-    {
-        while (uip >> token && token != "value")
-            name += (" " + token);
+    if (token != "name" || !(uip >> name))
+        return;
 
-        if (token == "value" && uip >> value)
-        {
-            while (uip >> token)
-                value += (" " + token);
+    while (uip >> token && token != "value")
+        name += (" " + token);
 
-            set_option_value(name, value);
-        } else
-            push_button(name);
+    if (token != "value" || !(uip >> value))
+    {
+        set_option_value(name, "true");
+        return;
     }
+
+    while (uip >> token)
+        value += (" " + token);
+
+    set_option_value(name, value);
   }
 
 
@@ -260,7 +262,7 @@ namespace {
     int time[2] = {0, 0}, inc[2] = {0, 0};
     int movesToGo = 0, depth = 0, nodes = 0, moveTime = 0;
     bool infinite = false, ponder = false;
-    Move searchMoves[500];
+    Move searchMoves[MOVES_MAX];
 
     searchMoves[0] = MOVE_NONE;
 
@@ -317,6 +319,6 @@ namespace {
     tm = get_system_time() - tm;
     std::cout << "\nNodes " << n
               << "\nTime (ms) " << tm
-              << "\nNodes/second " << (int)(n/(tm/1000.0)) << std::endl;
+              << "\nNodes/second " << int(n / (tm / 1000.0)) << std::endl;
   }
 }
index e1b5ae552900b310f61db930caf85d53eb73fb1e..2db1beeba31a11305fe7a4cb15ed09e6c62f8a99 100644 (file)
@@ -286,7 +286,7 @@ void set_option_value(const string& name, const string& value) {
   if (opt.type == CHECK && v != "0" && v != "1")
       return;
 
-  else if (opt.type == SPIN)
+  if (opt.type == SPIN)
   {
       int val = atoi(v.c_str());
       if (val < opt.minValue || val > opt.maxValue)
@@ -294,26 +294,3 @@ void set_option_value(const string& name, const string& value) {
   }
   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;
-}
index b5648af5f04b18c781992d8ff1119bcb4e63a333..e68e438b4ad66dae49846415db5f9b12a51481b7 100644 (file)
@@ -36,9 +36,6 @@ extern void print_uci_options();
 extern bool get_option_value_bool(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 bool button_was_pressed(const std::string& buttonName);
 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)