1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Some cleanup after previous big patch

This commit is contained in:
Marco Costalba 2016-05-06 13:05:43 +02:00
parent 6a260a7d66
commit 24338c2c66

View file

@ -676,48 +676,45 @@ int decompress_pairs(PairsData* d, uint64_t idx)
return sympat[3 * sym]; return sympat[3 * sym];
} }
int off_A1H8(Square sq) { return int(rank_of(sq)) - file_of(sq); }
template<typename Entry> template<typename Entry>
bool check_flags(Entry*, File, int) { return true; } bool check_flags(Entry*, File, int) { return true; }
template<> template<>
bool check_flags(DTZEntry* entry, File f, int stm) { bool check_flags(DTZEntry* entry, File f, int stm) {
if (!entry->has_pawns && (entry->piece.flags & 1) != stm && !entry->symmetric) uint8_t flags = entry->has_pawns ? entry->pawn.file[f].flags
return false; : entry->piece.flags;
if (entry->has_pawns && (entry->pawn.file[f].flags & 1) != stm) return (flags & 1) == stm || (entry->symmetric && !entry->has_pawns);
return false;
return true;
} }
template<typename Entry> template<typename Entry>
int update_map(Entry*, File, int res, int) { return res; } int map_score(Entry*, File, int res, int) { return res; }
template<> template<>
int update_map(DTZEntry* entry, File f, int res, int wdl) { int map_score(DTZEntry* entry, File f, int res, int wdl) {
if (!entry->has_pawns) { uint8_t flags = entry->has_pawns ? entry->pawn.file[f].flags
if (entry->piece.flags & 2) : entry->piece.flags;
res = entry->piece.map[entry->piece.map_idx[wdl_to_map[wdl + 2]] + res];
if (!(entry->piece.flags & pa_flags[wdl + 2]) || (wdl & 1)) uint8_t* map = entry->has_pawns ? entry->pawn.map
res *= 2; : entry->piece.map;
} else {
if (entry->pawn.file[f].flags & 2) uint16_t* idx = entry->has_pawns ? entry->pawn.file[f].map_idx
res = entry->pawn.map[entry->pawn.file[f].map_idx[wdl_to_map[wdl + 2]] + res]; : entry->piece.map_idx;
if (flags & 2)
res = map[idx[wdl_to_map[wdl + 2]] + res];
if (!(flags & pa_flags[wdl + 2]) || (wdl & 1))
res *= 2;
if (!(entry->pawn.file[f].flags & pa_flags[wdl + 2]) || (wdl & 1))
res *= 2;
}
return res; return res;
} }
int off_A1H8(Square sq) { return int(rank_of(sq)) - file_of(sq); }
template<typename Entry> template<typename Entry>
uint64_t probe_table(const Position& pos, Entry* entry, int wdl = 0, int* success = nullptr) uint64_t probe_table(const Position& pos, Entry* entry, int wdlScore = 0, int* success = nullptr)
{ {
Square squares[TBPIECES]; Square squares[TBPIECES];
Piece pieces[TBPIECES]; Piece pieces[TBPIECES];
@ -958,23 +955,8 @@ tail:
next += t; next += t;
} }
// Now that we have the index, decompress the pair // Now that we have the index, decompress the pair and get the score
int res = decompress_pairs(precomp, idx); return map_score(entry, tbFile, decompress_pairs(precomp, idx), wdlScore);
return update_map(entry, tbFile, res, wdl);
}
// determine file of leftmost pawn and sort pawns
File pawn_file(uint8_t pawns[], Square *pos)
{
static const File file_to_file[] = {
FILE_A, FILE_B, FILE_C, FILE_D, FILE_D, FILE_C, FILE_B, FILE_A
};
for (int i = 1; i < pawns[0]; ++i)
if (Flap[pos[0]] > Flap[pos[i]])
std::swap(pos[0], pos[i]);
return file_to_file[pos[0] & 7];
} }
template<typename T> template<typename T>