line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::ABC_Path::Solver::Move; |
2
|
|
|
|
|
|
|
$Games::ABC_Path::Solver::Move::VERSION = '0.6.2'; |
3
|
2
|
|
|
2
|
|
1382
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
74
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
43
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
8
|
use parent 'Games::ABC_Path::Solver::Base'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
8
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub get_text |
11
|
|
|
|
|
|
|
{ |
12
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
0
|
my $text = $self->_format; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
0
|
$text =~ s/%\((\w+)\)\{(\w+)\}/ |
17
|
0
|
|
|
|
|
0
|
$self->_expand_format($1,$2) |
18
|
|
|
|
|
|
|
/ge; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
return $text; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _depth |
24
|
|
|
|
|
|
|
{ |
25
|
84
|
|
|
84
|
|
141
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
84
|
50
|
|
|
|
187
|
if (@_) |
28
|
|
|
|
|
|
|
{ |
29
|
84
|
|
|
|
|
142
|
$self->{_depth} = shift; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
84
|
|
|
|
|
134
|
return $self->{_depth}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_depth |
37
|
|
|
|
|
|
|
{ |
38
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
return $self->_depth(); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _init |
44
|
|
|
|
|
|
|
{ |
45
|
84
|
|
|
84
|
|
156
|
my ( $self, $args ) = @_; |
46
|
|
|
|
|
|
|
|
47
|
84
|
|
|
|
|
219
|
$self->{_text} = $args->{text}; |
48
|
84
|
|
50
|
|
|
398
|
$self->_depth( $args->{depth} || 0 ); |
49
|
84
|
|
50
|
|
|
225
|
$self->{_vars} = ( $args->{vars} || {} ); |
50
|
|
|
|
|
|
|
|
51
|
84
|
|
|
|
|
163
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub bump |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return ref($self)->new( |
60
|
|
|
|
|
|
|
{ |
61
|
|
|
|
|
|
|
text => $self->get_text(), |
62
|
|
|
|
|
|
|
depth => ( $self->get_depth + 1 ), |
63
|
0
|
|
|
|
|
|
vars => { %{ $self->{_vars} }, }, |
|
0
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub get_var |
70
|
|
|
|
|
|
|
{ |
71
|
0
|
|
|
0
|
1
|
|
my ( $self, $name ) = @_; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return $self->{_vars}->{$name}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# TODO : duplicate code with ::Board |
77
|
|
|
|
|
|
|
my @letters = (qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y)); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _expand_format |
80
|
|
|
|
|
|
|
{ |
81
|
0
|
|
|
0
|
|
|
my ( $self, $name, $type ) = @_; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $value = $self->get_var($name); |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
if ( $type eq "letter" ) |
|
|
0
|
|
|
|
|
|
86
|
|
|
|
|
|
|
{ |
87
|
0
|
|
|
|
|
|
return $letters[$value]; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
elsif ( $type eq "coords" ) |
90
|
|
|
|
|
|
|
{ |
91
|
0
|
|
|
|
|
|
return sprintf( "(%d,%d)", $value->x() + 1, $value->y() + 1 ); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
else |
94
|
|
|
|
|
|
|
{ |
95
|
0
|
|
|
|
|
|
die "Unknown format type '$type'!"; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; # End of Games::ABC_Path::Solver::Move |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |