ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Games-Go-SimpleBoard/SimpleBoard.pm
(Generate patch)

Comparing Games-Go-SimpleBoard/SimpleBoard.pm (file contents):
Revision 1.3 by root, Mon Jun 23 20:41:16 2008 UTC vs.
Revision 1.4 by root, Tue Jun 24 04:39:07 2008 UTC

149=item $hint = $board->update ([update-structures...]) 149=item $hint = $board->update ([update-structures...])
150 150
151Each update-structure itself is also an array-ref: 151Each update-structure itself is also an array-ref:
152 152
153 [$x, $y, $clr, $set, $label, $hint] # update or move 153 [$x, $y, $clr, $set, $label, $hint] # update or move
154 [MOVE_HANDICAP, $handicap] # black move, set handicap 154 [MOVE_HANDICAP, $handicap] # black move, setup handicap
155 [MOVE_PASS] # pass 155 [MOVE_PASS] # pass
156 [] # also pass 156 [] # also pass (deprecated!)
157 157
158It changes the board or executes a move, by first clearing the bits 158It changes the board or executes a move, by first clearing the bits
159specified in C<$clr>, then setting bits specified in C<$set>. 159specified in C<$clr>, then setting bits specified in C<$set>.
160 160
161If C<$set> includes C<MARK_LABEL>, the label text must be given in 161If C<$set> includes C<MARK_LABEL>, the label text must be given in
162C<$label>. 162C<$label>.
163 163
164If C<$set> contains C<MARK_MOVE>, then a circle symbol will be placed on 164If C<$set> contains C<MARK_MOVE>, then a circle symbol will be placed
165this coordinate only if this is the last move done (which is useful for a 165at this coordinate. Also, surrounded stones will be removed from the
166move marker). 166board and (simple) Kos are detected and marked with square symbols and
167C<MARK_KO>. The circle and square markings are removed with the next
168update that uses C<MARK_MOVE>, so this flag is suited well for marking,
169well, moves. Note that you can make invalid "moves" (such as suicide) and
170C<update> will try to cope with it. You can use C<is_valid_move> to avoid
171making illegal moves.
167 172
168For handicap "moves", currently only board sizes 9, 13 and 19 are 173For handicap "moves", currently only board sizes 9, 13 and 19 are
169supported and only handicap values from 2 to 9. The placement follows the 174supported and only handicap values from 2 to 9. The placement follows the
170IGS rules, if you want other placements, you have to set it up yourself. 175IGS rules, if you want other placements, you have to set it up yourself.
171 176
172This function modifies the hint member of the specified path to speed up 177This function modifies the C<$hint> member of the specified structure
173repeated board generation and updates with the same update structures. 178to speed up repeated board generation and updates with the same update
179structures.
174 180
175If the hint member is a reference the scalar pointed to by the reference 181If the hint member is a reference the scalar pointed to by the reference
176is updated instead. 182is updated instead.
177 183
178If all this hint member thing is unclear, just ignore it and specify it 184If all this hint member thing is confusing, just ignore it and specify
179as C<undef> or leave it out of the array entirely. Do make sure that you 185it as C<undef> or leave it out of the array entirely. Do make sure that
180keep your update structures around, however, as regenerating a full board 186you keep your update structures around as long as previous updates don't
181position from hinted update structures is I<much> faster then recreating 187change, however, as regenerating a full board position from hinted
182it from fresh update structures. 188update structures is I<much> faster then recreating it from fresh update
189structures.
183 190
184Example, make two silly moves: 191Example, make two silly moves:
185 192
186 $board->update ([[0, 18, -1, MARK_B|MARK_MOVE], 193 $board->update ([[0, 18, -1, MARK_B | MARK_MOVE],
187 [0, 17, -1, MARK_W|MARK_MOVE]]); 194 [0, 17, -1, MARK_W | MARK_MOVE]]);
188 195
189=cut 196=cut
190 197
191our %HANDICAP_COORD = ( 198our %HANDICAP_COORD = (
192 9 => [2, 4, 6], 199 9 => [2, 4, 6],
293} 300}
294 301
295=item $board->is_valid_move ($colour, $x, $y[, $may_suicide]) 302=item $board->is_valid_move ($colour, $x, $y[, $may_suicide])
296 303
297Returns true if the move of the given colour on the given coordinates is 304Returns true if the move of the given colour on the given coordinates is
298valid or not. 305valid or not. Kos are taken into account as long as they are marked with
306C<MARK_KO>. Suicides are invalid unless C<$may_suicide> is true (e.g. for
307new zealand rules)
299 308
300=cut 309=cut
301 310
302sub is_valid_move { 311sub is_valid_move {
303 my ($self, $colour, $x, $y, $may_suicide) = @_; 312 my ($self, $colour, $x, $y, $may_suicide) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines