Answers.Body: <p>Use the "position fen" command.</p>
  
  <p>For example, take a look at <a href="http://support.stockfishchess.org/kb/advanced-topics/uci-protocol" rel="nofollow">http://support.stockfishchess.org/kb/advanced-topics/uci-protocol</a>. From the example in the link, you could easily change to black's move by</p>
  
  <p>"position fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq - 0 1"</p>
  
  <p>Simply change "... w KQkq" to "... b KQkq". The letter tells the engine which color to move for the position.</p>
  
  <p>To start an infinite analysis, use "go infinite".</p>
  
  <p>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.</p>
  
  <p>Edited:</p>
  
  <ol>
  <li><p>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.</p></li>
  <li><p>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.</p></li>
  <li><p>Stockfish doesn't care how you tell it to reach a particular position.</p></li>
  <li><p>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.</p></li>
  </ol>
  
  <p>Edited Again for the poster</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T12:36:43.927Z
Answers.Text: The problem wasn't who's move it is. The problem was that dimas thought the "position startpos moves" command updates the current position, which it doesn't.
Answers.UserDisplayName: BlindKungFuMaster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T12:45:55.053Z
Answers.Text: hi studentt, thanks for replying. That's an interesting notation. My board doesn't give out KQkq - 01. Am not sure how I can show it either. But right now am just doing trial and error on the commands. From the example you have given, you knew its blacks move because of "b" before KQkq ?
Answers.UserDisplayName: dimas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T12:50:08.757Z
Answers.Text: @BlindKunfFuMaster The asker states "I wanted to know if there's a way to set UCI engine.." This means he's interested in whether there's a way, the fact that he got confused in the output because he didn't know there was another command. My answer is correct and precise.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T12:51:48.273Z
Answers.Text: @BlindKungFuMaster He did indeed believed the position was updated, but the real problem was that he actually needed another better way to do what he wanted to do.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T12:52:44.223Z
Answers.Text: @dimas FEN is a standard. Read https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation If your board doesn't give out KQkq, it's a bug. It's not a correct software.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T12:53:50.497Z
Answers.Text: @dimas I knew it was black's move because the letter "b" stands for "black to move". Please carefully look at the FEN specification.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T13:00:51.707Z
Answers.Text: If the goal is to play a game, using FEN is an incredibly roundabout way to do it. You already have the move notation at hand, because after all you have to make moves to play … FEN is only useful to start a game from a given position, not to set up the board anew for every single move of a game.
Answers.UserDisplayName: BlindKungFuMaster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T13:28:55.837Z
Answers.Text: So you're saying that if I have this kind of command position startpos FEN1 FEN2 FEN3 FEN4 after 2 moves by each player. It will not be giving an accurate information for Stockfish engine to work on?
  If that is the case then the board doesn't always gives out FEN notation and I have no idea on how to convert from FEN to PGN. Almost all search I have on google always converts PGN to FEN not the other way around. If you know a site which converts from FEN to PGN i'd be grateful coz i've been searching it for days.
