Thanks for the feedback so far. I will try to reply and change the document accordingly.
Could you explain the square mapping please. Which row and file is A1, H1 A8, H8?
As already indicated A is file 0, row 1 in the usual chess notation is encoded as 0 here.
Is it coded always or only when a second pawn exists to do the ep move?
It is coded only if it can there is a pawn in the correct position to take it, but the capture need not be legal (see Zach's reply)(in other words: your second possibilty).
Could you write explicitely that the zobrist value of castle and enpassant is 0
if the other values do not apply. Dito the whole zobrist value calculation
starts with 0, right?
I will. Thanks.
Is this algorithm free to use in every engine?
I think this algorithm is free to use even for closed source engines.
As you know Polyglot is GPL but the GPL only covers actual code and
not algorithms (the latter can be covered by patents, which luckily have
not appeared for chess engines).
The array Random64 is course taken from the Polyglot source code
but I am pretty sure that a table of random numbers is never covered by
copyright.
A GPL'ed engine can of course take the code directly from polyglot. Others
have to reimplement the algorithm.
Do you have any idea how 'good' these values are? Collisions? Hamming distance?
Not formally. Basically a Zobrist hash function behaves like a random mapping
to a set with 2**64=16x10**18 elements.
If you have an opening book with 10**5 positions then the chance that an individual
position matches one from the opening book is one in 16x10**13 which is very low.
Personally I have never observed a hash collision with a Polyglot opening book.
If you check moves for legality then the chance of a collision is even lower.
If you want to use this hash function as the main hash function of the engine then
you have to take the Birthday paradox into account but this only comes into
play at around 2**32 positions.
Teemy Pudas: your question about castling is a good one. I suspect that in
your position white would still have the "can castle short" flag but I am not
a hundred percent sure. I will check.