Stockfish, go movetime

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

Fulvio
Posts: 395
Joined: Fri Aug 12, 2016 8:43 pm

Stockfish, go movetime

Post by Fulvio »

I had a quick glance at the code, but I'm not sure I figured it out correctly.

Starting with the command

Code: Select all

go movetime 5000
lets assume that Stockfish completed depth 20 with bestmove (PV) e2e4 and second best d2d4.

Now moving to depth 21, the new evaluation of e2e4 is now worst than d2d4 (at depth 20), but the evaluation of d2d4 at depth 21 is interrupted by the time limit and incomplete.

Which is the "bestmove" output? d2d4 or e2e4?
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Stockfish, go movetime

Post by hgm »

Normally you would not know what the second-best move is (at d=20), and even in cases where you could know (because the PV switched away from it in the previous iteration), engines would normally not remember it. So I expect it to play e2e4.

It is a good question whether gambling that a second-best move would not suffer a similar score drop on the average would pay off. I expect that this has never been tested, because fixed time per move is not a popular TC. With flexible TC you would simply allocate extra time in a situation like this. There are no rating lists fore fixed time per move, so there is no Elo to earn by optimizing this.

Perhaps Shogi engine developers have tested this; there byoyomi TC, which after some initial time becomes fixed time per move, is the standard TC in human play.
User avatar
Ovyron
Posts: 4556
Joined: Tue Jul 03, 2007 4:30 am

Re: Stockfish, go movetime

Post by Ovyron »

It is my understanding that the Houdini chess engine used to do something like this: if the best move failed below some margin (say, e2e4), then it'd go to an earlier depth to check if another move was better (say, d2d4 is now better than e2e4).

So, suppose e2e4 at depth 21 is worse than d2d4 at depth 18, what Houdini would do is making d2d4 the main move, and "reduce depth" back to 19. With all the hash entries already for d2d4, Houdini will reach depth 21 again faster.

If while Houdini is doing all this, it's time to make a move, it'd then move d2d4, being aware that at this point in time it's better than e2e4.

I've never seen another engine do some main move switching like this or to reduce depth.

However, later Houdini versions did no longer do this, and they'd keep e2e4 until d2d4 proved itself better at depth 21, not caring if d2d4 looks way better at depth 20 or whatever.

So it seems this was an experiment, but all engines have it right: what matters is the current iteration, don't switch to some other move that looked better before, until it looks better in this iteration.
Your beliefs create your reality, so be careful what you wish for.
Fulvio
Posts: 395
Joined: Fri Aug 12, 2016 8:43 pm

Re: Stockfish, go movetime

Post by Fulvio »

hgm wrote:Normally you would not know what the second-best move is (at d=20), and even in cases where you could know (because the PV switched away from it in the previous iteration), engines would normally not remember it. So I expect it to play e2e4.
I suspect it depends on how bad is the evaluation of e2e4.
If it is slightly worse bestmove will be e2e4.
However if it fall outside of the aspiration window the moves are resorted
https://github.com/official-stockfish/S ... h.cpp#L388
and i think bestmove will be d2d4, even if the iteration at depth 21 is not completed.

I hope that someone with a better knowledge of Stockfish's code can clarify this.