]> git.sesse.net Git - stockfish/commitdiff
More readable init of MS1BTable[]
authorMarco Costalba <mcostalba@gmail.com>
Sat, 7 Dec 2013 10:33:31 +0000 (11:33 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 7 Dec 2013 10:35:26 +0000 (11:35 +0100)
Because now it uses lsb(), the BSFTable[] must be
already initialized.

No functional change.

src/bitboard.cpp

index 3597e7d830fe4d79cc0f1da4ebce5bbb78748548..fd3db6715b6e15278a5c8d382d37798132adc37b 100644 (file)
@@ -151,13 +151,12 @@ const std::string Bitboards::pretty(Bitboard b) {
 
 void Bitboards::init() {
 
 
 void Bitboards::init() {
 
-  for (int k = 0, i = 0; i < 8; ++i)
-      while (k < (2 << i))
-          MS1BTable[k++] = i;
-
   for (Square s = SQ_A1; s <= SQ_H8; ++s)
       BSFTable[bsf_index(SquareBB[s] = 1ULL << s)] = s;
 
   for (Square s = SQ_A1; s <= SQ_H8; ++s)
       BSFTable[bsf_index(SquareBB[s] = 1ULL << s)] = s;
 
+  for (Bitboard b = 1; b < 256; ++b)
+      MS1BTable[b] = more_than_one(b) ? MS1BTable[b - 1] : lsb(b);
+
   FileBB[FILE_A] = FileABB;
   RankBB[RANK_1] = Rank1BB;
 
   FileBB[FILE_A] = FileABB;
   RankBB[RANK_1] = Rank1BB;