line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
705
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Games::Goban::Board 1.103; |
5
|
1
|
|
|
1
|
|
415
|
use parent qw(Games::Board::Grid); |
|
1
|
|
|
|
|
343
|
|
|
1
|
|
|
|
|
6
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: a go board built from Games::Board |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
9
|
|
|
|
|
|
|
#pod |
10
|
|
|
|
|
|
|
#pod use Games::Goban::Board; |
11
|
|
|
|
|
|
|
#pod |
12
|
|
|
|
|
|
|
#pod my $board = Games::Goban::Board->new(size => 19); |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod # etc |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod This class exists is primarily for use (for now) by Games::Goban, which |
17
|
|
|
|
|
|
|
#pod currently implements its own board, badly. |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod This module provides a class for representing a go board and pieces. |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod =cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#pod =head1 METHODS |
26
|
|
|
|
|
|
|
#pod |
27
|
|
|
|
|
|
|
#pod The methods of this class are not substantially changed from those of |
28
|
|
|
|
|
|
|
#pod Games::Board. Space id's are more go-like. New pieces are blessed into the |
29
|
|
|
|
|
|
|
#pod class Games::Goban::Piece, which provides a few historical methods for |
30
|
|
|
|
|
|
|
#pod Games::Goban's consumption. |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod =cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $origin = ord('a'); |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
2
|
1
|
900
|
sub piececlass { 'Games::Goban::Piece' } |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new { |
39
|
2
|
|
|
2
|
1
|
1064
|
my ($self, %opts) = @_; |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
12
|
my $board = $self->SUPER::new(%opts); |
42
|
2
|
100
|
|
|
|
41
|
$board->{skip_i} = defined $opts{skip_i} ? $opts{skip_i} : 0; |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
6
|
$board; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub index2id { |
48
|
728
|
|
|
728
|
1
|
15729
|
my ($self, $loc) = @_; |
49
|
|
|
|
|
|
|
|
50
|
728
|
|
|
|
|
1391
|
my $id = chr($origin + $loc->[0]) . chr($origin + $loc->[1]); |
51
|
|
|
|
|
|
|
|
52
|
728
|
100
|
|
|
|
1280
|
$id =~ tr/[i-s]/[j-t]/ if $self->{skip_i}; |
53
|
|
|
|
|
|
|
|
54
|
728
|
|
|
|
|
1535
|
$id; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub id2index { |
58
|
7
|
|
|
7
|
1
|
2275
|
my ($self, $id) = @_; |
59
|
|
|
|
|
|
|
|
60
|
7
|
100
|
|
|
|
22
|
$id =~ tr/[j-t]/[i-s]/ if $self->{skip_i}; |
61
|
|
|
|
|
|
|
|
62
|
7
|
|
|
|
|
22
|
my @loc = split //, $id; |
63
|
|
|
|
|
|
|
|
64
|
7
|
|
|
|
|
22
|
$_ = ord($_) - $origin for @loc; |
65
|
7
|
|
|
|
|
42
|
\@loc; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
package Games::Goban::Piece 1.103; |
69
|
1
|
|
|
1
|
|
4269
|
use base qw(Games::Board::Piece); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
305
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $next_id = 0; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub new { |
74
|
2
|
|
|
2
|
|
7
|
my ($class, %args) = @_; |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
33
|
|
|
14
|
$args{id} ||= ++$next_id; |
77
|
|
|
|
|
|
|
|
78
|
2
|
|
|
|
|
10
|
my $self = $class->SUPER::new(%args); |
79
|
|
|
|
|
|
|
|
80
|
2
|
|
|
|
|
36
|
$self->{color} = $args{color}; |
81
|
2
|
|
|
|
|
13
|
$self->{notes} = $args{notes}; |
82
|
2
|
|
|
|
|
9
|
$self->{move} = $args{move}; |
83
|
|
|
|
|
|
|
|
84
|
2
|
|
|
|
|
5
|
bless $self => $class; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
0
|
|
0
|
sub notes { (shift)->{notes} } |
88
|
4
|
|
|
4
|
|
817
|
sub position { (shift)->current_space_id } |
89
|
|
|
|
|
|
|
|
90
|
2
|
|
|
2
|
|
9
|
sub moved_on { (shift)->{move} } |
91
|
|
|
|
|
|
|
|
92
|
2
|
|
|
2
|
|
681
|
sub color { my $self = shift; $self->{color} } |
|
2
|
|
|
|
|
8
|
|
93
|
2
|
|
|
2
|
|
5
|
sub colour { my $self = shift; $self->{color} } |
|
2
|
|
|
|
|
8
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |