*/
#include <algorithm>
-#include <cstring>
-#include <sstream>
+#include <cstring> // For memset
#include "bitboard.h"
#include "bitcount.h"
const std::string Bitboards::pretty(Bitboard b) {
- std::ostringstream ss;
+ std::string s = "+---+---+---+---+---+---+---+---+\n";
- for (Rank rank = RANK_8; rank >= RANK_1; --rank)
+ for (Rank r = RANK_8; r >= RANK_1; --r)
{
- ss << "+---+---+---+---+---+---+---+---+" << '\n';
+ for (File f = FILE_A; f <= FILE_H; ++f)
+ s.append(b & make_square(f, r) ? "| X " : "| ");
- for (File file = FILE_A; file <= FILE_H; ++file)
- ss << "| " << (b & (file | rank) ? "X " : " ");
-
- ss << "|\n";
+ s.append("|\n+---+---+---+---+---+---+---+---+\n");
}
- ss << "+---+---+---+---+---+---+---+---+";
- return ss.str();
+
+ return s;
}
b = size = 0;
do {
occupancy[size] = b;
- reference[size++] = sliding_attack(deltas, s, b);
+ reference[size] = sliding_attack(deltas, s, b);
+
+ if (HasPext)
+ attacks[s][_pext_u64(b, masks[s])] = reference[size];
+
+ size++;
b = (b - masks[s]) & masks[s];
} while (b);
if (s < SQ_H8)
attacks[s + 1] = attacks[s] + size;
+ if (HasPext)
+ continue;
+
booster = MagicBoosters[Is64Bit][rank_of(s)];
// Find a magic for square 's' picking up an (almost) random number