]> git.sesse.net Git - stockfish/commitdiff
Fix magic boosters conversion
authorMarco Costalba <mcostalba@gmail.com>
Fri, 14 Feb 2014 09:43:37 +0000 (10:43 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 14 Feb 2014 09:43:37 +0000 (10:43 +0100)
Fix small overflow error while converting
magic boosters from right rotate to left rotate,
in particular booster 38 was converted to 4122
instead of the corrcet value 26.

Formula used was:

s1 = original & 63, s2 = (original >> 6) & 63;
new = (64 - s1) | ((64 - s2) << 6);

Instead of:

s1 = original & 63, s2 = (original >> 6) & 63;
new = ((64 - s1) & 63) | (((64 - s2) & 63) << 6);

This has no impact in number of cycles needed, but
just in the resultig number that yields to a rotate
amount bigger than 63.

Spotted by Ehsan Rashid.

No functional change.

src/bitboard.cpp

index b7eed922d10b0badeb0c4580ea34b76e31adaabf..3df7d42546b333935d45cfce913a7330bc6a3c49 100644 (file)
@@ -255,7 +255,7 @@ namespace {
                    Bitboard masks[], unsigned shifts[], Square deltas[], Fn index) {
 
     int MagicBoosters[][8] = { {  969, 1976, 2850,  542, 2069, 2852, 1708,  164 },
-                               { 3101,  552, 3555,  926,  834, 4122, 2131, 1117 } };
+                               { 3101,  552, 3555,  926,  834,   26, 2131, 1117 } };
 
     RKISS rk;
     Bitboard occupancy[4096], reference[4096], edges, b;