From: Steinar H. Gunderson Date: Sat, 30 Jun 2007 15:19:11 +0000 (+0200) Subject: Try to weed out invalid PVs before printing them; should return somewhat X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=724119d41259a918dfb96531634815c85812bb91;hp=517f9dd2dc682986409a7dfc1e492b7723d32dbb Try to weed out invalid PVs before printing them; should return somewhat less junk in the output. --- diff --git a/remoteglot.pl b/remoteglot.pl index eecad8f..50b3fba 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -264,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; @@ -406,6 +410,27 @@ sub prettyprint_pv { sub output_screen { #return; + # + # 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 "cAnalysis:\n"; return unless (exists($ficsinfo{'board'}));