6
use Games::Solitaire::Verify::Solution;
8
open my $dump_fh, '<', '982.dump'
9
or die "Cannot open 982.dump";
11
my $initial_state_str;
14
my $two_fc_variant = Games::Solitaire::Verify::VariantsMap->new->get_variant_by_id('freecell');
16
$two_fc_variant->num_freecells(2);
19
my %states_to_components = ();
21
while (my $line = <$dump_fh>)
23
if (($line =~ m{^Foundations}) .. ($line !~ /\S/))
31
# $state_str is now ready.
32
if (!defined($initial_state_str))
34
$initial_state_str = $state_str;
35
$initial_board = Games::Solitaire::Verify::State->new(
37
string => $initial_state_str,
39
variant_params => $two_fc_variant,
44
my $board = Games::Solitaire::Verify::State->new(
46
string => $initial_state_str,
48
variant_params => $two_fc_variant,
52
my $found_str = join(',',
53
map { $board->get_foundation_value($_, 0) } (0 .. 3)
56
my @columns_non_free_lens;
58
foreach my $col_idx (0 .. ($board->num_columns - 1))
60
my $col = $board->get_column($col_idx);
62
my $get_non_free_len = sub {
63
my $non_free_len = $col->len();
65
while ($non_free_len > 1)
67
my $child = $col->pos($non_free_len-1);
68
my $parent = $col->pos($non_free_len-2);
70
if (not (($child->color() ne $parent->color())
72
($child->rank()+1 == $parent->rank())))
84
push @columns_non_free_lens, $get_non_free_len->();
87
my $component_id = $found_str . ';' . join(',', @columns_non_free_lens);
89
if (exists($states_to_components{$state_str}))
91
if ($states_to_components{$state_str} ne $component_id)
93
die "MisMATCH! <<<$state_str>>> ; <<<$component_id>>> ; <<<$states_to_components>>>";
96
elsif (exists($components{$component_id}))
98
die "Two component IDs with different components - <<<$component_id>>>!";
102
$components{$component_id} = 1;
103
# Do a BrFS scan on the fully connected component.