From: Steinar H. Gunderson Date: Sat, 30 Jun 2007 15:50:00 +0000 (+0200) Subject: Print out who's doing the analysis. X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=0a8aa7b78bf6011452eceb6a3aeef3bf7017ae83 Print out who's doing the analysis. --- diff --git a/remoteglot.pl b/remoteglot.pl index 9aaa43d..d457e92 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -41,6 +41,7 @@ select(STDOUT); # open the chess engine my $pid = IPC::Open2::open2(*UCIREAD, *UCIWRITE, $engine); my %uciinfo = (); +my %uciid = (); my %ficsinfo = (); uciprint("uci"); @@ -48,6 +49,7 @@ uciprint("uci"); # gobble the options while () { /uciok/ && last; + handle_uci($_); } uciprint("setoption name UCI_AnalyseMode value true"); @@ -105,15 +107,7 @@ while (1) { # any fun on the UCI channel? if ($nfound > 0 && vec($rout, fileno(UCIREAD), 1) == 1) { my $line = ; - chomp $line; - $line =~ tr/\r//d; - print UCILOG "<= $line\n"; - if ($line =~ /^info/) { - my (@infos) = split / /, $line; - shift @infos; - - parse_infos(@infos); - } + handle_uci($line); $sleep = 0; # don't update too often @@ -123,6 +117,26 @@ while (1) { sleep $sleep; } +sub handle_uci { + my ($line) = @_; + + chomp $line; + $line =~ tr/\r//d; + print UCILOG "<= $line\n"; + if ($line =~ /^info/) { + my (@infos) = split / /, $line; + shift @infos; + + parse_infos(@infos); + } + if ($line =~ /^id/) { + my (@ids) = split / /, $line; + shift @ids; + + parse_ids(@ids); + } +} + sub parse_infos { my (@x) = @_; my $mpv = ''; @@ -179,6 +193,22 @@ sub parse_infos { } } +sub parse_ids { + my (@x) = @_; + + while (scalar @x > 0) { + if ($x[0] =~ /^(name|author)$/) { + my $key = shift @x; + my $value = join(' ', @x); + $uciid{$key} = $value; + last; + } + + # unknown + shift @x; + } +} + sub style12_to_fen { my $str = shift; my (@x) = split / /, $str; @@ -433,7 +463,12 @@ sub output_screen { return; } - print "Analysis:\n\n"; + print ""; # clear the screen + if (exists($uciid{'name'})) { + print "Analysis by $uciid{'name'}:\n\n"; + } else { + print "Analysis:\n\n"; + } return unless (exists($ficsinfo{'board'}));