ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Games-Go-SimpleBoard/README
Revision: 1.2
Committed: Tue Jul 29 09:43:48 2008 UTC (15 years, 9 months ago) by root
Branch: MAIN
CVS Tags: rel-1_0
Changes since 1.1: +46 -17 lines
Log Message:
1.0

File Contents

# User Rev Content
1 root 1.1 NAME
2     Games::Go::SimpleBoard - represent a simple go board
3    
4     SYNOPSIS
5     use Games::Go::SimpleBoard;
6    
7     DESCRIPTION
8     Please supply a description )
9    
10     EXPORTED CONSTANTS
11     Marker types for each board position (ORed together):
12    
13     MARK_TRIANGLE # triangle mark
14     MARK_SQUARE # square mark
15     MARK_CIRCLE # circle mark
16 root 1.2 MARK_CROSS # cross mark
17 root 1.1 MARK_SMALL_B # small stone, used for scoring or marking
18     MARK_SMALL_W # small stone, used for scoring or marking
19     MARK_B # normal black stone
20     MARK_W # normal whit stone
21     MARK_GRAYED # in conjunction with MARK_[BW], grays the stone
22     MARK_LABEL # a text label
23     MARK_HOSHI # this is a hoshi point (not used much)
24     MARK_MOVE # this is a regular move
25     MARK_KO # this is a ko position
26     MARK_REDRAW # ignored, can be used for your own purposes
27    
28 root 1.2 COLOUR_WHITE # guarenteed to be 0
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
33 root 1.1
34     METHODS
35     my $board = new $size
36     Creates a new empty board of the given size.
37    
38 root 1.2 "$board->{size}" stores the board size.
39    
40 root 1.1 "$board->{max}" stores the maximum board coordinate (size-1).
41    
42 root 1.2 "$board->{captures}[COLOUR_xxx]" stores the number of captured
43     stones for the given colour.
44 root 1.1
45     "$board->{board}" stores a two-dimensional array with board
46     contents.
47    
48 root 1.2 $hint = $board->update ([update-structures...])
49     Each update-structure itself is also an array-ref:
50 root 1.1
51     [$x, $y, $clr, $set, $label, $hint] # update or move
52 root 1.2 [MOVE_HANDICAP, $handicap] # black move, setup handicap
53     [MOVE_PASS] # pass
54     [] # also pass (deprecated!)
55 root 1.1
56 root 1.2 It changes the board or executes a move, by first clearing the bits
57 root 1.1 specified in $clr, then setting bits specified in $set.
58    
59     If $set includes "MARK_LABEL", the label text must be given in
60     $label.
61    
62 root 1.2 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    
76     This function modifies the $hint member of the specified structure
77     to speed up repeated board generation and updates with the same
78     update structures.
79 root 1.1
80     If the hint member is a reference the scalar pointed to by the
81     reference is updated instead.
82    
83 root 1.2 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    
90 root 1.1 Example, make two silly moves:
91    
92 root 1.2 $board->update ([[0, 18, -1, MARK_B | MARK_MOVE],
93     [0, 17, -1, MARK_W | MARK_MOVE]]);
94 root 1.1
95     $board->is_valid_move ($colour, $x, $y[, $may_suicide])
96     Returns true if the move of the given colour on the given
97 root 1.2 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)
100 root 1.1
101     AUTHOR
102     Marc Lehmann <schmorp@schmorp.de>
103    
104     SEE ALSO
105 root 1.2 Gtk2::GoBoard.
106 root 1.1