0

Playing against the computer I’d like to be able to go back and try different moves to see how they effect the game, however each time I go back again and repeat my previous positions the computer moves differently.

I’m looking for a ‘stupid’ computer that responds the same to a position each time. Then I can try different combinations to beat it in as few moves as possible.

I play on web and iOS.

3 Answers 3

2

I dug around for a bit and it seems it's surprisingly less straightforward than I thought. I don't know about other engines, but much of the randomness of eg. Stockfish and Leela Chess Zero comes from the time control and multi threading. It's surprisingly hard to make multi-threading search code deterministic, and since computer timers aren't perfectly precise, time control can introduce randomness by changing number of nodes searched even if the search itself was deterministic if the search is only given a certain amount of wall clock time as opposed to number of nodes.

It seems both Stockfish and lc0 running with a single thread and with a time control of a fixed number of nodes (instead of wall clock time) are deterministic. (For example, according to Wikipedia on lc0: Setting up the engine to play a single node with --minibatch-size=1 and go nodes 1 for each played move creates deterministic play, and Self-Play Elo on such settings will always yield the same result between 2 of the same networks on the same start position—always win, always loss, or always draw. See also Randomness in engine play) It's possible to control the number of nodes searched, but this feature is rarely used and not available as an option on popular platforms/apps such as chess.com, Lichess or Smallfish for iOS when playing against the computer. I haven't found a good simple way to do this yet, and if there's no existing solution, the easiest way might be to set up your own local engine (can be web-based) and give it the correct parameters to make it deterministic. Lichess does have a few bots based on lc0 that claim to not use calculation (I guess this means only using one node so should take out the randomness), such as https://lichess.org/@/LazyBotJr but I'm not sure if it's how it works, and anyway it's not very strong and the strength can't be adjusted.

Edit: I found another possible solution: it seems Fairy-Stockfish Playground (https://fairyground.vercel.app/advanced.html) has advanced options that allow setting the number of nodes to search. Yes, it's mainly for chess variants, but by default it plays normal chess if you don't choose a variant. You can try setting the number of nodes in Settings (in one of the input boxes marked "Nodes") and setting number of threads to 1 (input box marked "Thread") and enable engine for White or Black and play it.

4
  • I’ll look into old emulators, maybe there are GBA chess engines that are single tread.
    – OrigamiEye
    Commented Jun 22 at 6:54
  • @OrigamiEye It seems Chessmaster on GBA is not deterministic because its search is limited by time/hardware rather than number of nodes according to gamefaqs.gamespot.com/gba/567124-chessmaster/faqs/38373 ("Personality ratings change ... based upon the processor speed, current memory usage, and RAM available to the engine") It may be somewhat more predictable than multi-threaded engines but likely not truly deterministic. I tested fairy-stockfish playground and it works and gives the same result on different devices if I set it to the same number of nodes and 1 thread. Commented Jun 22 at 8:21
  • In a drawn endgame, it might be the case multiple moves are equally good (they result in a draw) so the engine might pick one at random. Commented Jun 22 at 10:50
  • @Lucenaposition I don't know about others but Stockfish uses pseudorandomness based on number of nodes, so if you set number of nodes it is deterministic. see chess.stackexchange.com/questions/25278 Commented Jun 22 at 15:39
0

A chess engine on PC is almost deterministic in its move results if...

You play with 1 thread only;

you switch off all parameters that guide move variety like Position Learning, Book Learning, Hashtables, MultiPV;

keep the usage of Endgame Tablebases on;

if possible switch off NNUE and MCTS to force the computer to use its own coded routines (not possible with every engine.)

Despite of all that, some engines have a randomness in their code with which they process the possible moves, some make a ranking hitlist after the main calculated variation that is different each time, in this case you cannot get a secure repetition of a move in a specific time frame. You would also have in each case to make the computer move after a fixed time bypassing the variety of different response times - as said above, best is to set a precise nodes-per-move calculation.

So far for my answer, but commenting on your "go back and try different moves to see how they effect the game", I don't think that doing all this is really necessary for that purpose.

0

Most engines do in my experience. Its just that nowadays the devs fiddle the source code in a way that it's not the same repetitive straight track. In most GUIs, you should see the pgn. Try going back to that same move in that visible pgn and make another move. That should work. Hope this helps!

Not the answer you're looking for? Browse other questions tagged or ask your own question.