]> git.sesse.net Git - stockfish/commit
Fix incorrect draw detection
authorMarco Costalba <mcostalba@gmail.com>
Sun, 17 Apr 2016 19:31:19 +0000 (21:31 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 17 Apr 2016 22:13:16 +0000 (00:13 +0200)
commit94e41274bba2d8a2f2d58aaa711df5872309d66c
tree4192b1b992bf6e0ff2a2b29d63d8e8763c74ea9a
parentec6aab01366ba1d2de27084d3cc7415a31aa5a24
Fix incorrect draw detection

In this position we should have draw for repetition:

position fen rnbqkbnr/2pppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 moves g1f3 g8f6 f3g1
go infinite

But latest patch broke it.

Actually we had two(!) very subtle bugs, the first is that Position::set()
clears the passed state and in particular 'previous' member, so
that on passing setupStates, 'previous' pointer was reset.

Second bug is even more subtle: SetupStates was based on std::vector
as container, but when vector grows, std::vector copies all its contents
to a new location invalidating all references to its entries. Because
all StateInfo records are linked by 'previous' pointer, this made pointers
go stale upon adding more element to setupStates. So revert to use a
std::deque that ensures references are preserved when pushing back new
elements.

No functional change.
src/benchmark.cpp
src/position.h
src/thread.cpp
src/uci.cpp