2

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.

5
  • Doesn't the FEN you give your engine already indicate whose turn it is?
    – qwr
    May 22, 2023 at 2:10
  • 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.
    – GMan3000
    May 22, 2023 at 3:17
  • @GMan3000 is your engine uci compliant?
    – ferdy
    May 22, 2023 at 3:37
  • yes, my engine is UCI complaint
    – GMan3000
    May 22, 2023 at 3:39
  • 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.
    – ferdy
    May 22, 2023 at 8:28

2 Answers 2

4

In uci protocol, there is a command position <info> 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 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.

3
  • 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
    – GMan3000
    May 22, 2023 at 3:15
  • 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.
    – ferdy
    May 22, 2023 at 3:33
  • 1
    @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.
    – Nelson O
    May 22, 2023 at 13:29
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.

2
  • I have to correct the command: the exact example is this: "setoption name UCI_Opponent none none computer 'program name'"
    – GMan3000
    May 22, 2023 at 3:40
  • You can use backticks ` to show code: setoption UCI_Opponent none none computer May 22, 2023 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.