Add option to allow Polyglot to accept draw offers
[polyglot.git] / xboard2uci.c
index fcc1812..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;
@@ -1014,8 +1018,10 @@ static void comp_move(int move) {
          my_log("POLYGLOT %d move%s with resign score\n",State->resign_nb,(State->resign_nb>1)?"s":"");
 
          if (State->resign_nb >= option_get_int(Option,"ResignMoves")) {
-            my_log("POLYGLOT *** RESIGN ***\n");
-            gui_send(GUI,"resign");
+           if (!option_get_bool(Option,"QueenNeverResigns") || !board_has_queen(board, board->turn)) { // [HGM] suppress resignig with Queen
+                my_log("POLYGLOT *** RESIGN ***\n");
+                gui_send(GUI,"resign");
+           }
          }
 
       } else {