Chess

 view release on metacpan or  search on metacpan

lib/Chess/Board.pm  view on Meta::CPAN

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
Takes a single scalar parameter containing the square to calculate distance
from. Returns the horizontal distance in squares between the two points.
 
=item vert_distance()
 
Takes a single scalar parameter containing the square to calculate distance
from. Returns the vertical distance in squares between the two points.
 
=item squares_in_line()
 
Takes two scalar parameters containing two distinct endpoints in a line.
Returns a list of scalars in lower-case with an entry for each square in that
line, or C<undef> if the two endpoints do not define a line. In the case where
both squares are the same, will return a list containing that square.
 
=back
 
=head2 Object methods
 
=over 4
 
=item clone()
 
Takes no arguments. Returns a blessed Chess::Board object reference which is
identical to the caller object. However, it is a I<deep copy> which allows
the clone()'d object to be manipulated separately of the caller object.
 
=item line_is_open()
 
Takes two scalar arguments, valid squares defining the endpoints of a line
on the Chess::Board. Returns true if there are no pieces on either of the
endpoints, or on any of the intervening squares. Returns false if the line
is blocked by one or more pieces, and C<undef> if the two squares do not
define endpoints of a line. In the case where both squares are equal, will
return true if the square is empty and false otherwise.
 
=item get_piece_at()
 
Takes a single scalar argument containing the square to retrieve the piece
from. Returns a scalar representing the piece on that square, or C<undef> if
there is none. Returns C<undef> and prints a warning to STDERR (See
L</"DIAGNOSTICS">) if the provided square is not valid.
 
=item set_piece_at()



( run in 0.376 second using v1.01-cache-2.11-cpan-bb97c1e446a )