File: simple-simon-stats-analysis.pl

package info (click to toggle)
freecell-solver 3.26.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,864 kB
  • ctags: 3,658
  • sloc: ansic: 34,721; perl: 12,320; xml: 5,999; python: 1,149; sh: 965; ruby: 347; cpp: 304; makefile: 151
file content (80 lines) | stat: -rw-r--r-- 1,761 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/perl

use strict;
use warnings;

use Statistics::Descriptive;

my @buckets_ids = (qw(solved unsolvable));
my %buckets =
(
    (map { $_ => Statistics::Descriptive::Full->new() } @buckets_ids)
);

my $filename = shift(@ARGV);
open my $in, "<", $filename
    or die "Cannot open file '$filename'";

my @stuck;
while (!eof($in))
{
    # @l = Lines.
    my @l = map { scalar(<$in>) } (1 .. 4);
    chomp(@l);

    my $b;
    if ($l[1] =~ m{\AI could not solve this game})
    {
        $b = "unsolvable";
    }
    elsif ($l[1] =~ m{\AThis game is solveable})
    {
        $b = "solved";
    }
    else
    {
        die "Unknown bucket with line '$l[1]' at game No. '$l[0]'!";
    }

    if ($l[2] !~ m{\ATotal number of states checked is (\d+)\.})
    {
        die "Unknown line format at game No. '$l[0]'"
    }
    my $stat = $1;

    if ($stat == 1_500_000)
    {
        push @stuck, $l[0];
    }
    else
    {
        $buckets{$b}->add_data($stat);
    }
}
close($in);

foreach my $b (@buckets_ids)
{
    my $bucket = $buckets{$b};
    print "$b\n";
    print "--------------\n\n";
    print "Count: ", $bucket->count(), "\n";
    print "Mean: ", $bucket->mean(), "\n";
    print "StdDev: ", $bucket->standard_deviation(), "\n";
    print "Median: ", $bucket->median(), "\n";
    print "Min: ", $bucket->min(), "\n";
    print "Max: ", $bucket->max(), "\n";

    my @limits = (100, 1_000, 10_000, 100_000, 1_000_000, 1_500_000);
    my $f = $bucket->frequency_distribution_ref(\@limits);
    foreach my $l (@limits)
    {
        print "Up to $l: $f->{$l} ("
            . sprintf("%.2f%%", $f->{$l}*100/$bucket->count())
            . ")\n"
            ;
    }
    print "\n\n";
}

print "Stuck:\n--------------\n" . join(",", @stuck) . "\n";