I followed your post -leaving out the early bailouts for now.
That works in some cases but not all. E.g. [d] gives 1200.
It's probably due to that threshold. My question now is: what is the value of the threshold compared to the piece values?
Code: Select all
// xy are of the victim
int Scene::getSEE(const int x, const int y, const ChessPiece *const attacker) const
{
const ChessPiece *const victim = b.getAt(x, y);
const PlayerColor c = attacker -> getColor();
// bit 0...15: if set, then a white piece can walk over and/or attack this field, 16...31 black
const uint32_t bits = ss.back().tcs.cells[y][x];
int see_val = victim -> getEvalVal();
int trophy_val = attacker -> getEvalVal();
PlayerColor sc = opponentColor(c);
int so[] = { 0, 16 }; // where to start to search in the bit pattern. so[0] is for white
constexpr int soe[] = { 16, 32 }; // where to stop searching. soe[0] is for white
for(; so[sc] < soe[sc];) {
// find a 1 bit
while((bits & (1 << so[sc])) == 0) {
// if end of pattern, stop searching
if (++so[sc] == soe[sc])
break;
}
if (so[sc] >= soe[sc])
break;
if (sc == c)
see_val += trophy_val;
else
see_val -= trophy_val;
// get eval val. bit number is an index in pieces[color][index] pointing to the
// piece.
trophy_val = sc == WHITE ? pieces[sc][so[sc]] -> getEvalVal() : pieces[sc][so[sc] - 16] -> getEvalVal();
// on to the next bit!
so[sc]++;
sc = opponentColor(sc);
}
return see_val;
}