Answers.Body: <p>I think for this you actually want the XBoard protocol, which <a href="https://www.gnu.org/software/xboard/engine-intf.html#8" rel="nofollow noreferrer">specifies</a>:</p>
  <blockquote>
  <p><strong>result RESULT {COMMENT}</strong></p>
  <p><strong>After the end of each game, xboard will send you a result command.</strong> You can use this command to trigger learning. RESULT is either 1-0, 0-1, 1/2-1/2, or *, indicating whether white won, black won, the game was a draw, or the game was unfinished. The COMMENT string is purely a human-readable comment; its content is unspecified and subject to change. In ICS mode, it is passed through from ICS uninterpreted. Example:</p>
  <p><code>result 1-0 {White mates}</code></p>
  <p>Here are some notes on interpreting the &quot;result&quot; command. Some apply only to playing on ICS (&quot;Zippy&quot; mode).</p>
  <p>If you won but did not just play a mate, your opponent must have resigned or forfeited. If you lost but were not just mated, you probably forfeited on time, or perhaps the operator resigned manually. If there was a draw for some nonobvious reason, perhaps your opponent called your flag when he had insufficient mating material (or vice versa), or perhaps the operator agreed to a draw manually.</p>
  <p><strong>You will get a result command even if you already know the game ended</strong> -- for example, after you just checkmated your opponent. In fact, if you send the &quot;RESULT {COMMENT}&quot; command (discussed below), you will simply get the same thing fed back to you with &quot;result&quot; tacked in front. You might not always get a &quot;result *&quot; command, however. In particular, you won't get one in local chess engine mode when the user stops playing by selecting Reset, Edit Game, Exit or the like.</p>
  </blockquote>
  <p>(emphasis mine)</p>
  <p>UCI protocol is designed to be stateless, so an engine does not know when a game begins or ends, but is merely given a position to search.</p>
  <p>As a compromise, you <em>could</em> trigger learning on a <code>ucinewgame</code> command, but this is not nearly as useful, because UCI does not send you the winning move. Perhaps perform a depth-1 search to see if there was a mating move, then assume they made that.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-13T17:33:25.833Z
Answers.Text: First of all thank you for your answer. Reading your post gave me the idea to search for whatever log files Arena might be saving concerning a game.And i found a  **.res** file that Arena creates during a tournament.By parsing that file i can get who won each time, and hopefully that will solve my problem.This file could be read ,as you proposed, when we get the _ucinewgame_ command and trigger learning.
Answers.UserDisplayName: Agisilaos Vasileiadis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-13T17:12:44.940Z
Answers.LastActivityDate: 2016-09-13T17:12:44.940Z
Answers.LastEditDate: 2020-06-17T09:59:59.497Z
Answers.UserDisplayName: ZirconiumX
Answers.Body: <p>Arena is closed source, so I don't see any possibility for you to force the GUI to send you the last move. In fact, I don't think chess GUI should send the move to you because there wouldn't be anything for your engine to do.</p>
  
  <p>If you really need the last move, maybe you want to use <a href="https://github.com/cutechess/cutechess" rel="nofollow">Cutechess</a>? It's open source so you can do whatever you want once the game is over.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-13T13:09:21.740Z
Answers.LastActivityDate: 2016-09-13T13:09:21.740Z
Answers.UserDisplayName: SmallChess
Answers.Body: <p>I think SmallChess is right and the Chess GUI is not supposed to send any more moves to a UCI Engine when the game is over by definition of UCI.</p>
  
  <p>UCI Engines do not analyse Chess Games, but only single Chess Positions, so saving, storing or analysing a complete Chess Game is up to the Chess UI and not the UCI Engine.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-27T12:34:07.853Z
