Answers.Body: <p>I'm not sure what exactly happened, but looking through the <a href="https://github.com/official-stockfish/Stockfish/blob/master/src/uci.cpp" rel="nofollow noreferrer">source code</a>, it appears your first token (<code>setoption</code>) is corrupted or not read properly.</p>
  
  <p>Have you modified the code yourself? If so, please revert all your changes.
  Please double and triple check the source code where you compile Stockfish.</p>
  
  <blockquote>
    <p>As on the very initialisation it doesn't work for me.</p>
  </blockquote>
  
  <p>You don't need to initialise anything to make SF work. The common <code>uci</code> is absolutely useless (look in the source code to convince yourself). There is nothing you should need to do to initalize the engine.</p>
  
  <p>I believe the problem was in how you compiled the engine. There's not enough information here for me to give you a complete answer.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-26T06:18:40.163Z
Answers.Text: I am using the precompiled binaries of SF9 which are part of public download. I didn't do anything with the source code. If I recall, there's no line I am sending to SF prior to the non working setoption statement. It starts to work after set position, go infinite and stop commands.
Answers.UserDisplayName: hoacin
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-26T06:26:42.367Z
Answers.Text: @hoacin If that's the case, why not send the options only after giving the initial position? Problem solved!
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-26T00:48:33.577Z
Answers.LastActivityDate: 2018-09-26T09:54:07.540Z
Answers.LastEditDate: 2018-09-26T09:54:07.540Z
Answers.UserDisplayName: SmallChess
Answers.Body: <p>Stockfish <strong>ignores</strong> any <strong>first command</strong> I send to him. Don't know why. Probably I do something wrong when I initialize I/O redirection. This works perfectly to me.</p>
  
  <pre><code>stockfish.SendLine("Hello Stockfish!");
  stockfish.SendLine("setoption name Threads value " + threads.ToString());
  </code></pre>
  
  <p>Just posting this answer as setting up number of threads as first command is quite logical thing to do. Stockfish replying "Unknown command: setoption name Threads value 3" is pretty misleading, taking into account that rest of communication works.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-26T18:56:59.943Z
Answers.LastActivityDate: 2018-09-26T18:56:59.943Z
Answers.UserDisplayName: hoacin
Body: <p>How is number of threads to use written on <strong>Android</strong> versions of <strong>Stockfish</strong>? Whole communication works but somehow I still can't change number of threads. I even have working code for PC version of Stockfish where changing number of threads works.</p>
  
  <p>This is what I do:</p>
  
  <pre><code>SendLine("setoption name Threads value " + threads.ToString());
  </code></pre>
  
  <p>And this is what I get as a reply from Stockfish...</p>
  
  <blockquote>
    <p>"Unknown command: setoption name Threads value 3"</p>
  </blockquote>
  
  <p>When I send the same line with multiPV, Stockfish does everything as expected, sending desired number of PVs.</p>
  
  <p>Is there something to consider when changing number of threads? Something that must be done prior to sending this command? Or is another command expected?</p>
  
  <p><strong>EDIT:</strong> I checked that when I "later" send meaningless line <em>'setoption name abc value true'</em> it returns different text "No such option: abc". While the engine is silent when sending number of threads "later". So I expect it actually works after some time, so my question is, what must be done before sending command to change number of threads? <strong>As on the very initialisation it doesn't work for me.</strong></p>
  
Tags: <engines><stockfish><programming>
Title: Android Stockfish communication works differently than on PC?
ThreadText: # Android Stockfish communication works differently than on PC?
  
  (Asked by: username_0 on 2018-09-25)
  
  How is number of threads to use written on Android versions of Stockfish? Whole communication works but somehow I still can't change number of threads. I even have working code for PC version of Stockfish where changing number of threads works.
  This is what I do:
  SendLine("setoption name Threads value " + threads.ToString());
  
  And this is what I get as a reply from Stockfish...
  
  "Unknown command: setoption name Threads value 3"
  
  When I send the same line with multiPV, Stockfish does everything as expected, sending desired number of PVs.
  Is there something to consider when changing number of threads? Something that must be done prior to sending this command? Or is another command expected?
  EDIT: I checked that when I "later" send meaningless line 'setoption name abc value true' it returns different text "No such option: abc". While the engine is silent when sending number of threads "later". So I expect it actually works after some time, so my question is, what must be done before sending command to change number of threads? As on the very initialisation it doesn't work for me.
  
  **Tags:** engines, stockfish, programming
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-09-26. Score: 1 | Accepted answer
  
  I'm not sure what exactly happened, but looking through the [source code](https://github.com/official-stockfish/Stockfish/blob/master/src/uci.cpp), it appears your first token (`setoption`) is corrupted or not read properly.
  
  Have you modified the code yourself? If so, please revert all your changes.
  Please double and triple check the source code where you compile Stockfish.
  
  > As on the very initialisation it doesn't work for me.
  
  You don't need to initialise anything to make SF work. The common `uci` is absolutely useless (look in the source code to convince yourself). There is nothing you should need to do to initalize the engine.
  
  I believe the problem was in how you compiled the engine. There's not enough information here for me to give you a complete answer.
  
  > **Comments:**
  > **username_0**: I am using the precompiled binaries of SF9 which are part of public download. I didn't do anything with the source code. If I recall, there's no line I am sending to SF prior to the non working setoption statement. It starts to work after set position, go infinite and stop commands.  
  > **username_1**: @username_0 If that's the case, why not send the options only after giving the initial position? Problem solved!  
  
  ---
  
  ### Answer by username_0 on 2018-09-26. Score: 0
  
  Stockfish ignores any first command I send to him. Don't know why. Probably I do something wrong when I initialize I/O redirection. This works perfectly to me.
  stockfish.SendLine("Hello Stockfish!");
  stockfish.SendLine("setoption name Threads value " + threads.ToString());
  
  Just posting this answer as setting up number of threads as first command is quite logical thing to do. Stockfish replying "Unknown command: setoption name Threads value 3" is pretty misleading, taking into account that rest of communication works.
  
  
  ---
  
  