Package: phalanx Version: 25-1~mx21 Severity: normal Tags: patch X-Debbugs-Cc: mssr...@gmail.com
Dear Maintainer, *** Reporter, please consider answering these questions, where appropriate *** * What led up to the situation? I setup a position and had the program play both sides. The game ended with a checkmate. * What exactly did you do (or not do) that was effective (or ineffective)? See the example that follows for an illustrative case. * What was the outcome of this action? The game's last move and outcome were printed to stdout but not to the logfile which I had specified using the "-g" command line option. * What outcome did you expect instead? A complete listing of the moves and outcome. * This is an example that demonstrates the problem. $ phalanx -g logfile.out setboard 7Q/8/3K4/2q5/6P1/4q3/5k2/8 w - - 0 0 both machine plays both my move is Kd6-d7 move d6d7 my move is Qe3-e7 move e3e7 0-1 {Black mates} quit $ cat logfile.out << other stuff snipped>> opponent plays Kd6-d7 <<other stuff snipped>> <quit $ Note that the last move and game outcome message are not included in logfile.out. * My proposal to fix the problem. I have created a patch. *** End of the template - remove these template lines *** -- System Information: Debian Release: 11.7 APT prefers oldstable-updates APT policy: (500, 'oldstable-updates'), (500, 'oldstable-security'), (500, 'oldstable') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 5.10.0-23-amd64 (SMP w/1 CPU thread) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /usr/bin/dash Init: sysvinit (via /sbin/init) Versions of packages phalanx depends on: ii debconf [debconf-2.0] 1.5.77 ii libc6 2.31-13+deb11u6 phalanx recommends no packages. Versions of packages phalanx suggests: ii xfce4-terminal [x-terminal-emulator] 1.0.2-0.1~mx21+1 -- debconf information: phalanx/learning_file_erase: false
>From e0d44aa391619275677c3d51986a7b99bbc06410 Mon Sep 17 00:00:00 2001 From: Michael Soyka <mssr...@gmail.com> Date: Thu, 27 Jul 2023 17:26:24 -0400 Subject: [PATCH 1/4] ensure game-ending move is logged When logging is enabled via the "-g" option and a move is made that causes checkmate, stalemate, or draws by the 50-move or 3-time repetition, that move would not be recorded in the logfile. This patch fixes the problem. --- io.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/io.c b/io.c index cd4b7e3..e83c148 100644 --- a/io.c +++ b/io.c @@ -1776,16 +1776,39 @@ while( command() ) printf("move "); gnuprintm(m); puts(""); } - switch( ( ter = terminal() ) ) + /* + * Test for game-over + */ + ter = terminal(); + if ( (1 <= ter) && (ter <= 3) ) { - case 1: puts("1/2-1/2 {Drawn game}"); continue; - case 2: puts("1/2-1/2 {Stalemate}"); continue; - case 3: - if( Color == WHITE ) - puts("0-1 {Black mates}"); - else - puts("1-0 {White mates}"); - continue; + const char *gameResult; + switch (ter) + { + case 1: + gameResult = "1/2-1/2 {Drawn game}"; + break; + case 2: + gameResult = "1/2-1/2 {Stalemate}"; + break; + case 3: + if (Color == WHITE) + gameResult = "0-1 {Black mates}"; + else + gameResult = "1-0 {White mates}"; + break; + } + puts(gameResult); + if (Flag.log != NULL) + { + char pb[640]; + printm( G[Counter-1].m, pb ); + fprintf(Flag.log,"\n opponent plays %s\n",pb); + printboard(pb); + fprintf(Flag.log, pb); + fprintf(Flag.log, "\n%s\n", gameResult); + } + continue; } if( Flag.ponder == 1 -- 2.30.2