X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=remoteglot.pl;h=1bdfea08b8fa9f7169a9be157fad25f945341a0d;hp=ea1e13de9be03d4b1be1698eb931d2f6d18b10a4;hb=8b2bd2fb0d74d954e3a4f8359a8a956254960666;hpb=10249b886d1ac8988d7c099d384f92a6800b73c2 diff --git a/remoteglot.pl b/remoteglot.pl index ea1e13d..1bdfea0 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -21,7 +21,7 @@ $SIG{ALRM} = sub { output_screen(); }; $| = 1; my $server = "freechess.org"; -my $target = "GMCarlsen"; +my $target = "Sesse"; # my $engine = "/usr/games/toga2"; my $engine = "wine Rybkav2.3.2a.mp.w32.exe"; @@ -52,8 +52,9 @@ while () { uciprint("setoption name UCI_AnalyseMode value true"); uciprint("setoption name NalimovPath value c:\\nalimov"); -uciprint("setoption name NalimovUsage value Normally"); -uciprint("setoption name MultiPV value 3"); +uciprint("setoption name NalimovUsage value Rarely"); +uciprint("setoption name Hash value 1024"); +# uciprint("setoption name MultiPV value 3"); # uciprint("setoption name Contempt value 1000"); # uciprint("setoption name Outlook value Ultra Optimistic"); uciprint("ucinewgame"); @@ -263,6 +264,10 @@ sub prettyprint_pv { my $pretty; my $piece = substr($board->[$from_row], $from_col, 1); + if ($piece eq '-') { + die "Invalid move"; + } + # white short castling if ($pv eq 'e1g1' && $piece eq 'K') { my @nb = @$board; @@ -303,7 +308,7 @@ sub prettyprint_pv { # rook substr($nb[0], 7, 1, '-'); - substr($nb[0], 5, 1, 'R'); + substr($nb[0], 5, 1, 'r'); return ('0-0', prettyprint_pv(\@nb, @pvs)); } @@ -318,7 +323,7 @@ sub prettyprint_pv { # rook substr($nb[0], 0, 1, '-'); - substr($nb[0], 3, 1, 'R'); + substr($nb[0], 3, 1, 'r'); return ('0-0-0', prettyprint_pv(\@nb, @pvs)); } @@ -405,7 +410,28 @@ sub prettyprint_pv { sub output_screen { #return; - print "cAnalysis:\n"; + # + # Check the PVs first. if they're invalid, just wait, as our data + # is most likely out of sync. This isn't a very good solution, as + # it can frequently miss stuff, but it's good enough for most users. + # + eval { + my $dummy; + if (exists($uciinfo{'pv'})) { + $dummy = prettyprint_pv($ficsinfo{'board'}, @{$uciinfo{'pv'}}); + } + + my $mpv = 1; + while (exists($uciinfo{'pv' . $mpv})) { + $dummy = prettyprint_pv($ficsinfo{'board'}, @{$uciinfo{'pv' . $mpv}}); + ++$mpv; + } + }; + if ($@) { + return; + } + + print "Analysis:\n\n"; return unless (exists($ficsinfo{'board'})); @@ -440,7 +466,15 @@ sub output_screen { } else { # single-PV if (defined($uciinfo{'score_mate'})) { - printf " Mate in %d\n", $uciinfo{'score_mate'}; + my $mate = $uciinfo{'score_mate'}; + if ($ficsinfo{'toplay'} eq 'B') { + $mate = -$mate; + } + if ($mate > 0) { + printf " White mates in %u\n", $mate; + } else { + printf " Black mates in %u\n", -$mate; + } } else { if (exists($uciinfo{'score_cp'})) { my $score = $uciinfo{'score_cp'} * 0.01; @@ -533,7 +567,7 @@ sub in_check { for my $row (0..7) { for my $col (0..7) { my $piece = substr($board->[$row], $col, 1); - next if ($piece eq '-' || lc($piece) eq 'k'); + next if ($piece eq '-'); if (uc($piece) eq $piece) { # white piece