14 |
|
|
15 |
|
|
16 |
@itemize @bullet |
@itemize @bullet |
17 |
@item @code{void change_matcher_status(int dr, int status)} |
@item @code{void change_dragon_status(int dr, int status)} |
18 |
@findex change_matcher_status |
@findex change_dragon_status |
19 |
@quotation |
@quotation |
20 |
Change the status of all the stones in the dragon at @code{dr}. |
Change the status of all the stones in the dragon at @code{dr}. |
21 |
@end quotation |
@end quotation |
26 |
@end quotation |
@end quotation |
27 |
@item @code{int cut_possible(int pos, int color)} |
@item @code{int cut_possible(int pos, int color)} |
28 |
@quotation |
@quotation |
29 |
Returns true if color can cut at @code{pos}, or if connection through @code{pos} |
Returns true if @code{color} can cut at @code{pos}, or if connection through |
30 |
is inhibited. This information is collected by @code{find_cuts()}, using the B |
@code{pos} is inhibited. This information is collected by @code{find_cuts()}, |
31 |
patterns in the connections database. |
using the B patterns in the connections database. |
32 |
@end quotation |
@end quotation |
33 |
@item @code{int does_attack(int move, int str)} |
@item @code{int does_attack(int move, int str)} |
34 |
@findex does_attack |
@findex does_attack |
46 |
@item @code{int somewhere(int color, int last_move, ...)} |
@item @code{int somewhere(int color, int last_move, ...)} |
47 |
@findex somewhere |
@findex somewhere |
48 |
@quotation |
@quotation |
|
Returns true if one of the vertices listed satisfies |
|
|
@code{board[pos]==color}. Here last_move is the number of moves minus one. |
|
49 |
Example: @code{somewhere(WHITE, 2, apos, bpos, cpos)}. |
Example: @code{somewhere(WHITE, 2, apos, bpos, cpos)}. |
50 |
|
Returns true if one of the vertices listed satisfies |
51 |
|
@code{board[pos]==color}. Here num_moves is the number of moves minus one. |
52 |
|
If the check is true the dragon is not allowed to be dead. This |
53 |
|
check is only valid if @code{stackp==0}. |
54 |
|
@end quotation |
55 |
|
@item @code{int visible_along_edge(int color, int apos, int bpos)} |
56 |
|
@quotation |
57 |
|
Search along the edge for the first visible stone. Start at apos |
58 |
|
and move in the direction of bpos. Return 1 if the first visible |
59 |
|
stone is of the given color. It is required that apos and bpos are |
60 |
|
at the same distance from the edge. |
61 |
@end quotation |
@end quotation |
62 |
@item @code{int play_break_through_n(int color, int num_moves, ...)} |
@item @code{int play_break_through_n(int color, int num_moves, ...)} |
63 |
@findex play_break_through_n |
@findex play_break_through_n |
64 |
@quotation |
@quotation |
65 |
Plays a sequence of moves, alternating between the players and starting with |
The function @code{play_break_through_n()} plays a sequence of moves, |
66 |
color. After having played through the sequence, the three last coordinate |
alternating between the players and starting with color. After |
67 |
pairs gives a position to be analyzed by @code{break_through()}, to see whether |
having played through the sequence, the three last coordinate pairs |
68 |
either color has managed to enclose some stones and/or connected his own |
gives a position to be analyzed by @code{break_through()}, to see whether |
69 |
stones. If any of the three last positions is empty, it's assumed that the |
either color has managed to enclose some stones and/or connected |
70 |
enclosure has failed, as well as the attempt to connect. If one or more of the |
his own stones. If any of the three last positions is empty, it's |
71 |
moves to play turns out to be illegal for some reason, the rest of the |
assumed that the enclosure has failed, as well as the attempt to |
72 |
sequence is played anyway, and @code{break_through()} is called as if nothing |
connect. If one or more of the moves to play turns out to be illegal for |
73 |
special happened. Like @code{break_through()}, this function returns 1 if the |
some reason, the rest of the sequence is played anyway, and |
74 |
attempt to break through was succesful and 2 if it only managed to cut |
@code{break_through()} is called as if nothing special happened. |
75 |
|
Like @code{break_through()}, this function returns 1 if the attempt to |
76 |
|
break through was succesful and 2 if it only managed to cut |
77 |
through. |
through. |
78 |
@end quotation |
@end quotation |
79 |
@item @code{int play_attack_defend_n(int color, int do_attack, int num_moves, ...)} |
@item @code{int play_attack_defend_n(int color, int do_attack, int num_moves, ...)} |
|
@findex play_attack_defend_n |
|
|
@quotation |
|
|
Plays a sequence of moves, alternating between the players and starting with |
|
|
color. After having played through the sequence, the last coordinate pair |
|
|
gives a target to attack or defend, depending on the value of do_attack. If |
|
|
there is no stone present to attack or defend, it is assumed that it has |
|
|
already been captured. If one or more of the moves to play turns out to be |
|
|
illegal for some reason, the rest of the sequence is played anyway, and |
|
|
attack/defense is tested as if nothing special happened. A typical use for |
|
|
these functions is to set up a ladder in an autohelper and see whether it |
|
|
works or not. |
|
|
@end quotation |
|
80 |
@item @code{int play_attack_defend2_n(int color, int do_attack, int num_moves, ...)} |
@item @code{int play_attack_defend2_n(int color, int do_attack, int num_moves, ...)} |
81 |
@findex play_attack_defend2_n |
@findex play_attack_defend2_n |
82 |
|
@findex play_attack_defend_n |
83 |
@quotation |
@quotation |
84 |
Plays a sequence of moves, alternating |
The function @code{play_attack_defend_n()} plays a sequence of moves, |
85 |
between the players and starting with color. After having played through the |
alternating between the players and starting with @code{color}. After |
86 |
sequence, the two last coordinate pairs give two targets to simultaneously |
having played through the sequence, the last coordinate pair gives |
87 |
attack or defend, depending on the value of do_attack. If there is no stone |
a target to attack or defend, depending on the value of do_attack. |
88 |
present to attack or defend, it is assumed that it has already been |
If there is no stone present to attack or defend, it is assumed |
89 |
captured. If one or more of the moves to play turns out to be illegal for some |
that it has already been captured. If one or more of the moves to |
90 |
reason, the rest of the sequence is played anyway, and attack/defense is |
play turns out to be illegal for some reason, the rest of the |
91 |
tested as if nothing special happened. A typical use for these functions is to |
sequence is played anyway, and attack/defense is tested as if |
92 |
set up a crosscut in an autohelper and see whether at least one cutting stone |
nothing special happened. Conversely, |
93 |
can be captured. |
@code{play_attack_defend2_n()} plays a sequence of moves, |
94 |
|
alternating between the players and starting with @code{color}. After |
95 |
|
having played through the sequence, the two last coordinate pairs |
96 |
|
give two targets to simultaneously attack or defend, depending on |
97 |
|
the value of do_attack. If there is no stone present to attack or |
98 |
|
defend, it is assumed that it has already been captured. If one or |
99 |
|
more of the moves to play turns out to be illegal for some reason, |
100 |
|
the rest of the sequence is played anyway, and attack/defense is |
101 |
|
tested as if nothing special happened. A typical use of these functions is to |
102 |
|
set up a ladder in an autohelper and see whether it works or not. |
103 |
@end quotation |
@end quotation |
104 |
@item @code{int play_connect_n(int color, int do_connect, int num_moves, ...)} |
@item @code{int play_connect_n(int color, int do_connect, int num_moves, ...)} |
105 |
@findex play_connect_n |
@findex play_connect_n |
106 |
@quotation |
@quotation |
107 |
Plays a sequence of moves, alternating between the players and starting |
Plays a sequence of moves, alternating between the players and starting |
108 |
with color. After having played through the sequence, the two last |
with @code{color}. After having played through the sequence, the two last |
109 |
coordinates give two targets that should be connected or disconnected, |
coordinates give two targets that should be connected or disconnected, |
110 |
depending on the value of do_connect. If there is no stone present to |
depending on the value of do_connect. If there is no stone present to |
111 |
connect or disconnect, it is assumed that the connection has failed. If |
connect or disconnect, it is assumed that the connection has failed. If |
113 |
reason, the rest of the sequence is played anyway, and |
reason, the rest of the sequence is played anyway, and |
114 |
connection/disconnection is tested as if nothing special happened. |
connection/disconnection is tested as if nothing special happened. |
115 |
@end quotation |
@end quotation |
|
|
|
116 |
@item @code{void set_depth_values(int level)} |
@item @code{void set_depth_values(int level)} |
117 |
@findex set_depth_values |
@findex set_depth_values |
118 |
@quotation |
@quotation |
119 |
Set the various reading depth parameters. If @code{mandated_depth_value} |
It is assumed in reading a ladder if @code{stackp >= depth} that |
120 |
is not -1 that value is used; otherwise the depth values are |
as soon as a bounding stone is in atari, the string is safe. |
121 |
set as a function of level. The parameter @code{mandated_depth_value} |
Similar uses are made of the other depth parameters such |
122 |
can be set at the command line to force a particular value of |
as @code{backfill_depth} and so forth. In short, simplifying |
123 |
depth; normally it is -1. |
assumptions are made when @code{stackp} is large. Unfortunately any such |
124 |
|
scheme invites the ``horizon effect,'' in which a stalling move is perceived |
125 |
|
as a win, by pushing the refutation past the ``horizon''---the value of |
126 |
|
@code{stackp} in which the reading assumptions are relaxed. To avoid the depth |
127 |
|
it is sometimes necessary to increase the depth parameters. This |
128 |
|
function can be used to set the various reading depth parameters. If |
129 |
|
@code{mandated_depth_value} is not -1 that value is used; otherwise the depth |
130 |
|
values are set as a function of level. The parameter |
131 |
|
@code{mandated_depth_value} can be set at the command line to force a |
132 |
|
particular value of depth; normally it is -1. |
133 |
@end quotation |
@end quotation |
134 |
@item @code{void modify_depth_values(int n)} |
@item @code{void modify_depth_values(int n)} |
135 |
@findex modify_depth_values |
@findex modify_depth_values |
156 |
@quotation |
@quotation |
157 |
Sets @code{depth} and so forth to their saved values. |
Sets @code{depth} and so forth to their saved values. |
158 |
@end quotation |
@end quotation |
159 |
@item @code{int accurate_approxlib(int pos, int color, int maxlib, int *libs)} |
@item @code{void set_temporary_depth_values(int d, int b, int b2, int bc, int ss, int br, int f, int k)} |
|
@findex accurate_approxlib |
|
160 |
@quotation |
@quotation |
161 |
Play a stone at @code{pos} and count the number of liberties for the |
Explicitly set the depth values. This function is currently never |
162 |
resulting string. This requires @code{pos} to be empty. This function |
called. |
|
differs from @code{approxlib()} by the fact that it removes captured |
|
|
stones before counting the liberties. |
|
163 |
@end quotation |
@end quotation |
164 |
@item @code{int confirm_safety(int move, int color, int size, int *defense_point, int saved_dragons[BOARDMAX], int saved_worms[BOARDMAX])} |
@item @code{int confirm_safety(int move, int color, int *defense_point, char safe_stones[BOARDMAX])} |
165 |
@findex confirm_safety |
@findex confirm_safety |
166 |
@quotation |
@quotation |
167 |
|
Check that the move at color doesn't involve any kind of blunder, |
168 |
|
regardless of size. |
169 |
|
@end quotation |
170 |
|
@item @code{float blunder_size(int move, int color, int *defense_point, char safe_stones[BOARDMAX])} |
171 |
|
@findex blunder_size |
172 |
|
@quotation |
173 |
This function will detect some blunders. If the move reduces the number of |
This function will detect some blunders. If the move reduces the number of |
174 |
liberties of an adjacent friendly string, there is a danger that the move |
liberties of an adjacent friendly string, there is a danger that the move |
175 |
could backfire, so the function checks that no friendly worm which was |
could backfire, so the function checks that no friendly worm which was |
176 |
formerly not attackable becomes attackable, and it checks that no opposing |
formerly not attackable becomes attackable, and it checks that no opposing |
177 |
worm which was not defendable becomes defendable. Only worms with |
worm which was not defendable becomes defendable. It returns the estimated |
178 |
@code{worm.size>size} are checked. The arrays @code{saved_dragons[]} and |
size of the blunder, or 0.0 if nothing bad has happened. The array |
179 |
@code{saved_worms[]} should be one for stones belonging to dragons or worms |
@code{safe_stones[]} contains the stones that are supposedly safe after |
180 |
respectively, which are supposedly saved by @code{move}. These may be |
@code{move}. It may be @code{NULL}. For use when called from |
181 |
@code{NULL} if no stones are supposed to gaving been saved. For use when |
@code{fill_liberty()}, this function may optionally return a point of defense, |
182 |
called from @code{fill_liberty()}, this function may optionally return a point |
which, if taken, will presumably make the move at @code{move} safe on a |
183 |
of defense, which, if taken, will presumably make the move at @code{(move)} |
subsequent turn. |
|
safe on a subsequent turn. |
|
184 |
@end quotation |
@end quotation |
185 |
@item @code{int double_atari(int move, int color)} |
@item @code{int double_atari(int move, int color, float *value, char safe_stones[BOARDMAX])} |
186 |
@findex double_atari |
@findex double_atari |
187 |
@quotation |
@quotation |
188 |
Returns true if a move by @code{color} fits the following shape: |
Returns true if a move by (color) fits the following shape: |
189 |
@example |
@example |
190 |
X* (O=color) |
X* (O=color) |
191 |
OX |
OX |
192 |
@end example |
@end example |
193 |
capturing one of the two @samp{X} strings. The name is a slight |
capturing one of the two @samp{X} strings. The name is a slight misnomer since |
194 |
misnomer since this includes attacks which are not necessarily |
this includes attacks which are not necessarily double ataris, though the |
195 |
double ataris, though the common double atari is the most |
common double atari is the most important special case. If @code{safe_stones |
196 |
important special case. |
!= NULL}, then only attacks on stones marked as safe are tried. The value of |
197 |
|
the double atari attack is returned in value (unless value is @code{NULL}), |
198 |
|
and the attacked stones are marked unsafe. |
199 |
@end quotation |
@end quotation |
200 |
@item @code{void unconditional_life(int unconditional_territory[BOARDMAX], int color)} |
@item @code{void unconditional_life(int unconditional_territory[BOARDMAX], int color)} |
201 |
@findex unconditional_life |
@findex unconditional_life |
202 |
@quotation |
@quotation |
203 |
Find those worms of the given color that can never be captured, |
Find those worms of the given color that can never be captured, even if the |
204 |
even if the opponent is allowed an arbitrary number of consecutive |
opponent is allowed an arbitrary number of consecutive moves. The coordinates |
205 |
moves. The coordinates of the origins of these worms are written to |
of the origins of these worms are written to the worm arrays and the number of |
206 |
the worm arrays and the number of non-capturable worms is |
non-capturable worms is returned. The algorithm is to cycle through the worms |
207 |
returned. The algorithm is to cycle through the worms until none remains or |
until none remains or no more can be captured. A worm is removed when it is |
208 |
no more can be captured. A worm is removed when it is found to be |
found to be capturable, by letting the opponent try to play on all its |
209 |
capturable, by letting the opponent try to play on all its |
liberties. If the attack fails, the moves are undone. When no more worm can be |
210 |
liberties. If the attack fails, the moves are undone. When no more |
removed in this way, the remaining ones are unconditionally alive. After |
211 |
worm can be removed in this way, the remaining ones are |
this, unconditionally dead opponent worms and unconditional territory are |
212 |
unconditionally alive. After this, unconditionally dead opponent worms and |
identified. To find these, we continue from the position obtained at the end |
213 |
unconditional territory are identified. To find these, we continue from the |
of the previous operation (only unconditionally alive strings remain for |
214 |
position obtained at the end of the previous operation (only unconditionally |
color) with the following steps: |
215 |
alive strings remain for color) with the following steps: |
|
216 |
@enumerate |
@enumerate |
217 |
@item Play opponent stones on all liberties of the unconditionally |
@item Play opponent stones on all liberties of the unconditionally |
218 |
alive strings except where illegal. (That the move order may |
alive strings except where illegal. (That the move order may |
219 |
determine exactly which liberties can be played legally is not |
determine exactly which liberties can be played legally is not |
220 |
important. Just pick an arbitrary order). |
important. Just pick an arbitrary order). |
221 |
@item Recursively extend opponent strings in atari, except where this |
@item |
222 |
|
Recursively extend opponent strings in atari, except where this |
223 |
would be suicide. |
would be suicide. |
224 |
@item Play an opponent stone anywhere it can get two empty |
@item |
225 |
|
Play an opponent stone anywhere it can get two empty |
226 |
neighbors. (I.e. split big eyes into small ones). |
neighbors. (I.e. split big eyes into small ones). |
227 |
@item 4. Play an opponent stone anywhere it can get one empty |
@item |
228 |
|
an opponent stone anywhere it can get one empty |
229 |
neighbor. (I.e. reduce two space eyes to one space eyes.) |
neighbor. (I.e. reduce two space eyes to one space eyes.) |
|
@end enumerate |
|
230 |
Remaining opponent strings in atari and remaining liberties of the |
Remaining opponent strings in atari and remaining liberties of the |
231 |
unconditionally alive strings constitute the unconditional |
unconditionally alive strings constitute the unconditional |
232 |
territory. Opponent strings from the initial position placed on |
territory. |
233 |
|
Opponent strings from the initial position placed on |
234 |
unconditional territory are unconditionally dead. |
unconditional territory are unconditionally dead. |
235 |
On return, @code{unconditional_territory[][]} is 1 where color has |
On return, @code{unconditional_territory[][]} is 1 where color has |
236 |
unconditionally alive stones, 2 where it has unconditional |
unconditionally alive stones, 2 where it has unconditional |
237 |
territory, and 0 otherwise. |
territory, and 0 otherwise. |
238 |
|
@end enumerate |
239 |
@end quotation |
@end quotation |
240 |
@item @code{void who_wins(int color, FILE *outfile)} |
@item @code{void who_wins(int color, FILE *outfile)} |
|
@findex who_wins |
|
241 |
@quotation |
@quotation |
242 |
Score the game and determine the winner. Result is printed on |
Score the game and determine the winner |
|
@code{outfile}. |
|
243 |
@end quotation |
@end quotation |
244 |
@item @code{void find_superstring(int str, int *num_stones, int *stones)} |
@item @code{void find_superstring(int str, int *num_stones, int *stones)} |
245 |
@findex find_superstring |
@findex find_superstring |
260 |
XOX |
XOX |
261 |
X.X |
X.X |
262 |
@end example |
@end example |
263 |
@item Bamboo joint. |
@item |
264 |
|
Bamboo joint. |
265 |
@example |
@example |
266 |
OO |
OO |
267 |
.. |
.. |
274 |
@end example |
@end example |
275 |
@item Connection through adjacent or diagonal tactically captured stones. |
@item Connection through adjacent or diagonal tactically captured stones. |
276 |
Connections of this type are omitted when the superstring code is |
Connections of this type are omitted when the superstring code is |
277 |
called from @file{reading.c}, but included when the superstring code is |
called from reading.c, but included when the superstring code is |
278 |
called from @file{owl.c}. |
called from owl.c |
279 |
@end enumerate |
@end enumerate |
280 |
@end quotation |
@end quotation |
281 |
@item @code{void find_superstring_liberties(int str, int *num_libs, int *libs, int liberty_cap)} |
@item @code{void find_superstring_liberties(int str, int *num_libs, int *libs, int liberty_cap)} |
282 |
@findex find_superstring_liberties |
@findex find_superstring_liberties |
283 |
@quotation |
@quotation |
284 |
This function computes the superstring at @code{str} as described above, |
This function computes the superstring at @code{str} as described above, but |
285 |
but omitting connections of type 5. Then it constructs a list of |
omitting connections of type 5. Then it constructs a list of liberties of the |
286 |
liberties of the superstring which are not already liberties of |
superstring which are not already liberties of @code{str}. If |
287 |
@code{str}. If @code{liberty_cap} is nonzero, only liberties of substrings of the |
@code{liberty_cap} is nonzero, only liberties of substrings of the superstring |
288 |
superstring which have fewer than @code{liberty_cap} liberties are |
which have fewer than @code{liberty_cap} liberties are generated. |
|
generated. |
|
289 |
@end quotation |
@end quotation |
290 |
@item @code{void find_proper_superstring_liberties(int str, int *num_libs, int *libs, int liberty_cap)} |
@item @code{void find_proper_superstring_liberties(int str, int *num_libs, int *libs, int liberty_cap)} |
291 |
@findex find_proper_superstring_liberties |
@findex find_proper_superstring_liberties |
292 |
@quotation |
@quotation |
293 |
This function is the same as @code{find_superstring_liberties()}, but it omits those |
This function is the same as find_superstring_liberties, but it omits those |
294 |
liberties of the string @code{str}, presumably since those have already been |
liberties of the string @code{str}, presumably since those have already been |
295 |
treated elsewhere. If @code{liberty_cap} is nonzero, only liberties of substrings of |
treated elsewhere. If @code{liberty_cap} is nonzero, only liberties of |
296 |
the superstring which have at most @code{liberty_cap} liberties are generated. |
substrings of the superstring which have at most @code{liberty_cap} liberties |
297 |
|
are generated. |
298 |
@end quotation |
@end quotation |
299 |
@item @code{void find_superstring_stones_and_liberties(int str, int *num_stones, int *stones, int *num_libs, int *libs, int liberty_cap)} |
@item @code{void find_superstring_stones_and_liberties(int str, int *num_stones, int *stones, int *num_libs, int *libs, int liberty_cap)} |
300 |
@findex find_superstring_stones_and_liberties |
@findex find_superstring_stones_and_liberties |
302 |
This function computes the superstring at @code{str} as described above, |
This function computes the superstring at @code{str} as described above, |
303 |
but omitting connections of type 5. Then it constructs a list of |
but omitting connections of type 5. Then it constructs a list of |
304 |
liberties of the superstring which are not already liberties of |
liberties of the superstring which are not already liberties of |
305 |
@code{str}. If @code{liberty_cap} is nonzero, only liberties of substrings of the |
@code{str}. If liberty_cap is nonzero, only liberties of substrings of the |
306 |
superstring which have fewer than @code{liberty_cap} liberties are |
superstring which have fewer than liberty_cap liberties are |
307 |
generated. |
generated. |
308 |
@end quotation |
@end quotation |
309 |
@item @code{void superstring_chainlinks(int str, int *num_adj, int adjs[MAXCHAIN], int liberty_cap)} |
@item @code{void superstring_chainlinks(int str, int *num_adj, int adjs[MAXCHAIN], int liberty_cap)} |
310 |
@findex superstring_chainlinks |
@findex superstring_chainlinks |
311 |
@quotation |
@quotation |
312 |
Analogous to chainlinks, this function finds boundary chains of the |
analogous to chainlinks, this function finds boundary chains of the |
313 |
superstring at @code{str}, including those which are boundary chains of |
superstring at @code{str}, including those which are boundary chains of |
314 |
@code{str} itself. If @code{liberty_cap != 0}, only those boundary chains with |
@code{str} itself. If @code{liberty_cap != 0}, only those boundary chains with |
315 |
@code{<= liberty_cap} liberties are reported. |
@code{<= liberty_cap} liberties are reported. |
316 |
@end quotation |
@end quotation |
317 |
@item @code{void proper_superstring_chainlinks(int str, int *num_adj, int adjs[MAXCHAIN], int liberty_cap)} |
@item @code{void proper_superstring_chainlinks(int str, int *num_adj, int adjs[MAXCHAIN], int liberty_cap)} |
318 |
@findex proper_superstring_chainlinks |
@findex proper_superstring_chainlingks |
319 |
@quotation |
@quotation |
320 |
Analogous to chainlinks, this function finds boundary chains of the |
analogous to chainlinks, this function finds boundary chains of the |
321 |
superstring at @code{str}, omitting those which are boundary chains of |
superstring at @code{str}, omitting those which are boundary chains of |
322 |
@code{str} itself. If @code{liberty_cap != 0}, only those boundary chains with |
@code{str} itself. If @code{liberty_cap != 0}, only those boundary chains with |
323 |
@code{<= liberty_cap} liberties are reported. |
@code{<= liberty_cap} liberties are reported. |
324 |
@end quotation |
@end quotation |
325 |
@item @code{void start_timer(int n)} |
@item @code{void start_timer(int n)} |
326 |
@findex start_timer |
@findex start_timer |
327 |
|
@cindex timers |
328 |
@quotation |
@quotation |
329 |
Start a timer. Internal timers are used for assessing time spent on |
Start a timer. GNU Go has four internal timers available for |
330 |
various tasks. |
assessing the time spent on various tasks. |
331 |
@end quotation |
@end quotation |
332 |
@item @code{double time_report(int n, const char *occupation, int move, double mintime)} |
@item @code{double time_report(int n, const char *occupation, int move, double mintime)} |
333 |
@findex time_report |
@findex time_report |
338 |
@end itemize |
@end itemize |
339 |
|
|
340 |
@node Print Utilities |
@node Print Utilities |
341 |
@section Print utilities |
@section Print Utilities |
342 |
|
@cindex formatted printing |
343 |
|
|
344 |
Some utility functions from @file{engine/printutils.c}. |
Functions in @file{engine/printutils.c} do formatted printing similar to |
345 |
@findex TRACE |
@code{printf} and its allies. The following formats are recognized: |
|
@findex DEBUG |
|
|
|
|
|
The functions such as @code{gprintf} and the @code{TRACE} and |
|
|
@code{DEBUG} macros are derived from @code{vgprintf}, which is |
|
|
local to the file. Any one of these functions simulates the |
|
|
formatted @code{printf} functions in the standard C library, |
|
|
but the formats are slightly modified. One can use %c, %d, %f, |
|
|
%s, and %x as usual. But there are some other formats: |
|
346 |
|
|
347 |
@itemize @bullet |
@itemize @bullet |
348 |
@item %m: which takes TWO integers and writes a move; |
@item @code{%c}, @code{%d}, @code{%f}, @code{%s}, @code{%x} |
349 |
@item %1m: which takes one integer and prints a move; |
@quotation |
350 |
@item %H: Print a hashvalue. |
These have their usual meaning in formatted output, printing |
351 |
@item %C: Print a color as a string. |
a character, integer, float, string or hexadecimal, respectively. |
352 |
@item %M: Like %m but three characters wide for all moves (pads with spaces). |
@end quotation |
353 |
@item %o at the start means outdent, i.e. cancel indent. |
@item @code{%o} |
354 |
|
@quotation |
355 |
|
`Outdent.' Normally output is indented by @code{2*stackp} spaces, |
356 |
|
so that the depth can be seen at a glance in traces. At the |
357 |
|
beginning of a format, this @code{%o} inhibits the indentation. |
358 |
|
@end quotation |
359 |
|
@item @code{%H} |
360 |
|
@quotation |
361 |
|
Print a hashvalue. |
362 |
|
@end quotation |
363 |
|
@item @code{%C} |
364 |
|
@quotation |
365 |
|
Print a color as a string. |
366 |
|
@end quotation |
367 |
|
@item @code{%m}, @code{%2m} (synonyms) |
368 |
|
@quotation |
369 |
|
Takes 2 integers and writes a move, using the two dimensional |
370 |
|
board representation (@pxref{The Board Array}) |
371 |
|
@end quotation |
372 |
|
@item @code{%1m} |
373 |
|
@quotation |
374 |
|
Takes 1 integers and writes a move, using the one dimensional |
375 |
|
board representation (@pxref{The Board Array}) |
376 |
|
@end quotation |
377 |
|
@item @code{%r} |
378 |
|
@quotation |
379 |
|
Takes 1 integers and writes a move, using the one dimensional |
380 |
|
Print a read result as a string. Possible outcomes are: |
381 |
|
@itemize @minus |
382 |
|
@item 0 |
383 |
|
@item KO_B |
384 |
|
@item LOSS |
385 |
|
@item GAIN |
386 |
|
@item KO_A |
387 |
|
@item WIN |
388 |
|
@item SEKI |
389 |
|
@item ERROR |
390 |
|
@end itemize |
391 |
|
@end quotation |
392 |
@end itemize |
@end itemize |
393 |
|
|
394 |
The indentation referred to in the last item displays the stack depth. |
We list the non statically declared functions in @file{printutils.c}. |
395 |
|
|
396 |
@itemize @bullet |
@itemize @bullet |
397 |
|
@item @code{void gfprintf(FILE *outfile, const char *fmt, ...)} |
398 |
|
@findex gfprintf |
399 |
|
@quotation |
400 |
|
Formatted output to @file{outfile}. |
401 |
|
@end quotation |
402 |
@item @code{int gprintf(const char *fmt, ...)} |
@item @code{int gprintf(const char *fmt, ...)} |
403 |
@findex gprintf |
@findex gprintf |
404 |
@quotation |
@quotation |
405 |
The most common formatted print function, writes to stderr. |
Formatted output to stderr. Always returns 1 to allow use in short-circuit |
406 |
|
logical expressions. |
407 |
@end quotation |
@end quotation |
408 |
@item @code{void gfprintf(FILE *outfile, const char *fmt, ...)} |
@item @code{int mprintf(const char *fmt, ...)} |
409 |
@findex gfprintf |
@findex mprintf |
410 |
|
@quotation |
411 |
|
Formatted output to stdout. |
412 |
|
@end quotation |
413 |
|
@item @code{DEBUG(level, fmt, args...)} |
414 |
|
@findex DEBUG |
415 |
|
@quotation |
416 |
|
If @code{level & debug}, do formatted output to stderr. Otherwise, ignore. |
417 |
|
@end quotation |
418 |
|
@item @code{void abortgo(const char *file, int line, const char *msg, int pos)} |
419 |
|
@findex abortgo |
420 |
|
@quotation |
421 |
|
Print debugging output in an error situation, then exit. |
422 |
|
@end quotation |
423 |
|
@item @code{const char * color_to_string(int color)} |
424 |
|
@findex color_to_string |
425 |
@quotation |
@quotation |
426 |
Wrapper around @code{vgprintf}, writes to outfile. |
Convert a color value to a string |
427 |
|
@end quotation |
428 |
|
@item @code{const char * location_to_string(int pos)} |
429 |
|
@findex location_to_string |
430 |
|
@quotation |
431 |
|
Convert a location to a string |
432 |
|
@end quotation |
433 |
|
@item @code{void location_to_buffer(int pos, char *buf)} |
434 |
|
@findex location_to_buffer |
435 |
|
@quotation |
436 |
|
Convert a location to a string, writing to a buffer. |
437 |
|
@end quotation |
438 |
|
@item @code{const char * status_to_string(int status)} |
439 |
|
@findex status_to_string |
440 |
|
@quotation |
441 |
|
Convert a status value to a string. |
442 |
|
@end quotation |
443 |
|
@item @code{const char * safety_to_string(int status)} |
444 |
|
@findex safety_to_string |
445 |
|
@quotation |
446 |
|
Convert a safety value to a string. |
447 |
|
@end quotation |
448 |
|
@item @code{const char * routine_to_string(int routine)} |
449 |
|
@findex routine_to_string |
450 |
|
@quotation |
451 |
|
Convert a routine to a string. |
452 |
|
@end quotation |
453 |
|
@item @code{const char * result_to_string(int result)} |
454 |
|
@findex result_to_string |
455 |
|
@quotation |
456 |
|
Convert a read result to a string |
457 |
|
@end quotation |
458 |
|
@item @code{int string_to_location(int boardsize, char *str, int *m, int *n)} |
459 |
|
@findex string_to_location |
460 |
|
@quotation |
461 |
|
Get the @code{(m, n)} coordinates in the standard GNU Go coordinate system |
462 |
|
from the string @code{str}. This means that @samp{m} is the @samp{n}th row |
463 |
|
from the top and @samp{n} is the column. Both coordinates are between 0 and |
464 |
|
@code{boardsize-1}, inclusive. Return 1 if ok, otherwise return 0; |
465 |
@end quotation |
@end quotation |
|
void |
|
|
mprintf(const char *fmt, ...) |
|
|
Wrapper around @code{vgprintf}, in contrast to @code{gprintf} this one |
|
|
writes to stdout. |
|
|
TRACE(const char *fmt, ...) |
|
|
Like @code{gprintf}, but silent if the global variable @code{verbose} is |
|
|
zero. |
|
466 |
@end itemize |
@end itemize |
467 |
|
|