Answers.UserDisplayName: dimas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T14:35:07.890Z
Answers.Text: @dimas Your question makes no sense... I'll answer you in my edited answer.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T14:46:17.360Z
Answers.Text: @BlindKungFuMaster See my edited.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T15:05:28.887Z
Answers.Text: @Student T: Parsing the moves will take less than a millionth of the time stockfish uses for its calculation, even if the game takes hundreds of moves. So please keep it real. And if dimas used a GUI to play this game, he wouldn't ask this question.
Answers.UserDisplayName: BlindKungFuMaster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T15:07:09.823Z
Answers.Text: You could be correct but it still takes time and book-keeping. Also you could give a fraction of a second for analyze.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T15:10:03.953Z
Answers.Text: @BlindKungFuMaster It doesn't matter whether he's using a GUI or not. If he's using, the GUI has a move validator. If he isn't, he still needs to add one himself because he needs something to generate moves or FEN to the engine.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T15:27:41.190Z
Answers.Text: BlindKungFuMaster Student_T guys i've edited my post please let me know if am my understanding is right regarding this. Thank
Answers.UserDisplayName: dimas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T15:35:48.337Z
Answers.Text: @dimas Refer to my edited-edited answer.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T16:04:16.180Z
Answers.Text: @StudenT that's great so I need to find a board generator as well. I hope there is one as a stand alone if not then I would need to use a chess gui that throws out FEN to my application.
Answers.UserDisplayName: dimas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-30T00:01:22.483Z
Answers.Text: There're some open source, in C++ or C#. If you need advice, please start a new post on it, and I'll answer.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-30T05:34:19.023Z
Answers.Text: Ok, i will find some board generators. Thanks very much
Answers.UserDisplayName: dimas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-31T14:24:49.723Z
Answers.Text: Hi Student T is chesspresso a board generator? I've been looking for chess board generators but I cant be sure if the one I found is right. Can you please give me just one example. Thanks
Answers.UserDisplayName: dimas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-31T14:33:04.727Z
Answers.Text: Please post a new question because this is getting too long. I will answer and comment on a new question.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T12:20:48.157Z
Answers.LastActivityDate: 2015-01-29T15:35:25.623Z
Answers.LastEditDate: 2015-01-29T15:35:25.623Z
Answers.UserDisplayName: SmallChess
Answers.Body: <p>When you give the position, you always have to give all the game moves, if you start with 'startpos'. The command basically means: Start with the starting position and then execute all these moves and then start to think …</p>
  
  <p>'position startpos e7e5' is probably just the starting position, because e7e5 isn't a legal move. After all in the starting position it's white to move. (To relinquish the move right you'd have to give a zero move which is 0000, I think.)</p>
  
  <p>So it just isn't thinking about the position you think it is thinking about.</p>
  
  <p>There surely is a way to just update the position held internally by the engine, but I'm too lazy to look it up now.</p>
  
  <p>Edit: As you are a chess-stackexchange (and therefore maybe chess-) newcomer, I also want to add, that possibly you won't have much fun playing against stockfish. The top engines just crush every human player. If your goal is to play an open game with chances for both sides, there are probably better options …</p>
  
  <p>Edit: So actually this is the situation:</p>
  
  <ul>
  <li>The DGT-board gives you a FEN.</li>
  <li>You'll give "position fen FEN" to stockfish.</li>
  <li>Stockfish gives you a bestmove.</li>
  <li>You'll give the move to the robot and it executes it on the board.</li>
  <li>Your human player makes a move.</li>
  <li>… and back to the first point.</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T07:45:23.783Z
Answers.Text: Thanks for replying BlindKungfuMaster, so whenever I try to do a position startpos I have to add all the moves made by white and black according to its sequence. Is that correct?
Answers.UserDisplayName: dimas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T07:58:52.137Z
Answers.Text: Actually am trying to create an application using stockfish engine. I'd be playing with it in order to test if my application is running correctly. But the intended audience for this are players who have better background in chess than I am. Right now am just concerned on how to interface with the engine using the application am developing.
Answers.UserDisplayName: dimas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T08:12:58.160Z
Answers.Text: Yes, exactly. Is it just a playing app, or do you have something different in mind?
Answers.UserDisplayName: BlindKungFuMaster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T09:04:57.707Z
Answers.Text: Nope, its a human versus robot. We have a robotic arm that plays the computer using stockfish engine as the ai. The app i am creating will act as interface between the electronic board, stockfish engine and the robotic arm.
Answers.UserDisplayName: dimas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T09:20:41.633Z
Answers.Text: Ok, cool. Good luck with that.
Answers.UserDisplayName: BlindKungFuMaster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T12:17:27.013Z
Answers.Text: -1 the answer is incorrect. There is "position fen" command.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T12:23:42.587Z
Answers.Text: There is no such thing as "probably just the starting position" because the behavior is undefined.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T12:31:56.857Z
Answers.Text: Did you even read my answer? Or the question? The behaviour might be undefined by uci but for stockfish it is "probably just the starting position"! I mean just look at the output.
Answers.UserDisplayName: BlindKungFuMaster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T12:48:34.223Z
Answers.Text: In software engineering, there is no such thing as "probably". It's only yes or no. If someone has an undefined behavior, you shouldn't explain because it's unnecessary. Any result from such operation shouldn't be examined.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T15:16:46.990Z
Answers.Text: @dimas: Does your DGT-board only return the FEN of a position? In that case obviously using FEN to set up stockfish is easier. And by the way, "position startpost moves Ng1f3" shouldn't contain the "N".
Answers.UserDisplayName: BlindKungFuMaster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T15:26:01.887Z
Answers.Text: @BlindKungFuMaster yes it returns FEN. But as student said FEN is not suitable input for my application.
Answers.UserDisplayName: dimas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T15:39:44.300Z
Answers.Text: But you can use FEN as input. FEN describes the current board position, so in that case you need neither the old moves nor the old FEN. I think this confusion came from the fact that all the surrounding circumstances (robot, dgt-board, etc) are important for the optimal solution. But if the dgt-board gives you the FEN, you should use it with "position fen "FEN.
Answers.UserDisplayName: BlindKungFuMaster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-30T09:18:59.597Z
Answers.Text: I think you'll need your application to understand chess anyway. Consider you played b4 and Stockfish replies a4b3, your application will need to know to move a piece as directed AND remove a pawn from b4. Also, FEN doesn't give you enough info for draws by 3 fold repetition or 50 move rule.
Answers.UserDisplayName: BarrySW19
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-30T09:59:09.653Z
Answers.Text: Actually, full FEN does give you the 50 move rule data, but I don't know if the DGT board gives you full FEN including castling and en passant options, or just the simple position part.
Answers.UserDisplayName: BarrySW19
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-30T10:10:03.543Z
Answers.Text: Very good point about the en passant rule. You can use the FEN from the DGT-board to start stockfish, but you still need move information for the robot. Does stockfish specify whether a move is en passant?
Answers.UserDisplayName: BlindKungFuMaster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-30T22:05:41.187Z
Answers.Text: I don't know the specifics of the DGT board, but I would imagine it can only send the position in (partial) FEN format as I doubt it has internal software to keep track of castling and en passant status. If so, the FEN it sends won't even be sufficient as input to Stockfish. The system would either need to use the Stockfish engine to keep track of the whole game or do so itself. If Java can be used then the code for my chess engine (search CalculonX on github) would be very useful :-)
Answers.UserDisplayName: BarrySW19
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-29T07:35:04.923Z
Answers.LastActivityDate: 2015-01-29T15:45:27.910Z
Answers.LastEditDate: 2015-01-29T15:45:27.910Z
Answers.UserDisplayName: BlindKungFuMaster
Body: <p>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.</p>
  <p>I have the following log below:</p>
  <pre><code>...
  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
  </code></pre>
  <p>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</p>
  <h1>EDITED</h1>
  <p>Guys I really appreciate your healthy discussion over this. But I only understand a few concepts regarding UCI engine.</p>
  <p>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</p>
  <p>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.<br />
  Any ideas on where to proceed from here?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-03T18:07:33.950Z
