line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Game::TextPacMonster::R; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
542
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
121
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
24
|
|
|
4
|
|
|
|
|
126
|
|
5
|
4
|
|
|
4
|
|
20
|
use utf8; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
21
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
496
|
use Game::TextPacMonster::Point; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
104
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
18
|
use base 'Game::TextPacMonster::Creature'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1638
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
29
|
|
|
29
|
0
|
64
|
my $class = shift @_; |
13
|
29
|
|
|
|
|
109
|
my $self = $class->SUPER::new(@_); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub move_free { |
18
|
17
|
|
|
17
|
0
|
27
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
17
|
|
|
|
|
47
|
my $pre_p = $self->pre_point; |
21
|
17
|
|
|
|
|
43
|
my $now_p = $self->point; |
22
|
|
|
|
|
|
|
|
23
|
17
|
|
|
|
|
60
|
my $relative_point_x = $now_p->x_coord - $pre_p->x_coord; |
24
|
17
|
|
|
|
|
42
|
my $relative_point_y = $now_p->y_coord - $pre_p->y_coord; |
25
|
|
|
|
|
|
|
|
26
|
17
|
|
|
|
|
22
|
my $orientation = q{}; # an empty string; |
27
|
|
|
|
|
|
|
|
28
|
17
|
100
|
|
|
|
29
|
if ($relative_point_y == 0) { |
29
|
9
|
100
|
|
|
|
20
|
$orientation = $relative_point_x > 0 ? 'left_to_right' : 'right_to_left'; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
8
|
100
|
|
|
|
21
|
$orientation = $relative_point_y > 0 ? 'up_to_down' : 'down_to_up'; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
17
|
|
|
|
|
34
|
my %next_rules = $self->_make_rules; |
36
|
17
|
|
|
|
|
26
|
my @next_rule = @{$next_rules{$orientation}}; |
|
17
|
|
|
|
|
39
|
|
37
|
|
|
|
|
|
|
|
38
|
17
|
|
|
|
|
29
|
for my $rule (@next_rule) { |
39
|
38
|
100
|
|
|
|
121
|
return 1 if $self->$rule; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
28
|
return 0; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _make_rules { |
46
|
17
|
|
|
17
|
|
25
|
my %rules = (); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# R will face to move right, front, left |
49
|
17
|
|
|
|
|
41
|
$rules{left_to_right} = [ 'move_down', 'move_right', 'move_up' ]; |
50
|
17
|
|
|
|
|
41
|
$rules{right_to_left} = [ 'move_up', 'move_left', 'move_down' ]; |
51
|
17
|
|
|
|
|
35
|
$rules{up_to_down} = [ 'move_left', 'move_down', 'move_right' ]; |
52
|
17
|
|
|
|
|
31
|
$rules{down_to_up} = [ 'move_right', 'move_up', 'move_left' ]; |
53
|
|
|
|
|
|
|
|
54
|
17
|
|
|
|
|
86
|
return %rules; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |