]> git.sesse.net Git - stockfish/commit
Fix an off-by-one bug in extract_pv_from_tt
authorMarco Costalba <mcostalba@gmail.com>
Sat, 17 May 2014 20:56:35 +0000 (22:56 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 17 May 2014 20:59:07 +0000 (22:59 +0200)
commit5e03734eacc8e52a6c92be19e73b69ab3e398518
treebc3913b3814a1023c0ee6b99aab05f300d4ccb38
parente46a72dd1df5142cbbbd67ccff9ce2cbd3364450
Fix an off-by-one bug in extract_pv_from_tt

At root we start counting plies from 1,
instead pv[] array starts from 0. So
the variable 'ply' we use in extract_pv_from_tt
to index pv[] is misnamed, indeed it is
not the real ply, but ply-1.

The fix is to leave ply name in extract_pv_from_tt
but assign it the correct start value and
consequentely change all the references to pv[].
Instead in insert_pv_in_tt it's simpler to rename
the misnamed 'ply' in 'idx'.

The off-by-one bug was unhidden when trying to use
'ply' for what it should have been, for instance in
this position:

position fen 8/6R1/8/3k4/8/8/8/2K5 w - - 0 1

at depth 24 mate line is erroneusly truncated due
to value_from_tt() using the wrong ply.

Spotted by Ronald de Man.

bench: 8732553
src/search.cpp