Answers.LastActivityDate: 2017-11-27T12:34:07.853Z
Answers.UserDisplayName: UCI_GUI
Body: <p>I am building a chess engine using AI and have succesfully connected it to the <a href="http://www.playwitharena.com/" rel="nofollow">Arena</a> Gui, by implementing the <a href="http://wbec-ridderkerk.nl/html/UCIProtocol.html" rel="nofollow">UCI</a> protocol.</p>
  
  <p>My goal is to train my AI by facing other AIs that Arena offers.
  Everything works well except the checkmate part where one of the engine loses.
  More specifically Arena does not give the last move made(that ended the game) to the losing engine,but instead it starts a new game when in tournament mode.</p>
  
  <p>eg(from Arena debug): </p>
  
  <pre><code>2016-09-13 14:48:26,119--&gt;2:position startpos moves d2d4 d7d5 a2a3 e7e6 a3a4 b8c6 a1a3 f8a3 e2e4 a3f8 b2b4 f8b4 c2c3 b4a5 f1e2 d5e4 g2g3 c6d4 e2d3 e4d3 c1g5 d4c2 d1c2 d3c2 g5d8 c2b1q e1e2 b7b6 g1f3 c8a6 c3c4 a6c4 e2e3 b1b3 e3e4 c4e2 d8g5 b3f3 e4d4
  2016-09-13 14:48:26,119--&gt;2:go wtime 295296 btime 231219 winc 0 binc 0
  2016-09-13 14:48:26,121&lt;--2:info score cp 3343 lowerbound depth 1 nodes 1 time 0 pv f3h1
  2016-09-13 14:48:26,123&lt;--2:info score cp 3343 depth 1 nodes 2 time 0 pv f3h1
  2016-09-13 14:48:26,126&lt;--2:info score mate 1 lowerbound depth 1 nodes 5 time 0 pv a5c3
  2016-09-13 14:48:26,128&lt;--2:info score mate 1 depth 1 nodes 6 time 0 pv a5c3
  2016-09-13 14:48:26,129&lt;--2:info cpuload 0
  2016-09-13 14:48:26,130&lt;--2:bestmove a5c3
  2016-09-13 14:48:26,130*2*Found move:Ba5-c3
  2016-09-13 14:48:26,290********Game end: 0-1 {Mate}
  2016-09-13 14:48:26,291********Last game won by AnMon 5.75 with Black in 20 moves
  </code></pre>
  
  <p>In the example above my engine lost to its adversary(AnMon). As you can see the opponent gave the move a5c3 to the interface, and Arena just ended the game without sending a message to my engine before beggining a new game.</p>
  
  <p>The problem lies in the fact that my goal is to train my engine's AI and to do that i need the last move made so that i can determine who won and who lost.
  Is there a way to make Arena give me that information?</p>
  
  <p>If not what other engines that meet my needs would you reccomend?</p>
  
