]> git.sesse.net Git - stockfish/commitdiff
Logaritmic futility margins
authorMarco Costalba <mcostalba@gmail.com>
Thu, 19 Nov 2009 14:58:22 +0000 (15:58 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 23 Nov 2009 19:59:24 +0000 (20:59 +0100)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/bitboard.cpp
src/bitboard.h
src/search.cpp

index 6f1569250a7fe6681c080733c86370fc32b46f0c..7d86884d12ee51caab40e70e1b14eac56b3f019c 100644 (file)
@@ -366,6 +366,29 @@ Square pop_1st_bit(Bitboard* bb) {
 
 #endif
 
 
 #endif
 
+int bitScanReverse32(uint32_t b)
+{
+   int result = 0;
+
+   if (b > 0xFFFF) {
+      b >>= 16;
+      result += 16;
+   }
+   if (b > 0xFF) {
+      b >>= 8;
+      result += 8;
+   }
+   if (b > 0xF) {
+      b >>= 4;
+      result += 4;
+   }
+   if (b > 0x3) {
+      b >>= 2;
+      result += 2;
+   }
+   return result + (b > 0) + (b > 1);
+}
+
 namespace {
 
   // All functions below are used to precompute various bitboards during
 namespace {
 
   // All functions below are used to precompute various bitboards during
index c0af52269afe5997bb7f73c526c77f3e4322d55e..46f8fbd46a104ad173d80ec73db4608f1f331b73 100644 (file)
@@ -349,6 +349,7 @@ extern Square pop_1st_bit(Bitboard* b);
 
 extern void print_bitboard(Bitboard b);
 extern void init_bitboards();
 
 extern void print_bitboard(Bitboard b);
 extern void init_bitboards();
+extern int bitScanReverse32(uint32_t b);
 
 
 #endif // !defined(BITBOARD_H_INCLUDED)
 
 
 #endif // !defined(BITBOARD_H_INCLUDED)
index b47e26a1c974f73e627adf73754aa4ccc5c70b90..b6029e0c71f4dcd3506092a0695b22a0c0446d4c 100644 (file)
@@ -1417,10 +1417,25 @@ namespace {
       {
           //std::cout << std::endl;
           //for (int d = 2; d < 14; d++)
       {
           //std::cout << std::endl;
           //for (int d = 2; d < 14; d++)
-          //    std::cout << d << ", " << 300 + 2*(1 << (3*d/4)) << std::endl;
+          //    std::cout << d << ", " << 64*(1+bitScanReverse32(d*d)) << std::endl;
 
           //std::cout << std::endl;
 /*
 
           //std::cout << std::endl;
 /*
+            64*(1+bitScanReverse32(d*d))
+
+            2 -> 256 -  256
+            3 -> 288 -  320
+            4 -> 512 -  384
+            5 -> 544 -  384
+            6 -> 592 -  448
+            7 -> 624 -  448
+            8 -> 672 -  512
+            9 -> 704 -  512
+           10 -> 832 -  512
+           11 -> 864 -  512
+           12 -> 928 -  576
+           13 -> 960 -  576
+
             300 + 2*(1 << (3*d/4))
 
             2 -> 256 -  304
             300 + 2*(1 << (3*d/4))
 
             2 -> 256 -  304
@@ -1458,7 +1473,7 @@ namespace {
           {
               if (futilityValue == VALUE_NONE)
                   futilityValue =  evaluate(pos, ei, threadID)
           {
               if (futilityValue == VALUE_NONE)
                   futilityValue =  evaluate(pos, ei, threadID)
-                                 + (300 + 2 * (1 << (3 * int(depth) /4)))
+                                 + 64*(1+bitScanReverse32(int(depth) * int(depth)))
                                  + 4*IncrementalFutilityMargin;
 
               futilityValueScaled = futilityValue - moveCount * IncrementalFutilityMargin;
                                  + 4*IncrementalFutilityMargin;
 
               futilityValueScaled = futilityValue - moveCount * IncrementalFutilityMargin;