Next: Attack and Defense DB, Previous: Autohelper Actions, Up: Patterns
The autohelper functions are translated into C code by the program in mkpat.c. To see exactly how the functions are implemented, consult the autohelper function definitions in that file. Autohelper functions can be used in both constraint and action lines.
lib(x)
lib2(x)
lib3(x)
lib4(x)
Number of first, second, third, and fourth order liberties of a worm respectively. See Worms and Dragons, the documentation on worms for definitions.
xlib(x)
olib(x)
The number of liberties that an enemy or own stone, respectively, would obtain if played at the empty intersection `x'.
xcut(x)
ocut(x)
Calls cut_possible
(see General Utilities) to determine
whether `X' or `O' can cut at the empty intersection `x'.
ko(x)
True if `x' is either a stone or an empty point involved in a ko position.
status(x)
The matcher status of a dragon. status(x) returns an integer that can have the
values ALIVE
, UNKNOWN
, CRITICAL
, or DEAD
(see Worms and Dragons).
alive(x)
unknown(x)
critical(x)
dead(x)
Each function true if the dragon has the corresponding matcher status and false otherwise (see Worms and Dragons).
status(x)
Returns the status of the dragon at `x' (see Worms and Dragons).
genus(x)
The number of eyes of a dragon. It is only meaningful to compare this value against 0, 1, or 2.
xarea(x)
oarea(x)
xmoyo(x)
omoyo(x)
xterri(x)
oterri(x)
These functions call whose_territory()
, whose_moyo()
and whose_area()
(see Territory and Moyo). For example
xarea(x)
evaluates to true if `x' is either a living enemy stone
or an empty point within the opponent's “area”. The function oarea(x)
is analogous but with respect to our stones and area. The main difference
between area, moyo, and terri is that area is a very far reaching kind of
influence, moyo gives a more realistic estimate of what may turn in to
territory, and terri gives the points that already are believed to be secure
territory.
weak(x)
True for a dragon that is perceived as weak.
attack(x)
defend(x)
Results of tactical reading. attack(x)
is true if the worm can be
captured, defend(x)
is true if there also is a defending move. Please
notice that defend(x)
will return false if there is no attack on the
worm.
safe_xmove(x)
safe_omove(x)
True if an enemy or friendly stone, respectively, can safely be played at `x'. By safe it is understood that the move is legal and that it cannot be captured right away.
legal_xmove(x)
legal_omove(x)
True if an enemy or friendly stone, respectively, can legally be played at x.
o_somewhere(x,y,z, ...) x_somewhere(x,y,z, ...)
True if O (respectively X) has a stone at one of the labelled vertices. In the diagram, these vertices should be marked with a `?'.
odefend_against(x,y) xdefend_against(x,y)
True if an own stone at `x' would stop the enemy from safely playing at `y', and conversely for the second function.
does_defend(x,y)
does_attack(x,y)
True if a move at `x' defends/attacks the worm at `y'. For defense a move of the same color as `y' is tried and for attack a move of the opposite color.
xplay_defend(a,b,c,...,z)
oplay_defend(a,b,c,...,z)
xplay_attack(a,b,c,...,z)
oplay_attack(a,b,c,...,z)
These functions make it possible to do more complex reading experiments in the constraints. All of them work so that first the sequence of moves `a',`b',`c',... is played through with alternating colors, starting with `X' or `O' as indicated by the name. Then it is tested whether the worm at `z' can be attacked or defended, respectively. It doesn't matter who would be in turn to move, a worm of either color may be attacked or defended. For attacks the opposite color of the string being attacked starts moving and for defense the same color starts. The defend functions return true if the worm cannot be attacked in the position or if it can be attacked but also defended. The attack functions return true if there is a way to capture the worm, whether or not it can also be defended. If there is no stone present at `z' after the moves have been played, it is assumed that an attack has already been successful or a defense has already failed. If some of the moves should happen to be illegal, typically because it would have been suicide, the following moves are played as if nothing has happened and the attack or defense is tested as usual. It is assumed that this convention will give the relevant result without requiring a lot of special cases.
The special label `?' can be used to represent a tenuki.
Thus oplay_defend(a,?,b,c)
tries moves by `O' at `a' and
`b', as if `X' plays the second move in another part of
the board, then asks if `c' can be defended. The tenuki cannot
be the first move of the sequence, nor does it need to be:
instead of oplay_defend(?,a,b,c)
you can use
xplay_defend(a,b,c)
.
xplay_defend_both(a,b,c,...,y,z)
oplay_defend_both(a,b,c,...,y,z)
xplay_attack_either(a,b,c,...,y,z)
oplay_attack_either(a,b,c,...,y,z)
These functions are similar to the previous ones. The difference is that the last *two* arguments denote worms to be attacked or defended simultaneously. Obviously `y' and `z' must have the same color. If either location is empty, it is assumed that an attack has been successful or a defense has failed. The typical use for these functions is in cutting patterns, where it usually suffices to capture either cutstone.
The function xplay_defend_both
plays alternate moves
beginning with an `X' at `a'. Then it passes the last
two arguments to defend_both
in
engine/utils.c. This function checks to determine
whether the two strings can be simultaneously defended.
The function xplay_attack_either
plays alternate
moves beginning with an `X' move at `a'. Then it passes
the last two arguments to attack_either
in
engine/utils.c. This function looks for a move
which captures at least one of the two strings. In its
current implementation attack_either
only looks
for uncoordinated attacks and would thus miss a double
atari.
xplay_connect(a,b,c,...,y,z)
oplay_connect(a,b,c,...,y,z)
xplay_disconnect(a,b,c,...,y,z)
oplay_disconnect(a,b,c,...,y,z)
The function xplay_connect(a,b,c,...,y,z)
begins
with an `X' move at `a', then an `O'
move at `b', and so forth, then finally calls
string_connect()
to determine whether
`x' and `y' can be connected. The other
functions are similar (see Connection Reading).
xplay_break_through(a,b,c,...,x,y,z)
oplay_break_through(a,b,c,...,x,y,z)
These functions are used to set up a position like
.O. .y. OXO xXz
and `X' aims at capturing at least one of `x', `y', and `z'. If this succeeds `1' is returned. If it doesn't, `X' tries instead to cut through on either side and if this succeeds, `2' is returned. Of course the same shape with opposite colors can also be used.
Important notice: `x', `y', and `z' must be given in the order they have in the diagram above, or any reflection and/or rotation of it.
seki_helper(x)
Checks whether the string at `x' can attack any surrounding string. If so, return false as the move to create a seki (probably) wouldn't work.
threaten_to_save(x)
Calls add_followup_value
to add as a move reason a conservative
estimate of the value of saving the string `x' by capturing one opponent
stone.
area_stone(x)
Returns the number of stones in the area around `x'.
area_space(x)
Returns the amount of space in the area around `x'.
eye(x)
proper_eye(x)
marginal_eye(x)
True if `x' is an eye space for either color, a non-marginal eye space for either color, or a marginal eye space for either color, respectively.
antisuji(x)
Tell the move generation that `x' is a substandard move that never should be played.
same_dragon(x,y) same_worm(x,y)
Return true if `x' and `y' are the same dragon or worm respectively.
dragonsize(x)
wormsize(x)
Number of stones in the indicated dragon or worm.
add_connect_move(x,y)
add_cut_move(x,y)
add_attack_either_move(x,y)
add_defend_both_move(x,y)
Explicitly notify the move generation about move reasons for the move in the pattern.
halfeye(x)
Returns true if the empty intersection at `x' is a half eye.
remove_attack(x)
Inform the tactical reading that a supposed attack does in fact not work.
potential_cutstone(x)
True if cutstone2
field from worm data is larger than one. This
indicates that saving the worm would introduce at least two new
cutting points.
not_lunch(x,y)
Prevents the misreporting of `x' as lunch for `y'. For example, the following pattern tells GNU Go that even though the stone at `a' can be captured, it should not be considered “lunch” for the dragon at `b', because capturing it does not produce an eye:
XO| ba| O*| O*| oo| oo| ?o| ?o| > not_lunch(a,b)
vital_chain(x)
Calls vital_chain
to determine whether capturing
the stone at `x' will result in one eye for an adjacent
dragon. The current implementation just checks that the stone
is not a singleton on the first line.
amalgamate(x,y)
Amalgamate (join) the dragons at `x' and `y' (see Worms and Dragons).
amalgamate_most_valuable(x,y,z)
Called when `x', `y', `z' point to three (preferably distinct) dragons, in situations such as this:
.O.X X*OX .O.X
In this situation, the opponent can play at `*', preventing the three dragons from becoming connected. However `O' can decide which cut to allow. The helper amalgamates the dragon at `y' with either `x' or `z', whichever is largest.
make_proper_eye(x)
This autohelper should be called when `x' is an eyespace which is misidentified as marginal. It is reclassified as a proper eyespace (see Eye Space).
remove_halfeye(x)
Remove a half eye from the eyespace. This helper should not be run after
make_dragons
is finished, since by that time the eyespaces have
already been analyzed.
remove_eyepoint(x)
Remove an eye point. This function can only be used before the segmentation into eyespaces.
owl_topological_eye(x,y)
Here `x' is an empty intersection which may be an eye or half eye for some dragon, and `y' is a stone of the dragon, used only to determine the color of the eyespace in question. Returns the sum of the values of the diagonal intersections, relative to `x', as explained in See Eye Topology, equal to 4 or more if the eye at `x' is false, 3 if it is a half eye, and 2 if it is a true eye.
owl_escape_value(x)
Returns the escape value at `x'. This is only useful in owl attack and defense patterns.