From: H.G. Muller Date: Mon, 12 Mar 2012 11:18:33 +0000 (+0100) Subject: Add option to resign only without queen X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=2deb3f708afc86aaa77ed5c334c39ea43cd3d828;p=polyglot.git Add option to resign only without queen --- diff --git a/board.c b/board.c index 4f1139f..5c8231a 100644 --- a/board.c +++ b/board.c @@ -270,6 +270,24 @@ bool board_equal(const board_t * board_1, const board_t * board_2) { return TRUE; } +// board_has_queen() + +bool board_has_queen(const board_t * board, int colour) { + + int sq_64, sq, piece; + + ASSERT(board!=NULL); + + for (sq_64 = 0; sq_64 < 64; sq_64++) { + sq = square_from_64(sq_64); + piece = board->square[sq]; + if (colour_equal(piece,colour) && piece_is_queen(piece)) { + return TRUE; + } + } + return FALSE; +} + // board_init_list() void board_init_list(board_t * board) { diff --git a/board.h b/board.h index 00ec1c4..79208ce 100644 --- a/board.h +++ b/board.h @@ -49,6 +49,8 @@ extern void board_start (board_t * board); extern void board_copy (board_t * dst, const board_t * src); extern bool board_equal (const board_t * board_1, const board_t * board_2); +extern bool board_has_queen (const board_t * board, int colour); + extern void board_init_list (board_t * board); extern int board_flags (const board_t * board); diff --git a/option.c b/option.c index 57935ad..e77c799 100644 --- a/option.c +++ b/option.c @@ -46,6 +46,7 @@ option_t DefaultOptions[] = { { "Resign", "check","0","0", "false" , NULL,0,NNB, PG|XBOARD|XBSEL}, { "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}, { "MateScore", "spin","0","100000", "10000" , NULL,0,NNB, PG|XBOARD}, diff --git a/xboard2uci.c b/xboard2uci.c index fcc1812..00d582b 100644 --- a/xboard2uci.c +++ b/xboard2uci.c @@ -1014,8 +1014,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 {