File: verify-variant-range.pl

package info (click to toggle)
freecell-solver 3.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,332 kB
  • sloc: ansic: 29,493; perl: 8,911; xml: 5,162; python: 1,124; sh: 777; ruby: 358; cpp: 304; makefile: 150
file content (73 lines) | stat: -rw-r--r-- 1,382 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
#!/usr/bin/perl

use strict;
use warnings;
use autodie;

use Getopt::Long;

use String::ShellQuote;
use Data::Dumper;

use Games::Solitaire::Verify::Solution;

my $theme;
GetOptions(
    'l|load=s' => \$theme,
);

my $theme_s = "";

if ($ENV{THEME})
{
    $theme_s = $ENV{THEME};
}

if (defined($theme))
{
    $theme_s = shell_quote("-l", $theme);
}

my $variant = ($ENV{VARIANT} || "simple_simon");

my $ms = ($ENV{MS} ? " --ms " : '');

open my $dump, "<", "total_dump.txt";
LINES_LOOP:
while (!eof($dump))
{
    my @l = (map { scalar(<$dump>) } (1 .. 4));
    chomp(@l);
    my ($deal) = ($l[0] =~ m{\A(\d+):});
    print "Testing Deal No. $deal\n";

    if ($l[1] !~ m{This game is solveable})
    {
        next LINES_LOOP;
    }

    open my $fc_solve_output,
        +("make_pysol_freecell_board.py $ms -t $deal $variant | " .
        "./fc-solve -g $variant -p -t -sam $theme_s - |")
        or Carp::confess "Error! Could not open the fc-solve pipeline";

    # Initialise a column
    my $solution = Games::Solitaire::Verify::Solution->new(
        {
            input_fh => $fc_solve_output,
            variant => $variant,
        },
    );

    my $verdict = $solution->verify();

    if ($verdict)
    {
        print("Verdict == " . Dumper($verdict));
        Carp::confess("Deal No. $deal failed verification");
    }

    close($fc_solve_output);
}

close($dump);