]> git.sesse.net Git - stockfish/commitdiff
Use int conversion for Option class
authorMinetaS <skdty87@gmail.com>
Fri, 7 Apr 2023 15:23:04 +0000 (15:23 +0000)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Mon, 10 Apr 2023 07:27:35 +0000 (09:27 +0200)
The current implementation generates warnings on MSVC. However, we have
no real use cases for double-typed UCI option values now. Also parameter
tuning only accepts following three types:

  int, Value, Score

closes https://github.com/official-stockfish/Stockfish/pull/4505

No functional change

src/tt.cpp
src/uci.h
src/ucioption.cpp

index 39f18d3d9c4ec7b50ea7e81484c8124313cd0edb..3339c993c417998737a4e7602217307185be3a0b 100644 (file)
@@ -87,7 +87,7 @@ void TranspositionTable::clear() {
 
   std::vector<std::thread> threads;
 
-  for (size_t idx = 0; idx < Options["Threads"]; ++idx)
+  for (size_t idx = 0; idx < size_t(Options["Threads"]); ++idx)
   {
       threads.emplace_back([this, idx]() {
 
@@ -98,7 +98,7 @@ void TranspositionTable::clear() {
           // Each thread will zero its part of the hash table
           const size_t stride = size_t(clusterCount / Options["Threads"]),
                        start  = size_t(stride * idx),
-                       len    = idx != Options["Threads"] - 1 ?
+                       len    = idx != size_t(Options["Threads"]) - 1 ?
                                 stride : clusterCount - start;
 
           std::memset(&table[start], 0, len * sizeof(Cluster));
index 70e45accd1cf7f2d0108c5d34436ad5a74555065..9ca0ed36b4dd0385609f4d7dd317b70cc2f97eb9 100644 (file)
--- a/src/uci.h
+++ b/src/uci.h
@@ -61,7 +61,7 @@ public:
 
   Option& operator=(const std::string&);
   void operator<<(const Option&);
-  operator double() const;
+  operator int() const;
   operator std::string() const;
   bool operator==(const char*) const;
 
index 39933ea5e8d0150b6a7472bfad0223829b9e35c0..f6342e5cb57267a50520a1a96050fe15591fe658 100644 (file)
@@ -128,9 +128,9 @@ Option::Option(double v, int minv, int maxv, OnChange f) : type("spin"), min(min
 Option::Option(const char* v, const char* cur, OnChange f) : type("combo"), min(0), max(0), on_change(f)
 { defaultValue = v; currentValue = cur; }
 
-Option::operator double() const {
+Option::operator int() const {
   assert(type == "check" || type == "spin");
-  return (type == "spin" ? stof(currentValue) : currentValue == "true");
+  return (type == "spin" ? std::stoi(currentValue) : currentValue == "true");
 }
 
 Option::operator std::string() const {