Answers.Body: <p>You can use the uci <strong>setoption</strong> command or directive to change the engine internal parameters or options.</p>
  <pre><code>* setoption name &lt;id&gt; [value &lt;x&gt;]
      This is sent to the engine when the user wants to change the internal parameters
      of the engine. For the &quot;button&quot; 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 &lt;id&gt; should not be case sensitive and can inlude
      spaces. The substrings &quot;value&quot; and &quot;name&quot; should be avoided in &lt;id&gt; and &lt;x&gt; to allow
      unambiguous parsing, for example do not use &lt;name&gt; = &quot;draw value&quot;.
      Here are some strings for the example below:
         &quot;setoption name Nullmove value true\n&quot;
         &quot;setoption name Selectivity value 3\n&quot;
         &quot;setoption name Style value Risky\n&quot;
         &quot;setoption name Clear Hash\n&quot;
         &quot;setoption name NalimovPath value c:\chess\tb\4;c:\chess\tb\5\n&quot;
  </code></pre>
  <p>In your case this can be:</p>
  <pre><code>stockfish.postMessage(`setoption name multipv value 3`);
  </code></pre>
  <p>This will set the engine to emit its top 3 best lines.</p>
  <p>In the uci specification, <code>multipv</code> is the id, and 3 is the value.</p>
  <h3>Reference:</h3>
  <p><a href="https://github.com/fsmosca/UCIChessEngineProtocol" rel="nofollow noreferrer">UCI protocol</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-29T05:28:25.597Z
Answers.LastActivityDate: 2023-07-29T05:28:25.597Z
Answers.UserDisplayName: ferdy
Body: <p>This is what I have written so far:</p>
  <pre><code>stockfish.postMessage(&quot;uci&quot;);
  stockfish.postMessage(&quot;ucinewgame&quot;);
  stockfish.postMessage(`isready`);
  stockfish.postMessage(`position startpos d2d4`);
  stockfish.postMessage(`go depth 10`);
  </code></pre>
  <p>What this returns is &quot;<code>bestmove e2e4 ponder d7d5</code>&quot;.
  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 <code>multipv</code> but I do not know how to use, please help with examples.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-07-28T14:57:34.097Z
Comments.Text: What language and libraries are you using?
Comments.UserDisplayName: Inertial Ignorance
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-07-28T15:17:44.050Z
Comments.Text: @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.
Comments.UserDisplayName: Vivaan Kumar
Tags: <stockfish><uci>
Title: How to get a list of top number of moves in stockfish uci format?
ThreadText: # How to get a list of top number of moves in stockfish uci format?
  
  (Asked by: username_0 on 2023-07-28)
  
  This is what I have written so far:
  stockfish.postMessage("uci");
  stockfish.postMessage("ucinewgame");
  stockfish.postMessage(`isready`);
  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.
  
  **Tags:** stockfish, uci
  
  > **Comments:**
  > **username_1**: What language and libraries are you using?  
  > **username_0**: @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.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2023-07-29. Score: 1
  
  You can use the uci setoption command or directive to change the engine internal parameters or options.
  * setoption name  [value ]
      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  should not be case sensitive and can inlude
      spaces. The substrings "value" and "name" should be avoided in  and  to allow
      unambiguous parsing, for example do not use  = "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.
  Reference:
  UCI protocol
  
  
  ---
  
  