Open osvitashev opened 3 years ago
@osvitashev Thanks for spotting this (and sorry for the long delay, I've returned after quite a while). You are absolutely correct regarding the special state zobrist keys, I had put those off until the Position::set function worked completely correctly (it currently doesn't, see https://github.com/nkarve/surge/issues/17). I will try and implement this soon, exactly as you suggest (4 keys for castling, 1 for side to play and 8 for EP file).
Consider the following code snippet:
The two positions end up having the same hash key. The two positions share placement of pieces on the board, but they do not represent the same game state: the side-to-move is different, so is castling availability. Some key collisions are inevitable, but ideally they would happen between entirely different board positions, rather than the ones that are superficially similar.
I believe the classic solution to this is to have an extra number of Zobrist keys to represent game state parameters such as 'white to move', 'black can castle on queen side', 'en passant available on c-file', and so on.
... Thoughts?