Nice, I hadn't expected to see two new approaches!
Michael, your approach of effectively replacing a stack of 4 bits with 4 numbers has a certain elegance to it, I'll look into it.
Meanwhile, thinking a bit more about this, I found a bug in my present code:
Jan Brouwer wrote:Code: Select all
state &= board[move.from] & board[move.to] & MASK;
However this requires two types of rook encodings per color, ...
I actually need a 3rd rook encoding for promoted rooks, which doesn't modify the castling rights!
So, could anyone confirm that the following perft counts are now correct?
Code: Select all
position fen 4k3/8/8/8/8/8/R7/R3K2R w KQ - 0 1
perft 3
4893
position fen 4k3/8/8/8/8/8/R7/R3K2R w Q - 0 1
perft 3
4729
position fen 4k3/8/8/8/8/8/R7/R3K2R w K - 0 1
perft 3
4686
position fen 4k3/8/8/8/8/8/R7/R3K2R w - - 0 1
perft 3
4522
They are about a promoted rook move incorrectly modifying castling state:
[d]4k3/8/8/8/8/8/R7/R3K2R w KQ - 0 1