From bbb9d7bd143c2df3950024e545ebf4321631ecd4 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Sun, 24 Jun 2018 12:43:59 -0700 Subject: [PATCH] Fix fm_polyglot to send "white" or "black" before "go". --- doc/cboard.6.in | 11 +++++++++-- doc/config.example | 4 ++-- src/cboard.c | 8 -------- src/engine.c | 11 +++++++++++ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/doc/cboard.6.in b/doc/cboard.6.in index 56e1c7e..cedebfb 100644 --- a/doc/cboard.6.in +++ b/doc/cboard.6.in @@ -170,8 +170,15 @@ or reset. Can be specified more than once. .TP .I fm_polyglot -Send the "go" command to the chess engine during the first move. Fixes -a quirk when using polyglot(1). +Send the needed commands: +.B go +and +.B white +or +.B black +, due to a quirk when using +.BR polyglot (6) +as the chess engine. .TP .I turn_cmd [] [...] diff --git a/doc/config.example b/doc/config.example index 857339b..1d25331 100644 --- a/doc/config.example +++ b/doc/config.example @@ -21,8 +21,8 @@ # Can be used more than once to specify as many commands as needed. #engine_init depth 3 -# Send the "go" command to the chess engine during the first move. -# This fixes a quirk when interfacing with polyglot(1). +# Send the needed commands: "go" and "white" or "black", due to a quirk when +# using polyglot as the chess engine. #fm_polyglot off # The number of moves to jump when browsing move history and pressing the UP diff --git a/src/cboard.c b/src/cboard.c index 1db101d..ad11542 100644 --- a/src/cboard.c +++ b/src/cboard.c @@ -3166,14 +3166,6 @@ do_play_commit () if (d->rotate && d->sp.icon) rotate_position (&d->sp.srow, &d->sp.scol); - // Envia comando 'go' a Polyglot en el primer movimiento debido a que - // polyglot no envia el movimiento y cboard se queda esperando. - // Send command 'go' to the first movement Polyglot because cboard - // waits to send polyglot movement and this does not make. - if (config.fmpolyglot && - ((gp->side == WHITE && !gp->hindex) || fm_loaded_file)) - add_engine_command (gp, ENGINE_THINKING, "go\n"); - d->go_move = 0; fm_loaded_file = FALSE; d->pm_undo = FALSE; diff --git a/src/engine.c b/src/engine.c index a8e4259..15c8dcb 100644 --- a/src/engine.c +++ b/src/engine.c @@ -258,6 +258,17 @@ init_chess_engine (GAME g) tmp = pgn_game_to_fen (g, d->b); add_engine_command (g, ENGINE_READY, "setboard %s\n", tmp); free (tmp); + + if (config.fmpolyglot && !TEST_FLAG (d->flags, CF_HUMAN) ) + { + add_engine_command (g, ENGINE_READY, "%s\n", + g->side == WHITE ? "white" : "black"); + if (g->turn == WHITE && g->side == BLACK) + add_engine_command (g, ENGINE_READY, "%s\n", "go"); + else if (g->turn == BLACK && g->side == WHITE) + add_engine_command (g, ENGINE_READY, "%s\n", "go"); + } + return 0; } -- 2.11.4.GIT