54 #define MASK_BP 0x0000000F // 0- 3: .... .... .... .... .... .... .... 1111 55 #define MASK_BN 0x00000030 // 4- 5: .... .... .... .... .... .... ..11 .... 56 #define MASK_BB 0x000000C0 // 6- 7: .... .... .... .... .... .... 11.. .... 57 #define MASK_BR 0x00000300 // 8- 9: .... .... .... .... .... ..11 .... .... 58 #define MASK_BQ 0x00000C00 //10-11: .... .... .... .... .... 11.. .... .... 59 #define MASK_WP 0x0000F000 //12-15: .... .... .... .... 1111 .... .... .... 60 #define MASK_WN 0x00030000 //16-17: .... .... .... ..11 .... .... .... .... 61 #define MASK_WB 0x000C0000 //18-19: .... .... .... 11.. .... .... .... .... 62 #define MASK_WR 0x00300000 //20-21: .... .... ..11 .... .... .... .... .... 63 #define MASK_WQ 0x00C00000 //29-31: .... .... 11.. .... .... .... .... .... 108 #define MATSIG_FlipColor(x) ((x) >> 12) | (((x) & 0x00000FFF) << 12) 113 #define MATSIG_Has_WQ(x) ((x) & MASK_WQ) 114 #define MATSIG_Has_BQ(x) ((x) & MASK_BQ) 115 #define MATSIG_Has_WR(x) ((x) & MASK_WR) 116 #define MATSIG_Has_BR(x) ((x) & MASK_BR) 117 #define MATSIG_Has_WB(x) ((x) & MASK_WB) 118 #define MATSIG_Has_BB(x) ((x) & MASK_BB) 119 #define MATSIG_Has_WN(x) ((x) & MASK_WN) 120 #define MATSIG_Has_BN(x) ((x) & MASK_BN) 121 #define MATSIG_Has_WP(x) ((x) & MASK_WP) 122 #define MATSIG_Has_BP(x) ((x) & MASK_BP) 124 #define MATSIG_HasQueens(x) ((x) & (MASK_WQ | MASK_BQ)) 125 #define MATSIG_HasRooks(x) ((x) & (MASK_WR | MASK_BR)) 126 #define MATSIG_HasBishops(x) ((x) & (MASK_WB | MASK_BB)) 127 #define MATSIG_HasKnights(x) ((x) & (MASK_WN | MASK_BN)) 128 #define MATSIG_HasPawns(x) ((x) & (MASK_WP | MASK_BP)) 133 #define MATSIG_Count_WQ(x) (((x) & MASK_WQ) >> SHIFT_WQ) 134 #define MATSIG_Count_BQ(x) (((x) & MASK_BQ) >> SHIFT_BQ) 135 #define MATSIG_Count_WR(x) (((x) & MASK_WR) >> SHIFT_WR) 136 #define MATSIG_Count_BR(x) (((x) & MASK_BR) >> SHIFT_BR) 137 #define MATSIG_Count_WB(x) (((x) & MASK_WB) >> SHIFT_WB) 138 #define MATSIG_Count_BB(x) (((x) & MASK_BB) >> SHIFT_BB) 139 #define MATSIG_Count_WN(x) (((x) & MASK_WN) >> SHIFT_WN) 140 #define MATSIG_Count_BN(x) (((x) & MASK_BN) >> SHIFT_BN) 141 #define MATSIG_Count_WP(x) (((x) & MASK_WP) >> SHIFT_WP) 142 #define MATSIG_Count_BP(x) (((x) & MASK_BP) >> SHIFT_BP) 165 if (p !=
PAWN && count > 3)
227 m |= std::min<matSigT>(3, materialCounts[
WQ]) <<
SHIFT_WQ;
228 m |= std::min<matSigT>(3, materialCounts[
WR]) <<
SHIFT_WR;
229 m |= std::min<matSigT>(3, materialCounts[
WB]) <<
SHIFT_WB;
230 m |= std::min<matSigT>(3, materialCounts[
WN]) <<
SHIFT_WN;
232 m |= std::min<matSigT>(3, materialCounts[
BQ]) <<
SHIFT_BQ;
233 m |= std::min<matSigT>(3, materialCounts[
BR]) <<
SHIFT_BR;
234 m |= std::min<matSigT>(3, materialCounts[
BB]) <<
SHIFT_BB;
235 m |= std::min<matSigT>(3, materialCounts[
BN]) <<
SHIFT_BN;
263 static const uint hpSig_bitMask [16] = {
265 0x8000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0400, 0x0200, 0x0100,
267 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
277 if (color ==
BLACK) val += 8;
278 return hpSig | hpSig_bitMask [val];
288 if (color ==
BLACK) val += 8;
289 return hpSig & ~(hpSig_bitMask [val]);
303 if (*b !=
WP) { hpSig |= 0x8000; ++nMoved; } b++;
304 if (*b !=
WP) { hpSig |= 0x4000; ++nMoved; } b++;
305 if (*b !=
WP) { hpSig |= 0x2000; ++nMoved; } b++;
306 if (*b !=
WP) { hpSig |= 0x1000; ++nMoved; } b++;
307 if (*b !=
WP) { hpSig |= 0x0800; ++nMoved; } b++;
308 if (*b !=
WP) { hpSig |= 0x0400; ++nMoved; } b++;
309 if (*b !=
WP) { hpSig |= 0x0200; ++nMoved; } b++;
310 if (*b !=
WP) { hpSig |= 0x0100; ++nMoved; }
312 if (*b !=
BP) { hpSig |= 0x0080; ++nMoved; } b++;
313 if (*b !=
BP) { hpSig |= 0x0040; ++nMoved; } b++;
314 if (*b !=
BP) { hpSig |= 0x0020; ++nMoved; } b++;
315 if (*b !=
BP) { hpSig |= 0x0010; ++nMoved; } b++;
316 if (*b !=
BP) { hpSig |= 0x0008; ++nMoved; } b++;
317 if (*b !=
BP) { hpSig |= 0x0004; ++nMoved; } b++;
318 if (*b !=
BP) { hpSig |= 0x0002; ++nMoved; } b++;
319 if (*b !=
BP) { hpSig |= 0x0001; ++nMoved; }
322 return {
static_cast<uint16_t
>(hpSig), static_cast<uint16_t>(nMoved)};
328 if (*changeList == 16 && nMoved == 16)
330 if (*changeList++ < nMoved)
334 for (
int i = 0, n = nMoved / 2; i < n; ++i) {
335 sig |= 1 << (*changeList >> 4);
336 sig |= 1 << (*changeList++ & 0x0F);
339 sig |= 1 << (*changeList >> 4);
uint hpSig_ClearPawn(uint hpSig, colorT color, fyleT fyle)
uint hpSig_Final(const byte *changeList)
bool hpSig_Prefix(const byte *changeListA, const byte *changeListB)
matSigT matsig_setCount(matSigT m, pieceT p, uint count)
const uint SHIFT_BY_PIECE[16]
const uint HPSIG_StdStart
bool hpSig_match(int hpSig, int nMoved, const byte *changeList)
const matSigT MATSIG_Empty
const matSigT MATSIG_StdStart
uint matsig_getCount(matSigT m, pieceT p)
std::string matsig_makeString(matSigT matsig)
bool matsig_isReachable(matSigT mStart, matSigT mTarget, bool promos, bool upromo)
bool hpSig_PossibleMatch(uint hpSig, const byte *changeList)
bool matsig_isReachablePawns(matSigT mStart, matSigT mTarget)
const matSigT MASK_BY_PIECE[16]
#define MATSIG_Count_WP(x)
#define MATSIG_Count_BP(x)
std::pair< uint16_t, uint16_t > hpSig_make(const pieceT *board)
Creates a 16-bits bitmap of the missing pawns in the home ranks.
uint hpSig_AddPawn(uint hpSig, colorT color, fyleT fyle)
matSigT matsig_Make(const byte *materialCounts)