#! perl -nlw
# need to manually delete everything before "go infinite"
next if /^>>/;
next if /^<< info depth \d+ currmove \S+ currmovenumber \d+$/;
if (/^<< info depth (\d+) .* multipv .* score (.*) nodes \d+ nps \d+ (?:hashfull \d+ )?tbhits 0 time \d+ pv ((\S+).*)/){
    $depth=$1;
    $score=$2;
    $pv=$3;
    $firstpv=$4;
    die unless $score =~ /^cp (\S+)/;
    $score=$1;
    $store{$depth." ".$firstpv}="$score $pv";
    next;
}
die "unparsable line $_";
END{
    for (keys %store){
        ($depth=$_) =~ s/ .*//;
        die unless $store{$_} =~ /(\S+) (.+)/;
        $score=$1;
        $pv=$2;
        #print "$depth $store{$_}";
        printf("depth % 2d score %4d pv %s\n",$depth,$score,$pv);
    }
}
