]> git.sesse.net Git - remoteglot/blobdiff - remoteglot.pl
Tiny simplification in serve-analysis.js.
[remoteglot] / remoteglot.pl
index 9742a5a09a8686e93270290961ac4fa3704a2dae..df524a6b2e4ddd06d41ec8e8a4f2a8bf836adfb6 100755 (executable)
@@ -152,7 +152,7 @@ sub handle_uci {
        return if ($engine->{'stopping'} && $line !~ /^bestmove/);
        $engine->{'stopping'} = 0;
 
-       if ($line =~ /^info/) {
+       if ($line =~ /^info/ && $line !~ / cluster /) {
                my (@infos) = split / /, $line;
                shift @infos;
 
@@ -1072,7 +1072,7 @@ sub output_json {
        }
 
        if (exists($pos_calculating->{'history'}) &&
-           defined($remoteglotconf::json_history_dir)) {
+           defined($remoteglotconf::json_history_dir) && defined($json->{'engine'}{name})) {
                my $id = id_for_pos($pos_calculating);
                my $filename = $remoteglotconf::json_history_dir . "/" . $id . ".json";
 
@@ -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) {