Merge pull request #50 from lemonsqueeze/can_countercap
[pachi.git] / t-play / autotest / autotest-show-diagram
blob518bf5655e8304d82428e95429163b7ccdc4dc94
1 #!/usr/bin/perl
2 # Display confidence diagrams
3 # Usage: ./autotest-show-diagram [pairing-pattern]
4 # Make sure you run ./autotest-gather first !
6 my $mask = $ARGV[0];
8 my $confidence = 95;
9 #my $confidence = 67;
11 my $ratio;
12 if ($confidence == 95)
13 { $ratio = 1.96; }
14 elsif ($confidence == 67)
15 { $ratio = 1; }
16 else
17 { die "fixme"; }
18 print "Confidence level: $confidence%\n";
20 open(IN, "./autotest-show | ");
21 my $spaces = " ";
22 my $hashes = "################################################################################################";
23 while (my $str = <IN>)
25 if ($str =~ m/$mask/ &&
26 $str =~ m/([0-9]+)\t([0-9.]+)\t([0-9.]+)\t(.*)/)
28 my ($games, $wr, $sd, $name) = ($1, $2, $3, $4);
29 if (!$games)
30 { continue; }
31 $wr = $wr * 100;
32 $sd = $sd * 100;
33 $min = $wr - $ratio * $sd;
34 $max = $wr + $ratio * $sd;
35 $min_int = int($min + 0.5); # Don't use this for < 0 numbers !
36 $max_int = int($max + 0.5);
38 printf("%4i %-40s [%i%%-%i%%] ", $games, "$name", $min_int, $max_int);
39 my $shift_left = 20;
40 printf("%.*s[%.*s]\n", $min_int - 1 - $shift_left, "$spaces", $max_int - $min_int - 1, "$hashes");