let's start with this declaration
Code: Select all
uint8_t fi[2][8]; // files info
Code: Select all
fi[side][file(sq)] |= 1 << rank(sq);
some examples:
Code: Select all
bool is_on_openf(int sq)
{
return fi[0][file(sq)] + fi[1][file(sq)] == 0;
}
bool is_on_semiopenf(int sq, int side)
{
return fi[side][file(sq)] == 0;
}
// no enemy pawns in front of us
bool free_run(int sq, int side)
{
return fi[side ^ 1][file(sq)] >> rank(sq) == 0;
}
// doubled pawns: more than one bit set on file(sq)
since the bits are ordered by rank from white's POV one could check if a file is greater/lesser than the other one.
the nice thing about this is that the table can be updated incrementally and we don't need to check the board/piece list for pawns because we just run a loop through all the files and apply all the bonuses/maluses.
i have to say that i really using a mailbox representation, the code is simpler and i have to actually use my brain, maybe hgm was right all along...
what do you guys think?