Answers.Body: <p>In <a href="https://github.com/fsmosca/UCIChessEngineProtocol" rel="nofollow noreferrer">uci</a> protocol, there is a command <code>position &lt;info&gt;</code> that is sent to the engine. This command has an info which side to play.</p>
  <p>Example:</p>
  <p><code>position startpos</code></p>
  <p>That tells the engine to play white because the startpos has white to move.</p>
  <p>The word startpos is just equal to a position <code>rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1</code> which is a <a href="https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation" rel="nofollow noreferrer">FEN</a> notation for chess start position.</p>
  <p>It is similar to:</p>
  <p><code>position fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1</code></p>
  <p>The <code>w</code> in FEN means white. So it is white to move.</p>
  <p>Another command from position with moves can be different.</p>
  <p>Example:</p>
  <p><code>position startpos moves e2e4</code></p>
  <p>The startpos is white to move, but there is a move <code>e2e4</code>. With that the side to move is now black because from startpos, the move e2e4 is moved on the board. After the move e2e4, the side to move is now black.</p>
  <p>You may need to handle position fen &lt;&gt; with moves.</p>
  <p>Example:</p>
  <p><code>position fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 moves e2e4 c7c5</code></p>
  <p>That is white to move because there are 2 moves pushed on the board from the FEN <code>rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1</code>.</p>
  <p>You also need to handle a FEN with black to move.</p>
  <p>Example:</p>
  <p><code>position fen r1bqkbnr/pppp1ppp/2n5/4p3/4P3/2N2N2/PPPP1PPP/R1BQKB1R b KQkq - 3 3</code></p>
  <p>That means it is black to move because of <code>b</code> before <code>KQkq</code>.</p>
  <p>And if there is a move on it, the side to move may change.</p>
  <p>Example:</p>
  <p><code>position fen r1bqkbnr/pppp1ppp/2n5/4p3/4P3/2N2N2/PPPP1PPP/R1BQKB1R b KQkq - 3 3 moves g8f6</code></p>
  <p>Now it is white to move.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-22T03:15:03.970Z
Answers.Text: This sort of does not answer my question. (i.e) I am referring to the moment during the initialization of the engine, if there is a command that tells you, ok, Stockfish was initiated and there will play white, and that way I can tell whether I will play black....I cannot continue unsetting and resetting the engine to tell my engine, ok you will start as white...I want my engine to adapt in how the other engine is initialized in arena to determine whether that engine will start first, therefore, I will start as black or vise versa
Answers.UserDisplayName: GMan3000
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-22T03:33:08.210Z
Answers.Text: At the start, you can initialize your engine to play white. Your start position is startpos. Then arena will send position startpos, or position fen etc.
Answers.UserDisplayName: ferdy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-22T13:29:09.570Z
Answers.Text: @GMan3000 Why do you need that information? The UCI protocol is meant to keep the engine as stateless as possible and separate from the actual game, letting the GUI deal with sorting out who is playing which color. If you look at the logs from Arena, you will see that before each `go` command, the GUI sends a `position <fen> <moves> ...` command to let the engine know which position it will be working on next. A UCI-compliant engine should be able to work from either black's or white's perspective in a single game and shouldn't need to know which side it's playing from at the start.
Answers.UserDisplayName: Nelson O
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-22T02:15:34.703Z
Answers.LastActivityDate: 2023-05-22T02:45:28.047Z
Answers.LastEditDate: 2023-05-22T02:45:28.047Z
Answers.UserDisplayName: ferdy
Answers.Body: <p>I think I found it.</p>
  <p>I think I have to use, the &quot;setoption UCI_Opponent none none computer </p>
  <p>That should tell Arena, I will start as white...let me test it!</p>
  <p>BRB.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-22T03:40:44.127Z
