selfatari_cousin(): Suggest counter-captures
[pachi/peepo.git] / tools / pattern_bayes_merge.sh
blob598928803656fa16060ed1e31dd1c2440b399d36
1 #!/bin/sh
2 # pattern_bayes_merge: Merge pattern probability tables; pass them
3 # as arguments.
5 cat "$@" | perl -nle '
6 chomp;
7 my ($p, $ch, $co, $pa) = /^(.*?) (\d+) (\d+) (.*)$/;
8 $pa or die "parse error: $_";
9 $choices{$pa} += $ch;
10 $counts{$pa} += $co;
12 END {
13 for (keys %counts) {
14 $p{$_} = $choices{$_} / $counts{$_};
16 for (sort { $counts{$a} <=> $counts{$b} } keys %p) {
17 next if ($counts{$_} < 2);
18 printf("%.3f %d %d %s\n", $p{$_}, $choices{$_}, $counts{$_}, $_);