line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::ABC_Path::Solver::Move; |
2
|
|
|
|
|
|
|
$Games::ABC_Path::Solver::Move::VERSION = '0.6.1'; |
3
|
2
|
|
|
2
|
|
1026
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
53
|
|
4
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
31
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
6
|
use parent 'Games::ABC_Path::Solver::Base'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
7
|
|
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
|
84
|
|
|
84
|
|
97
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
84
|
50
|
|
|
|
135
|
if (@_) { |
27
|
84
|
|
|
|
|
125
|
$self->{_depth} = shift; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
84
|
|
|
|
|
105
|
return $self->{_depth}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get_depth |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
return $self->_depth(); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _init |
42
|
|
|
|
|
|
|
{ |
43
|
84
|
|
|
84
|
|
111
|
my ($self, $args) = @_; |
44
|
|
|
|
|
|
|
|
45
|
84
|
|
|
|
|
165
|
$self->{_text} = $args->{text}; |
46
|
84
|
|
50
|
|
|
294
|
$self->_depth($args->{depth} || 0); |
47
|
84
|
|
50
|
|
|
154
|
$self->{_vars} = ($args->{vars} || {}); |
48
|
|
|
|
|
|
|
|
49
|
84
|
|
|
|
|
107
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub bump |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return ref($self)->new( |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
text => $self->get_text(), |
60
|
|
|
|
|
|
|
depth => ($self->get_depth+1), |
61
|
0
|
|
|
|
|
|
vars => { %{$self->{_vars}}, }, |
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub get_var |
68
|
|
|
|
|
|
|
{ |
69
|
0
|
|
|
0
|
1
|
|
my ($self, $name) = @_; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return $self->{_vars}->{$name}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# TODO : duplicate code with ::Board |
75
|
|
|
|
|
|
|
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)); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _expand_format |
78
|
|
|
|
|
|
|
{ |
79
|
0
|
|
|
0
|
|
|
my ($self, $name, $type) = @_; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $value = $self->get_var($name); |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
if ($type eq "letter") |
|
|
0
|
|
|
|
|
|
84
|
|
|
|
|
|
|
{ |
85
|
0
|
|
|
|
|
|
return $letters[$value]; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
elsif ($type eq "coords") |
88
|
|
|
|
|
|
|
{ |
89
|
0
|
|
|
|
|
|
return sprintf("(%d,%d)", $value->x()+1, $value->y()+1); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
else |
92
|
|
|
|
|
|
|
{ |
93
|
0
|
|
|
|
|
|
die "Unknown format type '$type'!"; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; # End of Games::ABC_Path::Solver::Move |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |