This is what I have written so far:

stockfish.postMessage(`position startpos d2d4`);
stockfish.postMessage(`go depth 10`);

What this returns is "bestmove e2e4 ponder d7d5". But how can I have it so it returns me the top best n number of moves in a list in order rather than just having just best move. I have heard to use something called multipv but I do not know how to use, please help with examples.

  • 2
    What language and libraries are you using? Jul 28, 2023 at 14:57
  • @InertialIgnorance that doesn't really matter, all I want to know is the UCI commands to be able to do so and then I will translate that to stockfish with javascript myself. Jul 28, 2023 at 15:17

1 Answer 1


You can use the uci setoption command or directive to change the engine internal parameters or options.

* setoption name <id> [value <x>]
    This is sent to the engine when the user wants to change the internal parameters
    of the engine. For the "button" type no value is needed.
    One string will be sent for each parameter and this will only be sent when the engine is
    waiting. The name and value of the option in <id> should not be case sensitive and can inlude
    spaces. The substrings "value" and "name" should be avoided in <id> and <x> to allow
    unambiguous parsing, for example do not use <name> = "draw value".
    Here are some strings for the example below:
       "setoption name Nullmove value true\n"
       "setoption name Selectivity value 3\n"
       "setoption name Style value Risky\n"
       "setoption name Clear Hash\n"
       "setoption name NalimovPath value c:\chess\tb\4;c:\chess\tb\5\n"

In your case this can be:

stockfish.postMessage(`setoption name multipv value 3`);

This will set the engine to emit its top 3 best lines.

In the uci specification, multipv is the id, and 3 is the value.


UCI protocol

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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