Currently the UCI protocol does not specify a way of the gui telling the engine the end-result of a game. It only sends a "ucinewgame" and that's it.
For engines that would like to "learn" from a game, it would be useful if they were informed what the result was, like the xboard protocol does. This may be deducible but that can be tricky (e.g. when the program was asked for a hint).
To get around this problem I would like to propose a new UCI command "gameover" with as parameters win, draw or lose.
To stay compatible with UCI engines that do not support this feature I think it is best that the engine announces support of it via an option-line:
Code: Select all
option name GameOver_command type check default true
So what happens is as follows:
Code: Select all
gui eng> uci
eng gui> option name GameOver_command type check default true
gui eng> setoption name GameOver_command value true # this tells the engine that it can expect the gameover command
gui eng> ucinewgame
gui eng> position [...]
[...]
gui eng> gameover 1-0 white
[...]
p.s. a somewhat tested patch for polyglot could be:
(start polyglot with -pg GameOver_command=true - with this patch the setoption thing is not implemented)
Code: Select all
diff -uNrBbd polyglot-2.0.4.org/option.c polyglot-gameover/option.c
--- polyglot-2.0.4.org/option.c 2016-11-15 10:44:53.000000000 +0100
+++ polyglot-gameover/option.c 2017-01-19 13:53:21.188280741 +0100
@@ -40,6 +40,7 @@
{ "LogFile", "file","0","0", "polyglot.log", NULL,0,NNB, PG|XBOARD|XBSEL|UCI},
{ "UCI", "check","0","0", "false" , NULL,0,NNB, PG},
+ { "GameOver_command", "check","0","0", "false" , NULL,0,NNB, PG|UCI},
{ "UseNice", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|UCI},
{ "NiceValue", "spin", "0","20", "5" , NULL,0,NNB, PG|XBOARD|UCI},
diff -uNrBbd polyglot-2.0.4.org/uci.c polyglot-gameover/uci.c
--- polyglot-2.0.4.org/uci.c 2016-11-15 10:44:53.000000000 +0100
+++ polyglot-gameover/uci.c 2016-12-16 10:19:57.248771338 +0100
@@ -280,6 +280,20 @@
}
}
+// uci_send_gameover()
+
+void uci_send_gameover(uci_t * uci, const int result) {
+
+ ASSERT(uci!=NULL);
+
+ if (result > 0)
+ engine_send(uci->engine,"gameover win");
+ else if (result < 0)
+ engine_send(uci->engine,"gameover lose");
+ else
+ engine_send(uci->engine,"gameover draw");
+}
+
// uci_send_option()
bool uci_send_option(uci_t * uci, const char option[], const char format[], ...) {
diff -uNrBbd polyglot-2.0.4.org/uci.h polyglot-gameover/uci.h
--- polyglot-2.0.4.org/uci.h 2016-11-15 10:44:53.000000000 +0100
+++ polyglot-gameover/uci.h 2016-12-16 10:19:32.848771404 +0100
@@ -98,6 +98,7 @@
extern void uci_send_stop (uci_t * uci);
extern void uci_send_stop_sync (uci_t * uci);
extern void uci_send_ucinewgame (uci_t * uci);
+extern void uci_send_gameover (uci_t * uci, const int result);
extern void uci_set_threads (uci_t * uci, int n);
extern const char * uci_thread_option(uci_t * uci);
extern bool uci_send_option (uci_t * uci, const char option[], const char format[], ...);
diff -uNrBbd polyglot-2.0.4.org/xboard2uci.c polyglot-gameover/xboard2uci.c
--- polyglot-2.0.4.org/xboard2uci.c 2016-11-15 10:44:53.000000000 +0100
+++ polyglot-gameover/xboard2uci.c 2017-01-19 13:52:14.852280615 +0100
@@ -499,6 +499,7 @@
|| match(string,"result * {* }")
|| match(string,"result * { *}")
|| match(string,"result * { * }")) {
+ int xb_result = 0;
my_log("POLYGLOT GAME END\n");
@@ -506,17 +507,35 @@
mess();
+ if (FALSE) {
+ } else if (my_string_equal(Star[0],"1-0")) {
+ xb_result = 1;
+ } else if (my_string_equal(Star[0],"0-1")) {
+ xb_result = -1;
+ } else if (my_string_equal(Star[0],"1/2-1/2")) {
+ xb_result = 0;
+ }
+
+ if (option_get_bool(Option,"GameOver_command")) {
+ if (xb_result == 0)
+ uci_send_gameover(Uci, 0);
+ else if (State->computer[White] == TRUE)
+ uci_send_gameover(Uci, xb_result);
+ else
+ uci_send_gameover(Uci, xb_result * -1);
+ }
+
// book learning
if (option_get_bool(Option,"Book") &&
option_get_bool(Option,"BookLearn")) {
if (FALSE) {
- } else if (my_string_equal(Star[0],"1-0")) {
+ } else if (xb_result == 1) {
learn(+1);
- } else if (my_string_equal(Star[0],"0-1")) {
+ } else if (xb_result == -1) {
learn(-1);
- } else if (my_string_equal(Star[0],"1/2-1/2")) {
+ } else if (xb_result == 0) {
learn(0);
}
}