Thanks in advance,
Frank
Note: I'm not a chess engine author (yet), but hope to be someday. Maybe
more experienced programmers have better knowledge than me.
"Frank Hablizel" <frank.h...@gmx.de> wrote in message
news:pan.2003.12.25....@gmx.de...
> is it necessay to include even empty fields in the hash key of a position
> or not?
No, it isn't.
Ok, this means I also need only to xor additional values if castling is
possible (max. 4 values) and one value for each row if ep is possible and
one additional xor if black side is to move. Is this correct?
It sounds reasonable, but I am not a chess programmer.
You must think about your specific design.
As a Go programmer, and with a good understanding of Zobrist hashing,
I could answer your original question with absolute certainty, but your new
question is about implementation details that have no 100% defined yes/no
answer.
You may want to hash in much more stuff, or less, depending on your design.
The more you hash in, the higher potential for hash collisions.
If you code for the en-passant _target_ line, you need
one value at maximum.
Werner
Yes because different castling flags and different en-passant target
squares mean that different moves are available. You should only hash in
the en passant square if an en-passant capture is legal, though.
Dave.
--
David Richerby Mouldy Soap (TM): it's like a personal
www.chiark.greenend.org.uk/~davidr/ hygiene product but it's starting to
grow mushrooms!
It's just as valid to hash in the en-passant row exactly
after a pawn double-move has appeared, no matter if there's
an opponent pawn to actually make the capture. This will
never make two unequal positions hash equal. FEN uses this
method as well.
And you don't really need the field - it's enough to have
the row. It's not even necessary to make a difference between
"ep can happen on e3" and "ep can happen on e6", because
the side-to-move code will always remove the ambiguity.
Saves some bytes which are likely to be in cache and thus
may be valuable.
Regards;
Werner
Any hashing scheme will have two unequal positions hash equal because
the hash key will be smaller than the amount of data that is being
hashed. (If it were not, you'd just use the data itself rather than a
hash.)
You have to be careful about en-passant squares because including en-
passant squares that cannot be used means that two positions that are
the same will have different hashes. Since hashes are often used for
transposition tables, it's rather self-defeating to allow two positions
that result from transpositions of the same moves (e.g., the positions
after 1.d4 Nf6 2.c4 and 1.c4 2.Nf6 2.d4) result in different hashes!
Dave.
--
David Richerby Pickled Zen Boss (TM): it's like a
www.chiark.greenend.org.uk/~davidr/ middle manager that puts you in touch
with the universe but it's preserved
in vinegar!
> You have to be careful about en-passant squares because including en-
> passant squares that cannot be used means that two positions that are
> the same will have different hashes. Since hashes are often used for
> transposition tables, it's rather self-defeating to allow two positions
> that result from transpositions of the same moves (e.g., the positions
> after 1.d4 Nf6 2.c4 and 1.c4 2.Nf6 2.d4) result in different hashes!
I gladly pay a rare hash miss that could have been a hit, in favour
of speed of Zobrist key maintenance (and reduced codesize)
in move/unmove. YMMV, of course.
Werner