Answers.Body: <p>The volatility of the score here is caused by the time limit you have set. With <code>time=0.100</code> you're restricting the engine to <code>100 milliseconds</code>. With such a small time limit, there are a lot of small factors that can dramatically change the results. You can try increasing the time limit, or instead of using a time limit you can try a <code>depth</code> limit instead. This will make the engine search to a specific depth, rather than searching for a set amount of time. A depth limit will probably make your results more robust.</p>
  
  <p>An example of depth limit would be:</p>
  
  <pre><code>chess.engine.Limit(depth=20)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-19T20:09:02.620Z
Answers.LastActivityDate: 2019-08-19T20:09:02.620Z
Answers.UserDisplayName: Arman
Body: <p>My goal is to make a script to finding the most and least likely move an engine will play, and then make a list it. I tried using the scores to make such a list, with the best score equalling the most likely move,  but every time I got d ifferent scores for the same position. </p>
  
  <p>After compering high-scoring moves with engine moves with the code <code>engine.play(board, chess.engine.Limit(time=0.100))</code>, I noticed that the engine moves are totally different from the move that have the highest score on my outputs.</p>
  
  <p>When I use the same version from my engine, but onvother sites that have the engine installed, I found that it chooses a different move from what my engine script chooses. I know that the engine is  not just a bot who is repeating moves every time, but what's the best way make it as such?</p>
  
  <p>Here is my code if you want to have a look:</p>
  
  <pre><code>import asyncio
  import chess
  #import chess.uci
  import chess.engine
  import chess.pgn
  import io
  from chess.engine import Cp, Mate, MateGiven
  #Let's try our code with the starting position of chess:
  
  fen = 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1'
  board = chess.Board(fen)
  
  
  #Now make sure you give the correct location for your stockfish engine file
  #...in the line that follows: e.g., /home/.../stockfish_6_x64
  
  
  engine = chess.engine.SimpleEngine.popen_uci('/home/shar/Desktop/cheat detect python/stockfish-10-linux/Linux/stockfish_10_x64')
  
  if board.turn: print( 'White to move');
  else: print( 'black to move');
  counter = 0
  while counter &lt; 1:
    # do processing
    counter = counter + 1
  
    result = engine.play(board, chess.engine.Limit(time=0.100))
    print('the engine move',result.move)
  
  #getting legal moves scores part
  for el in board.legal_moves:
  
      pgn = io.StringIO(board.san(el))
  
      thnwpgntofen = chess.pgn.read_game(pgn);
      nwinfo = engine.analyse(thnwpgntofen.board(),chess.engine.Limit(time=0.100));
  
  
  
      print(board.san(el),nwinfo.get("score"), nwinfo.get("depth"))
  
  
  
      print("-------------------------");
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-20T11:23:13.777Z
Comments.Text: This is a chess forum. Why do you expect people to understand code?
Comments.UserDisplayName: David
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-20T12:28:41.790Z
Comments.Text: @David According to the help center (https://chess.stackexchange.com/help/on-topic) "Chess-specific questions about programming a chess engine or other chess software are welcome." There was a vote on this in Meta 4 years ago (https://chess.meta.stackexchange.com/questions/418/we-finally-have-a-scope-poll-closed-programming-questions) and the decision was to allow questions like this.
Comments.UserDisplayName: Brian Towers
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-20T13:15:43.973Z
Comments.Text: @BrianTowers This may sound as a novel concept, but not liking something and wanting something banned are two different things! I am just warning the OP that the people in this community may not have the knowledge to give a good answer
Comments.UserDisplayName: David
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-20T14:28:06.413Z
Comments.Text: @David It is not at all a novel concept although you miss out a third possibility, that of someone voting to close a question. There is one vote to close this question. We both know who cast that vote. I'm just telling you why that vote was denied.
Comments.UserDisplayName: Brian Towers
Tags: <engines><analysis><programming><python>
Title: Python-chess : Are the move scores enough to rank moves from the most to least likely moves played by an engine?
ThreadText: # Python-chess : Are the move scores enough to rank moves from the most to least likely moves played by an engine?
  
  (Asked by: username_0 on 2019-08-08)
  
  My goal is to make a script to finding the most and least likely move an engine will play, and then make a list it. I tried using the scores to make such a list, with the best score equalling the most likely move, but every time I got d ifferent scores for the same position.
  
  After compering high-scoring moves with engine moves with the code `engine.play(board, chess.engine.Limit(time=0.100))`, I noticed that the engine moves are totally different from the move that have the highest score on my outputs.
  
  When I use the same version from my engine, but onvother sites that have the engine installed, I found that it chooses a different move from what my engine script chooses. I know that the engine is not just a bot who is repeating moves every time, but what's the best way make it as such?
  
  Here is my code if you want to have a look:
  
  ```
  import asyncio
  import chess
  #import chess.uci
  import chess.engine
  import chess.pgn
  import io
  from chess.engine import Cp, Mate, MateGiven
  #Let's try our code with the starting position of chess:
  
  fen = 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1'
  board = chess.Board(fen)
  
  #Now make sure you give the correct location for your stockfish engine file
  #...in the line that follows: e.g., /home/.../stockfish_6_x64
  
  engine = chess.engine.SimpleEngine.popen_uci('/home/username_0/Desktop/cheat detect python/stockfish-10-linux/Linux/stockfish_10_x64')
  
  if board.turn: print( 'White to move');
  else: print( 'black to move');
  counter = 0
  while counter < 1:
    # do processing
    counter = counter + 1
  
    result = engine.play(board, chess.engine.Limit(time=0.100))
    print('the engine move',result.move)
  
  #getting legal moves scores part
  for el in board.legal_moves:
  
      pgn = io.StringIO(board.san(el))
  
      thnwpgntofen = chess.pgn.read_game(pgn);
      nwinfo = engine.analyse(thnwpgntofen.board(),chess.engine.Limit(time=0.100));
  
      print(board.san(el),nwinfo.get("score"), nwinfo.get("depth"))
  
      print("-------------------------");
  
  ```
  
  **Tags:** engines, analysis, programming, python
  
  > **Comments:**
  > **username_1**: This is a chess forum. Why do you expect people to understand code?  
  > **username_2**: @username_1 According to the help center (https://chess.stackexchange.com/help/on-topic) "Chess-specific questions about programming a chess engine or other chess software are welcome." There was a vote on this in Meta 4 years ago (https://chess.meta.stackexchange.com/questions/418/we-finally-have-a-scope-poll-closed-programming-questions) and the decision was to allow questions like this.  
  > **username_1**: @username_2 This may sound as a novel concept, but not liking something and wanting something banned are two different things! I am just warning the OP that the people in this community may not have the knowledge to give a good answer  
  > **username_2**: @username_1 It is not at all a novel concept although you miss out a third possibility, that of someone voting to close a question. There is one vote to close this question. We both know who cast that vote. I'm just telling you why that vote was denied.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2019-08-19. Score: 3
  
  The volatility of the score here is caused by the time limit you have set. With `time=0.100` you're restricting the engine to `100 milliseconds`. With such a small time limit, there are a lot of small factors that can dramatically change the results. You can try increasing the time limit, or instead of using a time limit you can try a `depth` limit instead. This will make the engine search to a specific depth, rather than searching for a set amount of time. A depth limit will probably make your results more robust.
  
  An example of depth limit would be:
  
  ```
  chess.engine.Limit(depth=20)
  
  ```
  
  
  ---
  
  