Next: Navigating the Source, Previous: Roadmap, Up: Overview
Please follow the coding conventions at: http://www.gnu.org/prep/standards_toc.html
Please preface every function with a brief description of its usage.
Please help to keep this Texinfo documentation up-to-date.
A function gprintf()
is provided. It is a cut-down
printf
, supporting only %c
, %d
,
%s
, and without field widths, etc. It does, however,
add some useful facilities:
%m
Takes two parameters, and displays a formatted board co-ordinate.
Trace messages are automatically indented to reflect the current stack depth, so it is clear during read-ahead when it puts a move down or takes one back.
As a workaround, %o
at the beginning of the: format string suppresses the indentation.
Normally gprintf()
is wrapped in one of the following:
TRACE(fmt, ...)
:
Print the message if the 'verbose' variable > 0. (verbose is set by -t on the command line)
DEBUG(flags, fmt, ...)
:
WhileTRACE
is intended to afford an overview of what GNU Go is considering,DEBUG
allows occasional in depth study of a module, usually needed when something goes wrong.flags
is one of theDEBUG_*
symbols in engine/gnugo.h. TheDEBUG
macro tests to see if that bit is set in thedebug
variable, and prints the message if it is. The debug variable is set using the -d command-line option.
The variable verbose
controls the tracing. It
can equal 0 (no trace), 1, 2, 3 or 4 for increasing
levels of tracing. You can set the trace level at
the command line by -t for verbose=1
,
-t -t for verbose=2
, etc. But in
practice if you want more verbose tracing than level
1 it is better to use GDB to reach the point where
you want the tracing; you will often find that the
variable verbose
has been temporarily set to zero
and you can use the GDB command set var verbose=1
to turn the tracing back on.
Related to tracing are assertions. Developers are strongly encouraged to pepper their code with assertions to ensure that data structures are as they expect. For example, the helper functions make assertions about the contents of the board in the vicinity of the move they are evaluating.
ASSERT()
is a wrapper around the standard C assert()
function. In addition to the test, it takes an extra pair of parameters
which are the co-ordinates of a "relevant" board position. If an
assertion fails, the board position is included in the trace output, and
showboard()
and popgo()
are called to unwind and display
the stack.
We have adopted the convention of putting the word FIXME in comments to denote known bugs, etc.