| 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.2601'; |
|
3
|
2
|
|
|
2
|
|
605251
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
79
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
137
|
|
|
5
|
2
|
|
|
2
|
|
1046
|
use autodie; |
|
|
2
|
|
|
|
|
22386
|
|
|
|
2
|
|
|
|
|
38
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
16276
|
use parent 'Games::Solitaire::Verify::FromOtherSolversBase'; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
135
|
use List::Util qw(first); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
1402
|
|
|
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
|
|
741
|
my ( $self, $move_line ) = @_; |
|
26
|
|
|
|
|
|
|
|
|
27
|
147
|
100
|
|
|
|
700
|
if ( my ($src_card_s) = $move_line =~ /\A(.[HCDS]) to temp\z/ ) |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
|
29
|
31
|
|
|
|
|
65
|
my $src_col_idx = $self->_find_col_card($src_card_s); |
|
30
|
31
|
50
|
|
|
|
161
|
if ( not defined($src_col_idx) ) |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
0
|
|
|
|
|
0
|
die "Cannot find card."; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
80
|
|
|
80
|
|
143
|
my $dest_fc_idx = first { !defined( $self->_st->get_freecell($_) ) } |
|
36
|
31
|
|
|
|
|
116
|
( 0 .. $self->_st->num_freecells - 1 ); |
|
37
|
|
|
|
|
|
|
|
|
38
|
31
|
50
|
|
|
|
85
|
if ( not defined($dest_fc_idx) ) |
|
39
|
|
|
|
|
|
|
{ |
|
40
|
0
|
|
|
|
|
0
|
die "No empty freecell."; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->_perform_and_output_move( |
|
44
|
31
|
|
|
|
|
115
|
sprintf( |
|
45
|
|
|
|
|
|
|
"Move a card from stack %d to freecell %d", |
|
46
|
|
|
|
|
|
|
$src_col_idx, $dest_fc_idx, |
|
47
|
|
|
|
|
|
|
), |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
elsif ( ($src_card_s) = $move_line =~ /\A(.[HCDS]) out\z/ ) |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
54
|
|
|
|
|
106
|
my @src_s = $self->_find_card_src_string($src_card_s); |
|
54
|
54
|
|
|
|
|
119
|
$self->_perform_and_output_move( |
|
55
|
|
|
|
|
|
|
sprintf( "Move a card from %s to the foundations", $src_s[1] ), ); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
elsif ( ($src_card_s) = $move_line =~ /\A(.[HCDS]) to empty pile\z/ ) |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
11
|
|
|
|
|
29
|
my $dest_col_idx = $self->_find_empty_col; |
|
60
|
11
|
50
|
|
|
|
39
|
if ( not defined($dest_col_idx) ) |
|
61
|
|
|
|
|
|
|
{ |
|
62
|
0
|
|
|
|
|
0
|
die "Cannot find empty col."; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
11
|
|
|
|
|
23
|
my @src_s = $self->_find_card_src_string($src_card_s); |
|
65
|
|
|
|
|
|
|
|
|
66
|
11
|
|
|
|
|
42
|
$self->_perform_and_output_move( |
|
67
|
|
|
|
|
|
|
sprintf( "Move %s from %s to stack %d", @src_s, $dest_col_idx ), ); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
elsif ( ( $src_card_s, ( my $dest_card_s ) ) = |
|
70
|
|
|
|
|
|
|
$move_line =~ /\A(.[HCDS]) to (.[HCDS])\z/ ) |
|
71
|
|
|
|
|
|
|
{ |
|
72
|
51
|
|
|
|
|
99
|
my $dest_col_idx = $self->_find_col_card($dest_card_s); |
|
73
|
51
|
50
|
|
|
|
227
|
if ( not defined($dest_col_idx) ) |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
0
|
|
|
|
|
0
|
die "Cannot find card <$dest_card_s>."; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
51
|
|
|
|
|
104
|
my @src_s = $self->_find_card_src_string($src_card_s); |
|
79
|
51
|
|
|
|
|
206
|
$self->_perform_and_output_move( |
|
80
|
|
|
|
|
|
|
sprintf( "Move %s from %s to stack %d", @src_s, $dest_col_idx ) ); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
else |
|
83
|
|
|
|
|
|
|
{ |
|
84
|
0
|
|
|
|
|
0
|
die "Unrecognised move_line <$move_line>"; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _process_main |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
1
|
|
|
1
|
|
6
|
my $self = shift; |
|
91
|
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
4
|
$self->_read_initial_state; |
|
93
|
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
7
|
open my $in_fh, '<', $self->_sol_filename; |
|
95
|
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
1634
|
while ( my $l = <$in_fh> ) |
|
97
|
|
|
|
|
|
|
{ |
|
98
|
128
|
|
|
|
|
198
|
chomp($l); |
|
99
|
128
|
|
|
|
|
246
|
$self->_perform_move($l); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
8
|
close($in_fh); |
|
103
|
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
832
|
$self->_append("This game is solveable.\n"); |
|
105
|
|
|
|
|
|
|
|
|
106
|
1
|
|
|
|
|
5
|
return; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__END__ |