Comments.Text: ponder ponders the *opponents* best move
Comments.UserDisplayName: john k
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-26T15:42:04.673Z
Comments.Text: Based on what I just read elsewhere, you really should have used `position moves e7e5`; the `startpos` resets the position.
Comments.UserDisplayName: D. Ben Knoble
Tags: <analysis><engines><stockfish><evaluation><uci>
Title: UCI engine state notion
ThreadText: # UCI engine state notion
  
  (Asked by: username_0 on 2015-01-29)
  
  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.
  -> 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
  -> 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?
  
  **Tags:** analysis, engines, stockfish, evaluation, uci
  
  > **Comments:**
  > **username_1**: ponder ponders the *opponents* best move  
  > **username_2**: Based on what I just read elsewhere, you really should have used `position moves e7e5`; the `startpos` resets the position.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2015-01-29. Score: 2 | Accepted answer
  
  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:
  
  1. 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.
  2. 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.
  3. Stockfish doesn't care how you tell it to reach a particular position.
  4. 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.
  
  > **Comments:**
  > **username_4**: The problem wasn't who's move it is. The problem was that username_0 thought the "position startpos moves" command updates the current position, which it doesn't.  
  > **username_0**: hi studentt, thanks for replying. That's an interesting notation. My board doesn't give out KQkq - 01. Am not sure how I can show it either. But right now am just doing trial and error on the commands. From the example you have given, you knew its blacks move because of "b" before KQkq ?  
  > **username_3**: @BlindKunfFuMaster The asker states "I wanted to know if there's a way to set UCI engine.." This means he's interested in whether there's a way, the fact that he got confused in the output because he didn't know there was another command. My answer is correct and precise.  
  > **username_3**: @username_4 He did indeed believed the position was updated, but the real problem was that he actually needed another better way to do what he wanted to do.  
  > **username_3**: @username_0 FEN is a standard. Read https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation If your board doesn't give out KQkq, it's a bug. It's not a correct software.  
  > **username_3**: @username_0 I knew it was black's move because the letter "b" stands for "black to move". Please carefully look at the FEN specification.  
  > **username_4**: If the goal is to play a game, using FEN is an incredibly roundabout way to do it. You already have the move notation at hand, because after all you have to make moves to play … FEN is only useful to start a game from a given position, not to set up the board anew for every single move of a game.  
  > **username_0**: So you're saying that if I have this kind of command position startpos FEN1 FEN2 FEN3 FEN4 after 2 moves by each player. It will not be giving an accurate information for Stockfish engine to work on? If that is the case then the board doesn't always gives out FEN notation and I have no idea on how to convert from FEN to PGN. Almost all search I have on google always converts PGN to FEN not the other way around. If you know a site which converts from FEN to PGN i'd be grateful coz i've been searching it for days.  
  > **username_3**: @username_0 Your question makes no sense... I'll answer you in my edited answer.  
  > **username_3**: @username_4 See my edited.  
  > **username_4**: @Student T: Parsing the moves will take less than a millionth of the time stockfish uses for its calculation, even if the game takes hundreds of moves. So please keep it real. And if username_0 used a GUI to play this game, he wouldn't ask this question.  
  > **username_3**: You could be correct but it still takes time and book-keeping. Also you could give a fraction of a second for analyze.  
  > **username_3**: @username_4 It doesn't matter whether he's using a GUI or not. If he's using, the GUI has a move validator. If he isn't, he still needs to add one himself because he needs something to generate moves or FEN to the engine.  
  > **username_0**: username_4 Student_T guys i've edited my post please let me know if am my understanding is right regarding this. Thank  
  > **username_3**: @username_0 Refer to my edited-edited answer.  
  > **username_0**: @StudenT that's great so I need to find a board generator as well. I hope there is one as a stand alone if not then I would need to use a chess gui that throws out FEN to my application.  
  > **username_3**: There're some open source, in C++ or C#. If you need advice, please start a new post on it, and I'll answer.  
  > **username_0**: Ok, i will find some board generators. Thanks very much  
  > **username_0**: Hi Student T is chesspresso a board generator? I've been looking for chess board generators but I cant be sure if the one I found is right. Can you please give me just one example. Thanks  
  > **username_3**: Please post a new question because this is getting too long. I will answer and comment on a new question.  
  
  ---
  
  ### Answer by username_4 on 2015-01-29. Score: 0
  
  When you give the position, you always have to give all the game moves, if you start with 'startpos'. The command basically means: Start with the starting position and then execute all these moves and then start to think …
  
  'position startpos e7e5' is probably just the starting position, because e7e5 isn't a legal move. After all in the starting position it's white to move. (To relinquish the move right you'd have to give a zero move which is 0000, I think.)
  
  So it just isn't thinking about the position you think it is thinking about.
  
  There surely is a way to just update the position held internally by the engine, but I'm too lazy to look it up now.
  
  Edit: As you are a chess-stackexchange (and therefore maybe chess-) newcomer, I also want to add, that possibly you won't have much fun playing against stockfish. The top engines just crush every human player. If your goal is to play an open game with chances for both sides, there are probably better options …
  
  Edit: So actually this is the situation:
  
  * The DGT-board gives you a FEN.
  * You'll give "position fen FEN" to stockfish.
  * Stockfish gives you a bestmove.
  * You'll give the move to the robot and it executes it on the board.
  * Your human player makes a move.
  * … and back to the first point.
  
  > **Comments:**
  > **username_0**: Thanks for replying BlindKungfuMaster, so whenever I try to do a position startpos I have to add all the moves made by white and black according to its sequence. Is that correct?  
  > **username_0**: Actually am trying to create an application using stockfish engine. I'd be playing with it in order to test if my application is running correctly. But the intended audience for this are players who have better background in chess than I am. Right now am just concerned on how to interface with the engine using the application am developing.  
  > **username_4**: Yes, exactly. Is it just a playing app, or do you have something different in mind?  
  > **username_0**: Nope, its a human versus robot. We have a robotic arm that plays the computer using stockfish engine as the ai. The app i am creating will act as interface between the electronic board, stockfish engine and the robotic arm.  
  > **username_4**: Ok, cool. Good luck with that.  
  > **username_3**: -1 the answer is incorrect. There is "position fen" command.  
  > **username_3**: There is no such thing as "probably just the starting position" because the behavior is undefined.  
  > **username_4**: Did you even read my answer? Or the question? The behaviour might be undefined by uci but for stockfish it is "probably just the starting position"! I mean just look at the output.  
  > **username_3**: In software engineering, there is no such thing as "probably". It's only yes or no. If someone has an undefined behavior, you shouldn't explain because it's unnecessary. Any result from such operation shouldn't be examined.  
  > **username_4**: @username_0: Does your DGT-board only return the FEN of a position? In that case obviously using FEN to set up stockfish is easier. And by the way, "position startpost moves Ng1f3" shouldn't contain the "N".  
  > **username_0**: @username_4 yes it returns FEN. But as student said FEN is not suitable input for my application.  
  > **username_4**: But you can use FEN as input. FEN describes the current board position, so in that case you need neither the old moves nor the old FEN. I think this confusion came from the fact that all the surrounding circumstances (robot, dgt-board, etc) are important for the optimal solution. But if the dgt-board gives you the FEN, you should use it with "position fen "FEN.  
  > **username_5**: I think you'll need your application to understand chess anyway. Consider you played b4 and Stockfish replies a4b3, your application will need to know to move a piece as directed AND remove a pawn from b4. Also, FEN doesn't give you enough info for draws by 3 fold repetition or 50 move rule.  
  > **username_5**: Actually, full FEN does give you the 50 move rule data, but I don't know if the DGT board gives you full FEN including castling and en passant options, or just the simple position part.  
  > **username_4**: Very good point about the en passant rule. You can use the FEN from the DGT-board to start stockfish, but you still need move information for the robot. Does stockfish specify whether a move is en passant?  
  > **username_5**: I don't know the specifics of the DGT board, but I would imagine it can only send the position in (partial) FEN format as I doubt it has internal software to keep track of castling and en passant status. If so, the FEN it sends won't even be sufficient as input to Stockfish. The system would either need to use the Stockfish engine to keep track of the whole game or do so itself. If Java can be used then the code for my chess engine (search CalculonX on github) would be very useful :-)  
  
  ---
  
  