# Computer repeating moves?

Where I observed it

[FEN "3k3r/pp1n2R1/2p1bp1p/6p1/2PP1p2/1PBB3P/P4KP1/8 w KQkq - 0 1"]

1.d5 cxd5 2.cxd5 Bxd5 3.Bf5 Nb6 4.Bxf6+ Ke8 5.Bg6+ Kf8 6.Re7 Bc6 7.Rf7+ Kg8

I was using Stockfish/Lichess to analyze 1.d5 cxd5 2.cxd5 Bxd5 3.Bf5 Nb6 (a very silly try to avoid immediate material loss) 4.Bxf6+ Ke8 5.Bg6+ Kf8 6.Re7 Bc6 7.Rf7+ Kg8. I always played out the preferred computer move after a second or two, which lead to the computer repeating moves a few times, trying e.g. Rg7+ followed by Rf7+ or Rc7 first (where I simply would have gobbled the exchange).

This behavior is straight impossible (by game theory) for a "god" computer. My only half-baked explanation is that the computer acts exactly like a human: hey, there must be some mate, let's repeat moves to gain time for analyzing a bit deeper. (But the analysis mode of Lichess doesn't involve time anyway?!)

Can a computer expert tell me why a computer repeats moves in a won position?

• I'm not clear what the question is here. Lichess displays the possible moves in descending order of their evaluation by Stockfish. If two moves have the same evaluation, I don't know how Lichess decides which order to display them in, but maybe it's just arbitrary. Aug 29, 2021 at 16:24
• What do you mean by "This behavior is straight impossible (by game theory) for a "god" computer"? Unless one somehow scores more highly for winning without repeating moves, then it seems perfectly fine to repeat moves along the way to winning. You might like to program your engine to play for the quickest win, but I don't know of anything in "game theory" that says you're obliged to! Perhaps Stockfish does indeed try to play for the quickest win; for that you could try watching Stockfish play, rather than just asking it for a numerical evaluation of the position after each possible next move. Aug 29, 2021 at 16:26
• @JamesMartin: I claimed merely that a repeating move can't have a higher evaluation than the quickest win. (I see what you mean, a "god" computer only has evaluations of +1,0,-1, so nothing speaks against repeating moves.) Aug 30, 2021 at 7:47
• @JamesMartin If we assume that the computer orders moves first by W/D/L, and then by length of game, a win with repeated moves would be ranked lower than one without. Aug 31, 2021 at 5:43
• @Acccumulation Agree! - if you prefer quick wins to slow wins, you will prefer not to repeat moves on the way. In the case of "L", I guess you prefer slow losses to quick losses - and what is your protocol in the case of "D"? Aug 31, 2021 at 10:12

I think this is due, at least in part, to the horizon effect.

I first used Stockfish 14 with depth 20 (in Lucas Chess).

After 1. d5 cxd6 2. cxd5 Bxd5 3. Bf5 Nb6 4. Bxf6+ Ke8 5. Bg6+ Kf8 6. Rf7+ Kg8 7. Rg7+ Kf8, Stockfish 14, using depth 20, rates Rc7 best, at +7.45, with the line

1. Rc7 Kg8 9. Rg7+ Kf8 10. Re7 Bc6 11. Rc7 Kg8 12. Bf5 Bd5 13. Bd4 h5 14. Bxh8 Kxh8 15. Rh7+ Kg8 16. Rxh5 Kf7 17. Rxg5 a5 18. Bb1 a4 19. b4 Bxa2

The position after 9. Rg7+ Kf8 there is the same. So why not 8 Re7 immediately? Stockfish rates 8 Re7 +6.85, with the line

1. Re7 Bc6 9. Rc7 Kg8 10. Bf5 Bd5 11. Bd4 h5 12. Bxh8 Kxh8 13. Rh7+ Kg8 14. Rxh5 Kf7 15. Rxg5 Bc6 {different}

and eventually 21. h7 Nxh7. That is, Stockfish now sees Black's capture of White's h-pawn, which it missed before.

If Stockfish's maximum depth is increased from 20 to 24, Stockfish still see Rc7 as best, but now its line is

1. Rc7 Kg8 9. Bd4 Bc6 10. Bf7+ Kf8 11. Be6 Nd7 12. Bxd7 Bxd7 13. Rxd7 Rg8 14. Bc5+ Ke8 15. Re7+ Kd8 16. Rxb7 Kc8 17. Rxa7 Kb8 18. Rh7 Rd8 19. Ke2 Re8+ 20. Kd2 Rd8+ 21. Kc3 g4 22. hxg4 Rg8 23. Bd6+ Kc8 24. Bxf4 Rxg4

avoiding repetition, bringing White's king closer to the scene of action and with more captures before the horizon, which suggests that still deeper analysis is needed. With depth 27, it sees the above line, but deviating with

1. Rxb7 Rg6 17. Rxa7 h5 18. a4 g4 19. h4 Kc8 20. Rf7 f3 21. gxf3 gxf3 22. a5 Rg2+ 23. Kxf3 Rh2 24. Kg3
• This obviously calls for a follow-up question: Did a computer ever repeated moves forever because the concrete win lie over the horizon and the short-term repeat benefit was higher than the actual winning line? Aug 31, 2021 at 10:53