Add option to allow Polyglot to accept draw offers
authorH.G. Muller <h.g.muller@hccnet.nl>
Mon, 12 Mar 2012 12:01:29 +0000 (13:01 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Mon, 12 Mar 2012 12:01:29 +0000 (13:01 +0100)
For engines that do not support the UCI_DrawOffers option, Polyglot
can accept a draw offer based on a contempt score.

option.c
xboard2uci.c

index e77c799..0feeea7 100644 (file)
--- a/option.c
+++ b/option.c
@@ -48,6 +48,8 @@ option_t DefaultOptions[] = {
     { "ResignMoves",      "spin","0","10000",    "3"        , NULL,0,NNB,  PG|XBOARD|XBSEL}, 
     { "QueenNeverResigns","check","0","0",      "true"      , NULL,0,NNB,  PG|XBOARD|XBSEL}, 
     { "ResignScore",      "spin","0","10000",   "600"       , NULL,0,NNB,  PG|XBOARD|XBSEL}, 
+    { "HandleDraws",      "check","0","0",      "false"     , NULL,0,NNB,  PG|XBOARD|XBSEL}, 
+    { "ContemptScore",    "spin","0","10000",   "30"        , NULL,0,NNB,  PG|XBOARD|XBSEL}, 
 
     { "MateScore",        "spin","0","100000",  "10000"     , NULL,0,NNB,  PG|XBOARD}, 
 
index 00d582b..f0288d7 100644 (file)
@@ -231,6 +231,10 @@ void xboard2uci_gui_step(char string[]) {
                        if(option_find(Uci->option,"UCI_DrawOffers")){
                            my_log("POLYGLOT draw from XB received");
                                uci_send_option(Uci,"DrawOffer","%s","draw");}
+                       else if (option_get_bool(Option,"HandleDraws") && Uci->root_move_nb > 20) { // [HGM] PG draw handling
+                           my_log("POLYGLOT draw from XB received");
+                           if (Uci->best_score <= -option_get_int(Option,"ContemptScore")) 
+                               gui_send(GUI,"offer draw");}
                } else if (match(string,"easy")) {
 
                        XB->ponder = FALSE;