| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Games::Solitaire::Verify::App::CmdLine::From_Patsolve; |
|
2
|
|
|
|
|
|
|
$Games::Solitaire::Verify::App::CmdLine::From_Patsolve::VERSION = '0.2402'; |
|
3
|
1
|
|
|
1
|
|
130060
|
use strict; |
|
|
1
|
|
|
|
|
13
|
|
|
|
1
|
|
|
|
|
61
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use autodie; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5897
|
use parent 'Games::Solitaire::Verify::FromOtherSolversBase'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
68
|
use List::Util qw(first); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
750
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_acc_ref( |
|
12
|
|
|
|
|
|
|
[ |
|
13
|
|
|
|
|
|
|
qw( |
|
14
|
|
|
|
|
|
|
_st |
|
15
|
|
|
|
|
|
|
_filename |
|
16
|
|
|
|
|
|
|
_sol_filename |
|
17
|
|
|
|
|
|
|
_variant_params |
|
18
|
|
|
|
|
|
|
_buffer_ref |
|
19
|
|
|
|
|
|
|
) |
|
20
|
|
|
|
|
|
|
] |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _perform_move |
|
24
|
|
|
|
|
|
|
{ |
|
25
|
147
|
|
|
147
|
|
852
|
my ( $self, $move_line ) = @_; |
|
26
|
|
|
|
|
|
|
|
|
27
|
147
|
100
|
|
|
|
917
|
if ( my ($src_card_s) = $move_line =~ /\A(.[HCDS]) to temp\z/ ) |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
|
29
|
31
|
|
|
|
|
90
|
my $src_col_idx = $self->_find_col_card($src_card_s); |
|
30
|
31
|
50
|
|
|
|
153
|
if ( not defined($src_col_idx) ) |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
0
|
|
|
|
|
0
|
die "Cannot find card."; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $dest_fc_idx = first |
|
36
|
|
|
|
|
|
|
{ |
|
37
|
80
|
|
|
80
|
|
208
|
!defined( $self->_st->get_freecell($_) ) |
|
38
|
|
|
|
|
|
|
} |
|
39
|
31
|
|
|
|
|
143
|
( 0 .. $self->_st->num_freecells - 1 ); |
|
40
|
|
|
|
|
|
|
|
|
41
|
31
|
50
|
|
|
|
118
|
if ( not defined($dest_fc_idx) ) |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
0
|
|
|
|
|
0
|
die "No empty freecell."; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$self->_perform_and_output_move( |
|
47
|
31
|
|
|
|
|
168
|
sprintf( |
|
48
|
|
|
|
|
|
|
"Move a card from stack %d to freecell %d", |
|
49
|
|
|
|
|
|
|
$src_col_idx, $dest_fc_idx, |
|
50
|
|
|
|
|
|
|
), |
|
51
|
|
|
|
|
|
|
); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
elsif ( ($src_card_s) = $move_line =~ /\A(.[HCDS]) out\z/ ) |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
54
|
|
|
|
|
140
|
my @src_s = $self->_find_card_src_string($src_card_s); |
|
57
|
54
|
|
|
|
|
274
|
$self->_perform_and_output_move( |
|
58
|
|
|
|
|
|
|
sprintf( "Move a card from %s to the foundations", $src_s[1] ), |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
elsif ( ($src_card_s) = $move_line =~ /\A(.[HCDS]) to empty pile\z/ ) |
|
62
|
|
|
|
|
|
|
{ |
|
63
|
11
|
|
|
|
|
35
|
my $dest_col_idx = $self->_find_empty_col; |
|
64
|
11
|
50
|
|
|
|
47
|
if ( not defined($dest_col_idx) ) |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
0
|
|
|
|
|
0
|
die "Cannot find empty col."; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
11
|
|
|
|
|
30
|
my @src_s = $self->_find_card_src_string($src_card_s); |
|
69
|
|
|
|
|
|
|
|
|
70
|
11
|
|
|
|
|
57
|
$self->_perform_and_output_move( |
|
71
|
|
|
|
|
|
|
sprintf( "Move %s from %s to stack %d", @src_s, $dest_col_idx ), |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
elsif ( ( $src_card_s, ( my $dest_card_s ) ) = |
|
75
|
|
|
|
|
|
|
$move_line =~ /\A(.[HCDS]) to (.[HCDS])\z/ ) |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
51
|
|
|
|
|
150
|
my $dest_col_idx = $self->_find_col_card($dest_card_s); |
|
78
|
51
|
50
|
|
|
|
220
|
if ( not defined($dest_col_idx) ) |
|
79
|
|
|
|
|
|
|
{ |
|
80
|
0
|
|
|
|
|
0
|
die "Cannot find card <$dest_card_s>."; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
51
|
|
|
|
|
182
|
my @src_s = $self->_find_card_src_string($src_card_s); |
|
84
|
51
|
|
|
|
|
272
|
$self->_perform_and_output_move( |
|
85
|
|
|
|
|
|
|
sprintf( "Move %s from %s to stack %d", @src_s, $dest_col_idx ) ); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
else |
|
88
|
|
|
|
|
|
|
{ |
|
89
|
0
|
|
|
|
|
0
|
die "Unrecognised move_line <$move_line>"; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _process_main |
|
94
|
|
|
|
|
|
|
{ |
|
95
|
1
|
|
|
1
|
|
6
|
my $self = shift; |
|
96
|
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
5
|
$self->_read_initial_state; |
|
98
|
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
9
|
open my $in_fh, '<', $self->_sol_filename; |
|
100
|
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
3149
|
while ( my $l = <$in_fh> ) |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
128
|
|
|
|
|
266
|
chomp($l); |
|
104
|
128
|
|
|
|
|
266
|
$self->_perform_move($l); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
9
|
close($in_fh); |
|
108
|
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
1190
|
$self->_append("This game is solveable.\n"); |
|
110
|
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
15
|
return; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |