-WDLEntry::WDLEntry(const std::string& code) {
-
- StateInfo st;
- Position pos;
-
- memset(this, 0, sizeof(WDLEntry));
-
- ready = false;
- key = pos.set(code, WHITE, &st).material_key();
- pieceCount = popcount(pos.pieces());
- hasPawns = pos.pieces(PAWN);
-
- for (Color c = WHITE; c <= BLACK; ++c)
- for (PieceType pt = PAWN; pt < KING; ++pt)
- if (popcount(pos.pieces(c, pt)) == 1)
- hasUniquePieces = true;
-
- if (hasPawns) {
- // Set the leading color. In case both sides have pawns the leading color
- // is the side with less pawns because this leads to better compression.
- bool c = !pos.count<PAWN>(BLACK)
- || ( pos.count<PAWN>(WHITE)
- && pos.count<PAWN>(BLACK) >= pos.count<PAWN>(WHITE));
-
- pawnTable.pawnCount[0] = pos.count<PAWN>(c ? WHITE : BLACK);
- pawnTable.pawnCount[1] = pos.count<PAWN>(c ? BLACK : WHITE);
- }
-
- key2 = pos.set(code, BLACK, &st).material_key();
-}
-
-WDLEntry::~WDLEntry() {
-
- if (baseAddress)
- TBFile::unmap(baseAddress, mapping);
-
- for (int i = 0; i < 2; ++i)
- if (hasPawns)
- for (File f = FILE_A; f <= FILE_D; ++f)
- delete pawnTable.file[i][f].precomp;
- else
- delete pieceTable[i].precomp;
-}
-
-DTZEntry::DTZEntry(const WDLEntry& wdl) {
-
- memset(this, 0, sizeof(DTZEntry));
-
- ready = false;
- key = wdl.key;
- key2 = wdl.key2;
- pieceCount = wdl.pieceCount;
- hasPawns = wdl.hasPawns;
- hasUniquePieces = wdl.hasUniquePieces;
-
- if (hasPawns) {
- pawnTable.pawnCount[0] = wdl.pawnTable.pawnCount[0];
- pawnTable.pawnCount[1] = wdl.pawnTable.pawnCount[1];
- }
-}
-
-DTZEntry::~DTZEntry() {
-