]> git.sesse.net Git - stockfish/commitdiff
Fix KingDanger[] array initialization
authorhxim <hxim.jo@gmail.com>
Mon, 9 Feb 2015 18:12:04 +0000 (19:12 +0100)
committerJoona Kiiski <joona.kiiski@gmail.com>
Mon, 9 Feb 2015 22:02:35 +0000 (22:02 +0000)
Use integer arithmetic instead of floating point arithmetic.
Floating point arithmetic was causing different results for some 32-bit compiles

No functional change

Resolves #249
Resolves #250

src/evaluate.cpp

index be3c64977be4b001e70f8a3e57dc324d88da04a0..40d59648f2ed10edf6660befbf0c2eb035feec35 100644 (file)
@@ -912,14 +912,14 @@ namespace Eval {
 
   void init() {
 
-    const double MaxSlope = 8.7;
-    const double Peak = 1280;
-    double t = 0.0;
+    const int MaxSlope = 87;
+    const int Peak = 12800;
+    int t = 0;
 
-    for (int i = 1; i < 400; ++i)
+    for (int i = 0; i < 400; ++i)
     {
-        t = std::min(Peak, std::min(0.027 * i * i, t + MaxSlope));
-        KingDanger[i] = apply_weight(make_score(int(t), 0), Weights[KingSafety]);
+        t = std::min(Peak, std::min(i * i * 27 / 100, t + MaxSlope));
+        KingDanger[i] = apply_weight(make_score(t / 10, 0), Weights[KingSafety]);
     }
   }