It turns out that the 1st test can be folded into the 2nd test with the proper encoding. By assigning the last 2 bits of the token for a piece to convey color as follows:
Code: Select all
0 empty square
1 white piece
2 black piece
3 out of bounds
Now when you want to determine whether a black Queen can move to sq, you would do the test to see if it contains a piece of the same color as follows:
Code: Select all
board[sq]&2
With 0x88, you would have to do 2 tests to produce the same result:
Code: Select all
sq&0x88
board[sq]&1
Since, the 1st test with 0x88 usually returns an inbounds result, you don't usually save yourself from having to access the board, so skipping this 1st test works out well.