Answers.Body: <p>You can do this by sending out MultiPV, something like:</p>
  
  <pre><code>engine = chess.uci.popen_engine(...)
  engine.setoption({ "MultiPV" : multiPV})
  </code></pre>
  
  <p>The module will generate multiple lines for you, as an array.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-11T10:37:19.320Z
Answers.Text: Short and simple! Gotta say, love how you and Phonon (like this [recent stuff](https://chess.stackexchange.com/a/24177/15078)) among others are constantly providing code snippets in these answers, to encourage people to do a bit of scripting/programming on their own, and relying less on commercial-closed-source products.
Answers.UserDisplayName: user929304
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-10T10:26:04.483Z
Answers.LastActivityDate: 2018-11-10T11:34:43.693Z
Answers.LastEditDate: 2018-11-10T11:34:43.693Z
Answers.UserDisplayName: SmallChess
Answers.Body: <p>As the version of python-chess I'm running doesn't support chess.uci, here's what worked for me.</p>
  <pre><code>engine = chess.engine.SimpleEngine.popen_uci(&quot;/path/to/engine.exe&quot;)
  board = chess.Board()
  info = engine.analyse(board, chess.engine.Limit(time=10),multipv=20))
  </code></pre>
  <p>info is a list of InfoDict objects, each with the keys &quot;pv&quot; and &quot;score&quot;, the list of moves in the line, and the evaluation respectively.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-13T07:04:01.383Z
Answers.LastActivityDate: 2021-02-13T07:04:01.383Z
Answers.UserDisplayName: SelfTaughtProgrammer
Body: <p>In python-chess you can communicate with the engine on a given position. However the method presented in <a href="https://python-chess.readthedocs.io/en/latest/uci.html" rel="nofollow noreferrer">https://python-chess.readthedocs.io/en/latest/uci.html</a> using the engine.go() function with only a time parameter returns just one continuation and that continuations evaluation. </p>
  
  <p>I know in most chess programs you can see the top few ranked positions and their evaluations. How can I do the same in python chess? None of the parameters in engine.go seemed to let me do that.</p>
  
Tags: <software><programming><python>
Title: How can I get multiple computer recommended lines in python-chess module?
ThreadText: # How can I get multiple computer recommended lines in python-chess module?
  
  (Asked by: username_0 on 2018-11-10)
  
  In python-chess you can communicate with the engine on a given position. However the method presented in <https://python-chess.readthedocs.io/en/latest/uci.html> using the engine.go() function with only a time parameter returns just one continuation and that continuations evaluation.
  
  I know in most chess programs you can see the top few ranked positions and their evaluations. How can I do the same in python chess? None of the parameters in engine.go seemed to let me do that.
  
  **Tags:** software, programming, python
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-11-10. Score: 4
  
  You can do this by sending out MultiPV, something like:
  engine = chess.uci.popen_engine(...)
  engine.setoption({ "MultiPV" : multiPV})
  
  The module will generate multiple lines for you, as an array.
  
  > **Comments:**
  > **username_2**: Short and simple! Gotta say, love how you and Phonon (like this [recent stuff](https://chess.stackexchange.com/a/24177/15078)) among others are constantly providing code snippets in these answers, to encourage people to do a bit of scripting/programming on their own, and relying less on commercial-closed-source products.  
  
  ---
  
  ### Answer by username_3 on 2021-02-13. Score: 2
  
  As the version of python-chess I'm running doesn't support chess.uci, here's what worked for me.
  engine = chess.engine.SimpleEngine.popen_uci("/path/to/engine.exe")
  board = chess.Board()
  info = engine.analyse(board, chess.engine.Limit(time=10),multipv=20))
  
  info is a list of InfoDict objects, each with the keys "pv" and "score", the list of moves in the line, and the evaluation respectively.
  
  
  ---
  
  