]> git.sesse.net Git - stockfish/commit
Fix material key for King
authorMarco Costalba <mcostalba@gmail.com>
Sun, 16 Feb 2014 10:37:29 +0000 (11:37 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 16 Feb 2014 10:51:30 +0000 (11:51 +0100)
commitd91079d4b02b410702dda082d5c489847f067a35
tree97b2b076ffa41d3e640bf7854f039974d6df5508
parent62c0dc5dea4b3398afbf2bc015e91fdaedfdb81e
Fix material key for King

Currently king has no material key associated because
it can never happen to find a legal position without
both kings, so there is no need to keep track of it.

The consequence is that a position with only the two
kings has material key set at zero and if the material
hash table is empty any entry will match and this is
wrong.

Normally bug is hidden becuase the checking for a draw
with pos.is_draw() is done earlier than evaluate() call,
so that we never check in gameplay the material key of a
position with two kings.

Nevertheless the bug is there and can be reproduced setting
at startup a position with only two kings and typing
'eval' from prompt.

The fix is very simple: add a random key also for the king.

Also fixed the condition in material.cpp to avoid asserting
when a 'just 2 kings' postion is evaluated.

No functional change.
src/material.cpp
src/position.cpp