| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Game::TextPacMonster::J; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
601
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
94
|
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
87
|
|
|
5
|
4
|
|
|
4
|
|
18
|
use utf8; |
|
|
4
|
|
|
|
|
14
|
|
|
|
4
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
575
|
use Game::TextPacMonster::Point; |
|
|
4
|
|
|
|
|
18
|
|
|
|
4
|
|
|
|
|
113
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
25
|
use base 'Game::TextPacMonster::Creature'; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
2425
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
13
|
|
|
13
|
0
|
49
|
my $class = shift @_; |
|
13
|
13
|
|
|
|
|
68
|
my $self = $class->SUPER::new(@_); |
|
14
|
13
|
|
|
|
|
47
|
$self->{_enter_crossing_count} = 0; |
|
15
|
13
|
|
|
|
|
40
|
return $self; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub move_free { |
|
20
|
4
|
|
|
4
|
0
|
508
|
my $self = shift; |
|
21
|
|
|
|
|
|
|
|
|
22
|
4
|
|
|
|
|
6
|
my $crossing_count = $self->{_enter_crossing_count}; |
|
23
|
|
|
|
|
|
|
|
|
24
|
4
|
100
|
|
|
|
14
|
my $is_r_behavior = ( $crossing_count % 2 == 1 ) ? 1 : 0; |
|
25
|
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
13
|
my @next_rules = $self->_get_rule($is_r_behavior); |
|
27
|
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
12
|
for my $rule (@next_rules) { |
|
29
|
6
|
100
|
|
|
|
20
|
if ( $self->$rule ) { |
|
30
|
3
|
|
|
|
|
5
|
$self->{_enter_crossing_count} += 1; |
|
31
|
3
|
|
|
|
|
23
|
return 1; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
6
|
return 0; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _get_delta_point { |
|
40
|
16
|
|
|
16
|
|
26
|
my $self = shift; |
|
41
|
|
|
|
|
|
|
|
|
42
|
16
|
|
|
|
|
51
|
my $pre_p = $self->pre_point; |
|
43
|
16
|
|
|
|
|
45
|
my $now_p = $self->point; |
|
44
|
|
|
|
|
|
|
|
|
45
|
16
|
|
|
|
|
40
|
my $delta_x = $now_p->x_coord - $pre_p->x_coord; |
|
46
|
16
|
|
|
|
|
48
|
my $delta_y = $now_p->y_coord - $pre_p->y_coord; |
|
47
|
|
|
|
|
|
|
|
|
48
|
16
|
|
|
|
|
47
|
return Game::TextPacMonster::Point->new($delta_x, $delta_y); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _get_rules { |
|
53
|
14
|
|
|
14
|
|
492
|
my ( $self, $is_r_behavior ) = @_; |
|
54
|
|
|
|
|
|
|
|
|
55
|
14
|
|
|
|
|
25
|
my %r_rules = (); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# R will face to move right, front, left |
|
58
|
14
|
|
|
|
|
36
|
$r_rules{left_to_right} = [ 'move_down', 'move_right', 'move_up' ]; |
|
59
|
14
|
|
|
|
|
26
|
$r_rules{right_to_left} = [ 'move_up', 'move_left', 'move_down' ]; |
|
60
|
14
|
|
|
|
|
29
|
$r_rules{up_to_down} = [ 'move_left', 'move_down', 'move_right' ]; |
|
61
|
14
|
|
|
|
|
52
|
$r_rules{down_to_up} = [ 'move_right', 'move_up', 'move_left' ]; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
14
|
|
|
|
|
18
|
my %l_rules = (); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# L will face to move left, front, right |
|
67
|
14
|
|
|
|
|
26
|
$l_rules{left_to_right} = [ 'move_up', 'move_right', 'move_down' ]; |
|
68
|
14
|
|
|
|
|
22
|
$l_rules{right_to_left} = [ 'move_down', 'move_left', 'move_up' ]; |
|
69
|
14
|
|
|
|
|
27
|
$l_rules{up_to_down} = [ 'move_right', 'move_down', 'move_left' ]; |
|
70
|
14
|
|
|
|
|
26
|
$l_rules{down_to_up} = [ 'move_left', 'move_up', 'move_right' ]; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
14
|
100
|
|
|
|
57
|
my %rules = ( $is_r_behavior ) ? %r_rules : %l_rules; |
|
74
|
14
|
|
|
|
|
95
|
return %rules; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _get_rule { |
|
80
|
12
|
|
|
12
|
|
1997
|
my ($self, $is_r_behavior) = @_; |
|
81
|
|
|
|
|
|
|
|
|
82
|
12
|
|
|
|
|
27
|
my $delta_p = $self->_get_delta_point; |
|
83
|
|
|
|
|
|
|
|
|
84
|
12
|
|
|
|
|
29
|
my %rules = $self->_get_rules($is_r_behavior); |
|
85
|
|
|
|
|
|
|
|
|
86
|
12
|
|
|
|
|
17
|
my $orientation = q{}; # empty string |
|
87
|
|
|
|
|
|
|
|
|
88
|
12
|
100
|
|
|
|
33
|
if ( $delta_p->y_coord == 0 ) { |
|
89
|
7
|
100
|
|
|
|
25
|
$orientation = $delta_p->x_coord > 0 ? 'left_to_right' : 'right_to_left'; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
else { |
|
92
|
5
|
100
|
|
|
|
13
|
$orientation = $delta_p->y_coord > 0 ? 'up_to_down' : 'down_to_up'; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
12
|
|
|
|
|
17
|
return @{ $rules{$orientation} }; |
|
|
12
|
|
|
|
|
72
|
|
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |