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

Comparing Games-Go-SimpleBoard/README (file contents):
Revision 1.1 by root, Sun Jun 22 15:05:59 2008 UTC vs.
Revision 1.2 by root, Tue Jul 29 09:43:48 2008 UTC

11 Marker types for each board position (ORed together): 11 Marker types for each board position (ORed together):
12 12
13 MARK_TRIANGLE # triangle mark 13 MARK_TRIANGLE # triangle mark
14 MARK_SQUARE # square mark 14 MARK_SQUARE # square mark
15 MARK_CIRCLE # circle mark 15 MARK_CIRCLE # circle mark
16 MARK_CROSS # cross mark
16 MARK_SMALL_B # small stone, used for scoring or marking 17 MARK_SMALL_B # small stone, used for scoring or marking
17 MARK_SMALL_W # small stone, used for scoring or marking 18 MARK_SMALL_W # small stone, used for scoring or marking
18 MARK_B # normal black stone 19 MARK_B # normal black stone
19 MARK_W # normal whit stone 20 MARK_W # normal whit stone
20 MARK_GRAYED # in conjunction with MARK_[BW], grays the stone 21 MARK_GRAYED # in conjunction with MARK_[BW], grays the stone
22 MARK_HOSHI # this is a hoshi point (not used much) 23 MARK_HOSHI # this is a hoshi point (not used much)
23 MARK_MOVE # this is a regular move 24 MARK_MOVE # this is a regular move
24 MARK_KO # this is a ko position 25 MARK_KO # this is a ko position
25 MARK_REDRAW # ignored, can be used for your own purposes 26 MARK_REDRAW # ignored, can be used for your own purposes
26 27
27 COLOUR_BLACK # used for $board->{last} 28 COLOUR_WHITE # guarenteed to be 0
28 COLOUR_WHITE # to mark the colour of the last move 29 COLOUR_BLACK # guarenteed to be 1
30
31 MOVE_HANDICAP # used as "x-coordinate" for handicap moves
32 MOVE_PASS # can be used as "x-coordinate" for pass moves
29 33
30 METHODS 34 METHODS
31 my $board = new $size 35 my $board = new $size
32 Creates a new empty board of the given size. 36 Creates a new empty board of the given size.
33 37
38 "$board->{size}" stores the board size.
39
34 "$board->{max}" stores the maximum board coordinate (size-1). 40 "$board->{max}" stores the maximum board coordinate (size-1).
35 41
36 "$board->{captures}[COLOUR]" stores the number of captured stones 42 "$board->{captures}[COLOUR_xxx]" stores the number of captured
37 for the given colour. 43 stones for the given colour.
38
39 "$board->{last}" stores the colour of the last move that was played.
40 44
41 "$board->{board}" stores a two-dimensional array with board 45 "$board->{board}" stores a two-dimensional array with board
42 contents. 46 contents.
43 47
44 $hint = $board->update ([update-structure...]) 48 $hint = $board->update ([update-structures...])
45 Structure is 49 Each update-structure itself is also an array-ref:
46 50
47 [$x, $y, $clr, $set, $label, $hint] # update or move 51 [$x, $y, $clr, $set, $label, $hint] # update or move
52 [MOVE_HANDICAP, $handicap] # black move, setup handicap
53 [MOVE_PASS] # pass
48 [] # pass 54 [] # also pass (deprecated!)
49 55
50 and changes the board or executes a move, by first clearing the bits 56 It changes the board or executes a move, by first clearing the bits
51 specified in $clr, then setting bits specified in $set. 57 specified in $clr, then setting bits specified in $set.
52 58
53 If $set includes "MARK_LABEL", the label text must be given in 59 If $set includes "MARK_LABEL", the label text must be given in
54 $label. 60 $label.
55 61
62 If $set contains "MARK_MOVE" then surrounded stones will be removed
63 from the board and (simple) Kos are detected and marked with square
64 symbols and "MARK_KO", after removing other marking symbols. The
65 markings are also removed with the next next update structure that
66 uses "MARK_MOVE", so this flag is suited well for marking, well,
67 moves. Note that you can make invalid "moves" (such as suicide) and
68 "update" will try to cope with it. You can use "is_valid_move" to
69 avoid making illegal moves.
70
71 For handicap "moves", currently only board sizes 9, 13 and 19 are
72 supported and only handicap values from 2 to 9. The placement
73 follows the IGS rules, if you want other placements, you have to set
74 it up yourself.
75
56 This function modifies the hint member of the specified path to 76 This function modifies the $hint member of the specified structure
57 speed up repeated board generation and updates with the same update 77 to speed up repeated board generation and updates with the same
58 structures. 78 update structures.
59 79
60 If the hint member is a reference the scalar pointed to by the 80 If the hint member is a reference the scalar pointed to by the
61 reference is updated instead. 81 reference is updated instead.
62 82
83 If all this hint member thing is confusing, just ignore it and
84 specify it as "undef" or leave it out of the array entirely. Do make
85 sure that you keep your update structures around as long as previous
86 updates don't change, however, as regenerating a full board position
87 from hinted update structures is *much* faster then recreating it
88 from fresh update structures.
89
63 Example, make two silly moves: 90 Example, make two silly moves:
64 91
65 $board->update ([[0, 18, -1, MARK_B|MARK_MOVE], 92 $board->update ([[0, 18, -1, MARK_B | MARK_MOVE],
66 [0, 17, -1, MARK_W|MARK_MOVE]); 93 [0, 17, -1, MARK_W | MARK_MOVE]]);
67 94
68 $board->is_valid_move ($colour, $x, $y[, $may_suicide]) 95 $board->is_valid_move ($colour, $x, $y[, $may_suicide])
69 Returns true if the move of the given colour on the given 96 Returns true if the move of the given colour on the given
70 coordinates is valid or not. 97 coordinates is valid or not. Kos are taken into account as long as
98 they are marked with "MARK_KO". Suicides are invalid unless
99 $may_suicide is true (e.g. for new zealand rules)
71 100
72 AUTHOR 101 AUTHOR
73 Marc Lehmann <schmorp@schmorp.de> 102 Marc Lehmann <schmorp@schmorp.de>
74 103
75 SEE ALSO 104 SEE ALSO
76 KGS::Protocol, KGS::Game::Tree, Gtk2::GoBoard. 105 Gtk2::GoBoard.
77 106

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines