]> git.sesse.net Git - remoteglot/blobdiff - remoteglot.pl
Fix some corner cases around in-TB positions.
[remoteglot] / remoteglot.pl
index 9742a5a09a8686e93270290961ac4fa3704a2dae..b9055a64d30616ff945bed8fd59c500ab8eeb62c 100755 (executable)
@@ -1180,13 +1180,21 @@ sub score_digest {
                }
                if (exists($info->{'splicepos' . $mpv})) {
                        my $sp = $info->{'splicepos' . $mpv};
-                       if ($mate < 0) {
-                               return ['tb', -$sp];
+                       if ($mate > 0) {
+                               return ['T', $sp];
                        } else {
-                               return ['tb', $sp];
+                               return ['t', $sp];
                        }
                } else {
-                       return ['m', $mate];
+                       if ($mate > 0) {
+                               return ['M', $mate];
+                       } elsif ($mate < 0) {
+                               return ['m', -$mate];
+                       } elsif ($pos->{'toplay'} eq 'B') {
+                               return ['M', 0];
+                       } else {
+                               return ['m', 0];
+                       }
                }
        } else {
                if (exists($info->{'score_cp' . $mpv})) {
@@ -1216,9 +1224,9 @@ sub long_score {
                if (exists($info->{'splicepos' . $mpv})) {
                        my $sp = $info->{'splicepos' . $mpv};
                        if ($mate > 0) {
-                               return sprintf "White wins in %u/%u", int(($sp + 1) * 0.5), $sp;
+                               return sprintf "White wins in %u", int(($sp + 1) * 0.5);
                        } else {
-                               return sprintf "Black wins in %u/%u", int(($sp + 1) * 0.5), $sp;
+                               return sprintf "Black wins in %u", int(($sp + 1) * 0.5);
                        }
                } else {
                        if ($mate > 0) {