Tags: <engines><programming>
Title: Make Arena send last move to chess engine
ThreadText: # Make Arena send last move to chess engine
  
  (Asked by: username_0 on 2016-09-13)
  
  I am building a chess engine using AI and have succesfully connected it to the Arena Gui, by implementing the UCI protocol.
  My goal is to train my AI by facing other AIs that Arena offers.
  Everything works well except the checkmate part where one of the engine loses.
  More specifically Arena does not give the last move made(that ended the game) to the losing engine,but instead it starts a new game when in tournament mode.
  eg(from Arena debug): 
  2016-09-13 14:48:26,119-->2:position startpos moves d2d4 d7d5 a2a3 e7e6 a3a4 b8c6 a1a3 f8a3 e2e4 a3f8 b2b4 f8b4 c2c3 b4a5 f1e2 d5e4 g2g3 c6d4 e2d3 e4d3 c1g5 d4c2 d1c2 d3c2 g5d8 c2b1q e1e2 b7b6 g1f3 c8a6 c3c4 a6c4 e2e3 b1b3 e3e4 c4e2 d8g5 b3f3 e4d4
  2016-09-13 14:48:26,119-->2:go wtime 295296 btime 231219 winc 0 binc 0
  2016-09-13 14:48:26,121<--2:info score cp 3343 lowerbound depth 1 nodes 1 time 0 pv f3h1
  2016-09-13 14:48:26,123<--2:info score cp 3343 depth 1 nodes 2 time 0 pv f3h1
  2016-09-13 14:48:26,126<--2:info score mate 1 lowerbound depth 1 nodes 5 time 0 pv a5c3
  2016-09-13 14:48:26,128<--2:info score mate 1 depth 1 nodes 6 time 0 pv a5c3
  2016-09-13 14:48:26,129<--2:info cpuload 0
  2016-09-13 14:48:26,130<--2:bestmove a5c3
  2016-09-13 14:48:26,130*2*Found move:Ba5-c3
  2016-09-13 14:48:26,290********Game end: 0-1 {Mate}
  2016-09-13 14:48:26,291********Last game won by AnMon 5.75 with Black in 20 moves
  
  In the example above my engine lost to its adversary(AnMon). As you can see the opponent gave the move a5c3 to the interface, and Arena just ended the game without sending a message to my engine before beggining a new game.
  The problem lies in the fact that my goal is to train my engine's AI and to do that i need the last move made so that i can determine who won and who lost.
  Is there a way to make Arena give me that information?
  If not what other engines that meet my needs would you reccomend?
  
  **Tags:** engines, programming
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2016-09-13. Score: 1
  
  I think for this you actually want the XBoard protocol, which [specifies](https://www.gnu.org/software/xboard/engine-intf.html#8):
  
  > **result RESULT {COMMENT}**
  >
  > **After the end of each game, xboard will send you a result command.** You can use this command to trigger learning. RESULT is either 1-0, 0-1, 1/2-1/2, or \*, indicating whether white won, black won, the game was a draw, or the game was unfinished. The COMMENT string is purely a human-readable comment; its content is unspecified and subject to change. In ICS mode, it is passed through from ICS uninterpreted. Example:
  >
  > `result 1-0 {White mates}`
  >
  > Here are some notes on interpreting the "result" command. Some apply only to playing on ICS ("Zippy" mode).
  >
  > If you won but did not just play a mate, your opponent must have resigned or forfeited. If you lost but were not just mated, you probably forfeited on time, or perhaps the operator resigned manually. If there was a draw for some nonobvious reason, perhaps your opponent called your flag when he had insufficient mating material (or vice versa), or perhaps the operator agreed to a draw manually.
  >
  > **You will get a result command even if you already know the game ended** -- for example, after you just checkmated your opponent. In fact, if you send the "RESULT {COMMENT}" command (discussed below), you will simply get the same thing fed back to you with "result" tacked in front. You might not always get a "result \*" command, however. In particular, you won't get one in local chess engine mode when the user stops playing by selecting Reset, Edit Game, Exit or the like.
  
  (emphasis mine)
  
  UCI protocol is designed to be stateless, so an engine does not know when a game begins or ends, but is merely given a position to search.
  
  As a compromise, you *could* trigger learning on a `ucinewgame` command, but this is not nearly as useful, because UCI does not send you the winning move. Perhaps perform a depth-1 search to see if there was a mating move, then assume they made that.
  
  > **Comments:**
  > **username_0**: First of all thank you for your answer. Reading your post gave me the idea to search for whatever log files Arena might be saving concerning a game.And i found a  **.res** file that Arena creates during a tournament.By parsing that file i can get who won each time, and hopefully that will solve my problem.This file could be read ,as you proposed, when we get the _ucinewgame_ command and trigger learning.  
  
  ---
  
  ### Answer by username_2 on 2016-09-13. Score: 0
  
  Arena is closed source, so I don't see any possibility for you to force the GUI to send you the last move. In fact, I don't think chess GUI should send the move to you because there wouldn't be anything for your engine to do.
  
  If you really need the last move, maybe you want to use [Cutechess](https://github.com/cutechess/cutechess)? It's open source so you can do whatever you want once the game is over.
  
  
  ---
  
  ### Answer by username_3 on 2017-11-27. Score: 0
  
  I think username_2 is right and the Chess GUI is not supposed to send any more moves to a UCI Engine when the game is over by definition of UCI.
  
  UCI Engines do not analyse Chess Games, but only single Chess Positions, so saving, storing or analysing a complete Chess Game is up to the Chess UI and not the UCI Engine.
  
  
  ---
  
  