Actually I have always considered that a weakness of the Zobrist scheme: for no clear advantage you cannot see the difference between two pieces on the same square or zero. So in my engines I always use additive Zobrist keys. Then I can place as many pieces as I want on the same square, without creating any ambiguity.Dann Corbit wrote:The magic of the zobrist hash is that it uses xor.
Since you are using xor, the same operation that added a chessman on a square is the operation to subtract the chessman.
That way I need no kludges to hash the holdings of a Crazyhouse or Shogi game. In micro-Max an additional reason was that +- have better operator priorities than ^, so that they would not have to be protected by parentheses everywhere (saving some characters).
@Erick:
MVV sorting in QS (or something at least as good) is way more important than hashing, but it is not always obvious. When you play without something (LVA is a nice refinement, but not essential.) Without it, initially you hardly won't notice anything, perhaps a slowdown of 50% f you are lucky. But almost every game will go through a stage where you get a tremendous search explosion, when you don't sort the captures. You will then see the search depth drop from its normal 11 ply (say) to 3, 2 or sometimes even 1 ply. At that point the engine will play a horibleblunder, of course, so you basically lose every game.