]> git.sesse.net Git - stockfish/commit
Bugfix of Position::has_repeated()
authorjoergoster <osterj165@googlemail.com>
Fri, 1 Jun 2018 20:35:23 +0000 (22:35 +0200)
committerStéphane Nicolet <cassio@free.fr>
Mon, 4 Jun 2018 05:45:12 +0000 (07:45 +0200)
commitf7bae2de82347c61897b8de62d294dd0e4fc579e
tree895f67c632c9535f51ea0b91586572db43914d7a
parent8ef9bc5a9588c49a9c32f87b025980aed794ecd6
Bugfix of Position::has_repeated()

The function Position::has_repeated() is used by Tablebases::root_probe()
to determine whether we can rank all winning moves with the same value, or
if we need to strictly rank by dtz in case the position has already been
repeated once, and we are risking to run into the 50-move rule and thus
losing the win (especially critical in some very complicated endgames).

To check whether the current position or one of the previous positions
after the last zeroing move has already been occured once, we start looking
for a repetition of the current position, and if that is not the case, we
step one position back and repeat the check for that position, and so on.

If you now look at how this was done before the new root ranking patch was
merged two months ago, it seems quite obvious that it is a simple oversight:
https://github.com/official-stockfish/Stockfish/commit/108f0da4d7f993732aa2e854b8f3fa8ca6d3b46c

More specifically, after we stepped one position back with

```
stc = stc->previous;
```

we now have to start checking for a repetition with

```
StateInfo* stp = stc->previous->previous;
```

and not with

```
StateInfo* stp = st->previous->previous;
```

Closes https://github.com/official-stockfish/Stockfish/pull/1625

No functional change
src/position.cpp