Answers.Body: <p>Everything works perfectly.</p>
  
  <ul>
  <li>You should add 50 move counter to your FEN, but this is not the biggest issue.</li>
  <li>The <code>eval</code> command returns a <strong>static</strong> evaluation of your position. It <strong>doesn't</strong> start the search, that's why Stockfish gave you back the results immediately.</li>
  </ul>
  
  <p>Try this:</p>
  
  <pre><code>ucinewgame
  position fen rnbqkbnr/pppp1ppp/8/4p3/6P1/5P2/PPPPP2P/RNBQKBNR b KQkq - 0 1
  go movetime 1000
  </code></pre>
  
  <p>The engine gives you back mate in one:</p>
  
  <pre><code>info depth 126 seldepth 2 multipv 1 score mate 1 nodes 3781 nps 945250 tbhits 0 time 4 pv d8h4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-21T16:37:48.467Z
Answers.Text: Ok, I need to store the score with FEN... If i dont use EVAL, I cant get score. Using GO will return a long list of string.
Answers.UserDisplayName: Telenoobies
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-21T17:26:05.503Z
Answers.Text: I've also said that GO is working. But EVAL is not. EVAL crashes, and gives wrong numbers. What does static evaluation mean? Its either mate in 1 or its not.
Answers.UserDisplayName: Telenoobies
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-21T17:36:42.200Z
Answers.Text: In this case, static means it just evaluates the position without generating any moves.
Answers.UserDisplayName: Herb
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-21T17:50:02.393Z
Answers.Text: I see... well what should I do? I have a FEN file of a few thousand positions. And I need to get the score for each of the position... and store it in CSV format.
Answers.UserDisplayName: Telenoobies
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-21T23:09:40.070Z
Answers.Text: @Telenoobies You need to parse the `info depth` lines. Please take a look at the UCI protocol. The score is just `score mate 1` in this example.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-21T23:13:02.397Z
Answers.Text: Is there a way to get stockfish to just return 1 line. when I do `Go` it returns a bunch of `info depth` lines, and I have no idea which one is the best line.. I only want 1 line and 1 number...
Answers.UserDisplayName: Telenoobies
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-21T23:26:41.983Z
Answers.Text: Another problem is. My file has MILLIONS of FEN positions that i want to parse... using `go` will be very slow. Not sure if its feasible.
Answers.UserDisplayName: Telenoobies
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-22T01:37:27.383Z
Answers.Text: @Telenoobies you will need to parse the last line for info depth. You have no choice but to run million analysis. You can do it multicore.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-22T04:56:22.863Z
Answers.Text: It doesnt work, because the last line is BESTMOVE, and doesnt show score. Like I said, I have more than a million positions, there is no way I can spend more than 1 second per FEN. Also `eval` crashes the engine on certain positions, like the last one I posted.
Answers.UserDisplayName: Telenoobies
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-22T07:46:06.250Z
Answers.Text: @Telenoobies It works. You need the last `info depth` line. Your FEN was invalid, so `the eval` command crashed. You must analyze for each position, static evaluation won't work.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-22T17:22:12.487Z
Answers.Text: https://en.lichess.org/editor/1b1B1k2/8/2B1p1p1/3n1p2/4KP2/6P1/8/8_w
  
  This is the last fen I posted that crashed the program. Seems to me to work fine. You don't need a 50 move counter... I've tested using other positions.
Answers.UserDisplayName: Telenoobies
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-22T17:35:30.120Z
Answers.Text: `position fen 1b1B1k2/8/2B1p1p1/3n1p2/4KP2/6P1/8/8 w - - 0 43`
  `go` WOrks just fine, but `eval` breaks. I dont know what u are talking about mate. Did you even try the steps I took?
Answers.UserDisplayName: Telenoobies
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-21T09:14:00.603Z
Answers.LastActivityDate: 2017-01-21T09:14:00.603Z
Answers.UserDisplayName: SmallChess
Body: <p>I asked the same question on Stockfish's forum.</p>
  
  <p>Black to move in the classic scholar's mate position. mate in 1. Engine produce erroneous results?</p>
  
  <pre><code>position fen rnbqkbnr/pppp1ppp/8/4p3/6P1/5P2/PPPPP2P/RNBQKBNR b KQkq -
  
  eval
  
  Total Evaluation: -0.85 (white side)
  </code></pre>
  
  <p>Same position, except black checkmated white. White to move:</p>
  
  <pre><code>position fen rnb1kbnr/pppp1ppp/8/4p3/6Pq/5P2/PPPPP2P/RNBQKBNR w KQkq -
  
  eval
  
  Debug error! abort() has been called
  </code></pre>
  
  <p>Here is another position that crashes:</p>
  
  <pre><code>1b1B1k2/8/2B1p1p1/3n1p2/4KP2/6P1/8/8 w
  eval
  </code></pre>
  
  <p><code>Go</code> seems to work properly, showing that its mate in 1, and checkmate. However <code>eval</code> is not showing the correct numbers.</p>
  
  <p>Or am I misunderstanding something here?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-21T06:49:05.433Z
