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