UCI engine state notion Hi guys I have a problem with using stockfish engine which is using UCI protocol. I wanted to play black and the computer white. But so far I think that uci engine has no notion of state and it gives me the same best moves over. I wanted to know if there's a way to set UCI engine to play as black or white so when am playing as white and gives it move in FEN string notation. It will suggest a move to black.
I have the following log below:
...
option name Emergency Move Time type spin default 30 min 0 max 5000
option name Minimum Thinking Time type spin default 20 min 0 max 5000
option name Slow Mover type spin default 80 min 10 max 1000
option name UCI_Chess960 type check default false
...

uciok
setoption name Hash value 128
ucinewgame

position startpost moves Ng1f3
info depth 1 seldepth 1 score cp 82 nodes 27 nps 27000 time 1 multipv 1 pv e2e4
info depth 2 seldepth 2 score cp 9 nodes 155 nps 155000 time 1 multipv 1 pv d2d4
 d7d5
info depth 3 seldepth 3 score cp 56 nodes 278 nps 278000 time 1 multipv 1 pv d2d
4 d7d5 g1f3
info depth 4 seldepth 4 score cp 8 nodes 749 nps 749000 time 1 multipv 1 pv d2d4
 g8f6 g1f3 d7d6
...
stop

bestmove e2e4 ponder e7e5

Comment : I make a move e2e4 and computer makes a move e7e5

position startpos e7e5 (based on last computer move)

go infinite
wait (5sec)

bestmove e2e4 ponder e7e5

Why is it still e2e4 ponder e7e5, the same best move as the last one. How can I set it to give a best move for black player (me). What kind of commands do i need to set here? Desperately need your help on this guys. Thanks
EDITED
Guys I really appreciate your healthy discussion over this. But I only understand a few concepts regarding UCI engine.
Here's what I have understood so far.
-&gt; There is no FEN to PGN conversion because FEN is the positions of the chess pieces after a number of moves and its not possible to convert it to PGN because FEN doesn't contain the sequence necessary to be converted to PGN
-&gt; PGN on the other hand contains the moves of the players in sequence so it can easily be converted to FEN
Right now my problem is that DGTs electronic board only gives FEN where I use it as an input to our application and am still researching on how I can get PGN from it. I know Fritz shows the PGN as well as other GUI's.
Any ideas on where to proceed from here?
Use the "position fen" command.

For example, take a look at http://support.stockfishchess.org/kb/advanced-topics/uci-protocol. From the example in the link, you could easily change to black's move by

"position fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq - 0 1"

Simply change "... w KQkq" to "... b KQkq". The letter tells the engine which color to move for the position.

To start an infinite analysis, use "go infinite".

Please note that "position startpos" assumes a valid move sequence. Failed to do so will result in undefined behavior - it could crash, do nothing or something else.

Edited:


FEN and PGN are two different things. FEN represents a particular position on the board. PGN is the whole game. You don't convert from one to the other. Talking about conversion is meaningless.
You don't do "position startpos FEN1 FEN2 FEN3 FEN4", please read the UCI specification again. You give the moves with the startpos command, not the position itself.
Stockfish doesn't care how you tell it to reach a particular position.
There is a comment that giving a startpos would be a better way to start a game. But why? Think again, and ask yourself, why?? Why would you think giving a command like "startpos e2e4 e7e5 .... ..... (20 more moves) .... .... " is better than simply giving out the FEN of the position? You typically use a chess GUI to interact with an engine, and the chess GUI must have its own chess-board validator. It's quite easy to generate a FEN string from a validator. However, generating a sequence of moves from the initial position would involve looping over all moves, the complexity of the operation is O(n) where n is the number of moves in the game. Furthermore, you'd have to reserve extra buffer to save the long string. The engine would then have to parse the long string, again this is a slow operation. The startpos is strictly unnecessary.


Edited Again for the poster

PGN can technically be converted into a sequence of FEN positions, but it's meaningless. Nobody does that. Your confusion is all based on the fact that you don't know how to interact with an engine. Don't worry, I'll guide you.

Before you can do anything, you'll need a board generator in your own code. You'll need it because you need something to tell Stockfish what to do, and the only way to do that is with a board generator. Every single chess GUI has it.

Make sure you can use your board generator to convert your position to a FEN or a sequence of moves from the initial position. Either way works, you don't need a PGN. I repeat, you DON'T NEED a PGN to interact with a chess engine. Forget about the PGN, period.

Now, it's easy. You make a move on your physical chess board. Your board generator updates the move and sends the update to Stockfish. The update could be a FEN string or a sequence of moves from the initial position. It doesn't really matter which way you go. I recommend the FEN approach because it'll be easier for you to debug your UCI session.