Answers.Text: I have to correct the command: the exact example is this: "setoption name UCI_Opponent none none computer 'program name'"
Answers.UserDisplayName: GMan3000
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-22T11:40:36.283Z
Answers.Text: You can use backticks ` to show code: `setoption UCI_Opponent none none computer`
Answers.UserDisplayName: infinitezero
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-22T03:27:09.060Z
Answers.LastActivityDate: 2023-05-22T03:27:09.060Z
Answers.UserDisplayName: GMan3000
Body: <p>Is there a UCI protocol command that tells the other engine which team white or black to play?</p>
  <p>For instance, I wrote a chess engine. I connected my engine to play against Stockfish 15.1 using chess Arena 3.5.1 using a Java runnable jJar file.</p>
  <p>However, I always have to unset and reset in the Arena Engine Management interface for my engine to start as white, and I want to know why. Is there a UCI or Arena command that allows to know which engine will start as white or black? That way I can rewrite my UCI code to adapt for running as white or black.</p>
  <p>If someone understands my question, please give me some insight.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-22T02:10:16.053Z
Comments.Text: Doesn't the FEN you give your engine already indicate whose turn it is?
Comments.UserDisplayName: qwr
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-22T03:17:02.970Z
Comments.Text: I don't want to give a FEN to tell the engine hey, I am starting as white...I want to know from Arena, hey, which engine will start as white, my engine or stockfish or whatever other engine I am using against my engine.
Comments.UserDisplayName: GMan3000
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-22T03:37:16.067Z
Comments.Text: @GMan3000 is your engine uci compliant?
Comments.UserDisplayName: ferdy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-22T03:39:20.023Z
Comments.Text: yes, my engine is UCI complaint
Comments.UserDisplayName: GMan3000
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-05-22T08:28:28.917Z
Comments.Text: If your engine is uci compliant, then let arena schedule the game. Your engine can play as white or your engine can play as black. or both for two games.
Comments.UserDisplayName: ferdy
Tags: <uci>
Title: How to tell which engine is going to play white or black in UCI Protocol?
ThreadText: # How to tell which engine is going to play white or black in UCI Protocol?
  
  (Asked by: username_0 on 2023-05-22)
  
  Is there a UCI protocol command that tells the other engine which team white or black to play?
  
  For instance, I wrote a chess engine. I connected my engine to play against Stockfish 15.1 using chess Arena 3.5.1 using a Java runnable jJar file.
  
  However, I always have to unset and reset in the Arena Engine Management interface for my engine to start as white, and I want to know why. Is there a UCI or Arena command that allows to know which engine will start as white or black? That way I can rewrite my UCI code to adapt for running as white or black.
  
  If someone understands my question, please give me some insight.
  
  **Tags:** uci
  
  > **Comments:**
  > **username_1**: Doesn't the FEN you give your engine already indicate whose turn it is?  
  > **username_0**: I don't want to give a FEN to tell the engine hey, I am starting as white...I want to know from Arena, hey, which engine will start as white, my engine or stockfish or whatever other engine I am using against my engine.  
  > **username_2**: @username_0 is your engine uci compliant?  
  > **username_0**: yes, my engine is UCI complaint  
  > **username_2**: If your engine is uci compliant, then let arena schedule the game. Your engine can play as white or your engine can play as black. or both for two games.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2023-05-22. Score: 4
  
  In [uci](https://github.com/fsmosca/UCIChessEngineProtocol) protocol, there is a command `position`  that is sent to the engine. This command has an info which side to play.
  
  Example:
  
  `position startpos`
  
  That tells the engine to play white because the startpos has white to move.
  
  The word startpos is just equal to a position `rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1` which is a [FEN](https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation) notation for chess start position.
  
  It is similar to:
  
  `position fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1`
  
  The `w` in FEN means white. So it is white to move.
  
  Another command from position with moves can be different.
  
  Example:
  
  `position startpos moves e2e4`
  
  The startpos is white to move, but there is a move `e2e4`. With that the side to move is now black because from startpos, the move e2e4 is moved on the board. After the move e2e4, the side to move is now black.
  
  You may need to handle position fen <> with moves.
  
  Example:
  
  `position fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 moves e2e4 c7c5`
  
  That is white to move because there are 2 moves pushed on the board from the FEN `rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1`.
  
  You also need to handle a FEN with black to move.
  
  Example:
  
  `position fen r1bqkbnr/pppp1ppp/2n5/4p3/4P3/2N2N2/PPPP1PPP/R1BQKB1R b KQkq - 3 3`
  
  That means it is black to move because of `b` before `KQkq`.
  
  And if there is a move on it, the side to move may change.
  
  Example:
  
  `position fen r1bqkbnr/pppp1ppp/2n5/4p3/4P3/2N2N2/PPPP1PPP/R1BQKB1R b KQkq - 3 3 moves g8f6`
  
  Now it is white to move.
  
  > **Comments:**
  > **username_0**: This sort of does not answer my question. (i.e) I am referring to the moment during the initialization of the engine, if there is a command that tells you, ok, Stockfish was initiated and there will play white, and that way I can tell whether I will play black....I cannot continue unsetting and resetting the engine to tell my engine, ok you will start as white...I want my engine to adapt in how the other engine is initialized in arena to determine whether that engine will start first, therefore, I will start as black or vise versa  
  > **username_2**: At the start, you can initialize your engine to play white. Your start position is startpos. Then arena will send position startpos, or position fen etc.  
  > **username_3**: @username_0 Why do you need that information? The UCI protocol is meant to keep the engine as stateless as possible and separate from the actual game, letting the GUI deal with sorting out who is playing which color. If you look at the logs from Arena, you will see that before each `go` command, the GUI sends a `position <fen> <moves> ...` command to let the engine know which position it will be working on next. A UCI-compliant engine should be able to work from either black's or white's perspective in a single game and shouldn't need to know which side it's playing from at the start.  
  
  ---
  
  ### Answer by username_0 on 2023-05-22. Score: 1
  
  I think I found it.
  
  I think I have to use, the "setoption UCI\_Opponent none none computer
  
  That should tell Arena, I will start as white...let me test it!
  
  BRB.
  
  > **Comments:**
  > **username_0**: I have to correct the command: the exact example is this: "setoption name UCI_Opponent none none computer 'program name'"  
  > **username_4**: You can use backticks ` to show code: `setoption UCI_Opponent none none computer`  
  
  ---
  
  