| 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.2401'; |
|
3
|
1
|
|
|
1
|
|
127976
|
use strict; |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
30
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
25
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use autodie; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5721
|
use parent 'Games::Solitaire::Verify::FromOtherSolversBase'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
6
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
57
|
use List::MoreUtils qw(firstidx); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
8
|
|
|
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
|
|
789
|
my ( $self, $move_line ) = @_; |
|
26
|
|
|
|
|
|
|
|
|
27
|
147
|
100
|
|
|
|
879
|
if ( my ($src_card_s) = $move_line =~ /\A(.[HCDS]) to temp\z/ ) |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
|
29
|
31
|
|
|
|
|
95
|
my $src_col_idx = $self->_find_col_card($src_card_s); |
|
30
|
31
|
50
|
|
|
|
143
|
if ( $src_col_idx < 0 ) |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
0
|
|
|
|
|
0
|
die "Cannot find card."; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $dest_fc_idx = firstidx |
|
36
|
|
|
|
|
|
|
{ |
|
37
|
80
|
|
|
80
|
|
210
|
!defined( $self->_st->get_freecell($_) ) |
|
38
|
|
|
|
|
|
|
} |
|
39
|
31
|
|
|
|
|
149
|
( 0 .. $self->_st->num_freecells - 1 ); |
|
40
|
|
|
|
|
|
|
|
|
41
|
31
|
50
|
|
|
|
118
|
if ( $dest_fc_idx < 0 ) |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
0
|
|
|
|
|
0
|
die "No empty freecell."; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$self->_perform_and_output_move( |
|
47
|
31
|
|
|
|
|
176
|
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
|
|
|
|
|
147
|
my @src_s = $self->_find_card_src_string($src_card_s); |
|
57
|
54
|
|
|
|
|
282
|
$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
|
|
|
|
|
39
|
my $dest_col_idx = $self->_find_empty_col; |
|
64
|
11
|
50
|
|
|
|
46
|
if ( $dest_col_idx < 0 ) |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
0
|
|
|
|
|
0
|
die "Cannot find empty col."; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
11
|
|
|
|
|
28
|
my @src_s = $self->_find_card_src_string($src_card_s); |
|
69
|
|
|
|
|
|
|
|
|
70
|
11
|
|
|
|
|
60
|
$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
|
|
|
|
|
141
|
my $dest_col_idx = $self->_find_col_card($dest_card_s); |
|
78
|
51
|
50
|
|
|
|
214
|
if ( $dest_col_idx < 0 ) |
|
79
|
|
|
|
|
|
|
{ |
|
80
|
0
|
|
|
|
|
0
|
die "Cannot find card <$dest_card_s>."; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
51
|
|
|
|
|
144
|
my @src_s = $self->_find_card_src_string($src_card_s); |
|
84
|
51
|
|
|
|
|
283
|
$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
|
|
|
|
|
4
|
$self->_read_initial_state; |
|
98
|
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
9
|
open my $in_fh, '<', $self->_sol_filename; |
|
100
|
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
2815
|
while ( my $l = <$in_fh> ) |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
128
|
|
|
|
|
264
|
chomp($l); |
|
104
|
128
|
|
|
|
|
288
|
$self->_perform_move($l); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
11
|
close($in_fh); |
|
108
|
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
1235
|
$self->_append("This game is solveable.\n"); |
|
110
|
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
7
|
return; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |