From cb7bd8a40da5de2a53633fb3dc27b8435f49468e Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 2 Jul 2007 00:35:09 +0200 Subject: [PATCH] Factor out the short and long scores into separate functions. --- remoteglot.pl | 82 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/remoteglot.pl b/remoteglot.pl index 36af4ed..5409d7b 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -63,7 +63,7 @@ uciprint("setoption name UCI_AnalyseMode value true"); uciprint("setoption name NalimovPath value c:\\nalimov"); uciprint("setoption name NalimovUsage value Rarely"); uciprint("setoption name Hash value 1024"); -uciprint("setoption name MultiPV value 3"); +# uciprint("setoption name MultiPV value 3"); # uciprint("setoption name Contempt value 1000"); # uciprint("setoption name Outlook value Ultra Optimistic"); uciprint("ucinewgame"); @@ -496,19 +496,9 @@ sub output_screen { my $mpv = 1; while (exists($uciinfo{'pv' . $mpv})) { $text .= sprintf " PV%2u", $mpv; + my $score = short_score(\%uciinfo, \%ficsinfo, $mpv); + $text .= " ($score)" if (!defined($score)); - if (defined($uciinfo{'score_mate' . $mpv})) { - $text .= sprintf " (M%3d)", $uciinfo{'score_mate' . $mpv}; - } else { - if (exists($uciinfo{'score_cp' . $mpv})) { - my $score = $uciinfo{'score_cp' . $mpv} * 0.01; - if ($ficsinfo{'toplay'} eq 'B') { - $score = -$score; - } - $text .= sprintf " (%+5.2f)", $score; - } - } - if (exists($uciinfo{'nodes' . $mpv}) && exists($uciinfo{'nps' . $mpv}) && exists($uciinfo{'depth' . $mpv})) { $text .= sprintf " (%5u kn, %3u kn/s, %2u ply)", $uciinfo{'nodes' . $mpv} / 1000, $uciinfo{'nps' . $mpv} / 1000, $uciinfo{'depth' . $mpv}; @@ -534,26 +524,8 @@ sub output_screen { } # single-PV - if (defined($uciinfo{'score_mate'})) { - my $mate = $uciinfo{'score_mate'}; - if ($ficsinfo{'toplay'} eq 'B') { - $mate = -$mate; - } - if ($mate > 0) { - $text .= sprintf " White mates in %u\n", $mate; - } else { - $text .= sprintf " Black mates in %u\n", -$mate; - } - } else { - if (exists($uciinfo{'score_cp'})) { - my $score = $uciinfo{'score_cp'} * 0.01; - if ($ficsinfo{'toplay'} eq 'B') { - $score = -$score; - } - $text .= sprintf " Score: %+5.2f\n", $score; - } - } - + my $score = long_score(\%uciinfo, \%ficsinfo, ''); + $text .= " $score\n" if defined($score); $text .= " PV: " . join(', ', prettyprint_pv($ficsinfo{'board'}, @{$uciinfo{'pv'}})); $text .= "\n"; @@ -788,3 +760,47 @@ sub uciprint { print UCIWRITE "$msg\n"; print UCILOG "=> $msg\n"; } + +sub short_score { + my ($uciinfo, $ficsinfo, $mpv) = @_; + + if (defined($uciinfo{'score_mate' . $mpv})) { + return sprintf "M%3d", $uciinfo{'score_mate' . $mpv}; + } else { + if (exists($uciinfo{'score_cp' . $mpv})) { + my $score = $uciinfo{'score_cp' . $mpv} * 0.01; + if ($ficsinfo{'toplay'} eq 'B') { + $score = -$score; + } + return sprintf "%+5.2f", $score; + } + } + + return undef; +} + +sub long_score { + my ($uciinfo, $ficsinfo, $mpv) = @_; + + if (defined($uciinfo{'score_mate' . $mpv})) { + my $mate = $uciinfo{'score_mate' . $mpv}; + if ($ficsinfo{'toplay'} eq 'B') { + $mate = -$mate; + } + if ($mate > 0) { + return sprintf "White mates in %u", $mate; + } else { + return sprintf "Black mates in %u", -$mate; + } + } else { + if (exists($uciinfo{'score_cp' . $mpv})) { + my $score = $uciinfo{'score_cp' . $mpv} * 0.01; + if ($ficsinfo{'toplay'} eq 'B') { + $score = -$score; + } + return sprintf "Score: %+5.2f", $score; + } + } + + return undef; +} -- 2.39.2