Comments.Text: Your fens are invalid. Look at it again, you need the 50 move counter.
Comments.UserDisplayName: SmallChess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-21T07:28:14.550Z
Comments.Text: Even with 50 move counter it still doesnt work.
Comments.UserDisplayName: Telenoobies
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-22T07:48:22.127Z
Comments.Text: I've voted to close the question because I've answered the question but in the comments the OP insisted and clearly had little idea on what he was doing. In particular, he was trying to make static evaluation work which is not possible. Search engine needs to think. There is no chance this question can be answered, you just can't analyze with just a static evaluator.
Comments.UserDisplayName: SmallChess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-22T17:22:41.393Z
Comments.Text: If I knew exactly what I was doing, I wouldn't be asking a question now would I?
Comments.UserDisplayName: Telenoobies
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-23T05:13:39.903Z
Comments.Text: You need to search, most likely more than a second. Forget `eval`, it is not designed for evaluating a FEN. I know you have million positions, but that doesn't change that you still have to search. You could search with multi-core, rent some clusters on Amazon to speed up.
Comments.UserDisplayName: SmallChess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-23T22:39:28.110Z
Comments.Text: Well, I found out why eval was crashing on certain positions. Apparently Eval will not evaluate position that are under check.
Comments.UserDisplayName: Telenoobies
Tags: <engines><stockfish>
Title: Stockfish crashing on checkmate positions, and erroneous evaluation
ThreadText: # Stockfish crashing on checkmate positions, and erroneous evaluation
  
  (Asked by: username_0 on 2017-01-21)
  
  I asked the same question on Stockfish's forum.
  Black to move in the classic scholar's mate position. mate in 1. Engine produce erroneous results?
  position fen rnbqkbnr/pppp1ppp/8/4p3/6P1/5P2/PPPPP2P/RNBQKBNR b KQkq -
  
  eval
  
  Total Evaluation: -0.85 (white side)
  
  Same position, except black checkmated white. White to move:
  position fen rnb1kbnr/pppp1ppp/8/4p3/6Pq/5P2/PPPPP2P/RNBQKBNR w KQkq -
  
  eval
  
  Debug error! abort() has been called
  
  Here is another position that crashes:
  1b1B1k2/8/2B1p1p1/3n1p2/4KP2/6P1/8/8 w
  eval
  
  Go seems to work properly, showing that its mate in 1, and checkmate. However eval is not showing the correct numbers.
  Or am I misunderstanding something here?
  
  **Tags:** engines, stockfish
  
  > **Comments:**
  > **username_1**: Your fens are invalid. Look at it again, you need the 50 move counter.  
  > **username_0**: Even with 50 move counter it still doesnt work.  
  > **username_1**: I've voted to close the question because I've answered the question but in the comments the OP insisted and clearly had little idea on what he was doing. In particular, he was trying to make static evaluation work which is not possible. Search engine needs to think. There is no chance this question can be answered, you just can't analyze with just a static evaluator.  
  > **username_0**: If I knew exactly what I was doing, I wouldn't be asking a question now would I?  
  > **username_1**: You need to search, most likely more than a second. Forget `eval`, it is not designed for evaluating a FEN. I know you have million positions, but that doesn't change that you still have to search. You could search with multi-core, rent some clusters on Amazon to speed up.  
  > **username_0**: Well, I found out why eval was crashing on certain positions. Apparently Eval will not evaluate position that are under check.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-01-21. Score: 0 | Accepted answer
  
  Everything works perfectly.
  
  You should add 50 move counter to your FEN, but this is not the biggest issue.
  The eval command returns a static evaluation of your position. It doesn't start the search, that's why Stockfish gave you back the results immediately.
  
  Try this:
  ucinewgame
  position fen rnbqkbnr/pppp1ppp/8/4p3/6P1/5P2/PPPPP2P/RNBQKBNR b KQkq - 0 1
  go movetime 1000
  
  The engine gives you back mate in one:
  info depth 126 seldepth 2 multipv 1 score mate 1 nodes 3781 nps 945250 tbhits 0 time 4 pv d8h4
  
  > **Comments:**
  > **username_0**: Ok, I need to store the score with FEN... If i dont use EVAL, I cant get score. Using GO will return a long list of string.  
  > **username_0**: I've also said that GO is working. But EVAL is not. EVAL crashes, and gives wrong numbers. What does static evaluation mean? Its either mate in 1 or its not.  
  > **username_2**: In this case, static means it just evaluates the position without generating any moves.  
  > **username_0**: I see... well what should I do? I have a FEN file of a few thousand positions. And I need to get the score for each of the position... and store it in CSV format.  
  > **username_1**: @username_0 You need to parse the `info depth` lines. Please take a look at the UCI protocol. The score is just `score mate 1` in this example.  
  > **username_0**: Is there a way to get stockfish to just return 1 line. when I do `Go` it returns a bunch of `info depth` lines, and I have no idea which one is the best line.. I only want 1 line and 1 number...  
  > **username_0**: Another problem is. My file has MILLIONS of FEN positions that i want to parse... using `go` will be very slow. Not sure if its feasible.  
  > **username_1**: @username_0 you will need to parse the last line for info depth. You have no choice but to run million analysis. You can do it multicore.  
  > **username_0**: It doesnt work, because the last line is BESTMOVE, and doesnt show score. Like I said, I have more than a million positions, there is no way I can spend more than 1 second per FEN. Also `eval` crashes the engine on certain positions, like the last one I posted.  
  > **username_1**: @username_0 It works. You need the last `info depth` line. Your FEN was invalid, so `the eval` command crashed. You must analyze for each position, static evaluation won't work.  
  > **username_0**: https://en.lichess.org/editor/1b1B1k2/8/2B1p1p1/3n1p2/4KP2/6P1/8/8_w  This is the last fen I posted that crashed the program. Seems to me to work fine. You don't need a 50 move counter... I've tested using other positions.  
  > **username_0**: `position fen 1b1B1k2/8/2B1p1p1/3n1p2/4KP2/6P1/8/8 w - - 0 43` `go` WOrks just fine, but `eval` breaks. I dont know what u are talking about mate. Did you even try the steps I took?  
  
  ---
  
  