Here's the code again:

u64 encode(Position const &p) { u64 occupied = p.white | p.black; return ((occupied << 1) | BOTTOM_ROW) ^ p.black; }

Hopefully it is clear what `occupied' means. `occupied << 1' means the set of squares that are above an occupied square. I compute the union of that and the bottom row (which is a constant) and now I have the set of all the squares occupied or on top of an occupied one. XORing that with the set of black pieces sets the places with black pieces to 0, leaving the unique number that I described early in this thread.

Is that clear now?

Remember to do something about what I mentioned at the end of post #17.