I'm attempting to use Zobrist hashing in my chess engine, but I'm running into some difficulties getting it to work correctly.
I'm using the random numbers from this site so I can test my results against the answers they have, and for one of the positions I can't figure out what series of XORs need to be performed to get the next correct position.
I'm attempting to go from the "position after e2e4 d7d5 e4e5" (with a hash 662fafb965db29d4) to the "position after e2e4 d7d5 e4e5 f7f5" (with the hash 22a48b5a8e47ff78).
But I can't figure out what series of XORs I need to use to go between the first position's hash key and the second (this is important as I need to incrementally add and remove pieces from the hash correctly for the Zobrist hashing to efficiently work with my engines DoMove and UndoMove functions). As far as I can tell, the black pawn on f7 is XORed away, and then a black pawn at f5 is XORed back. And then the random number for the side to move should be flipped. Here is what I said in pseduo-code:
startingHash = 662fafb965db29d4 startingHash = startingHash XOR random number for pawn at f7 startingHash = startingHash XOR random number for pawn at f5 startingHash = startingHash XOR random number for white to move
But doing this isn't giving 22a48b5a8e47ff78. Any idea where I'm going wrong here? I'm fairly confident I'm using the correct random numbers according to the spec in the link above. And I've already gotten many of the other positions to work as well. But I'm stuck on this one.