Updated README: Equal sign not required with `--mode` flag.
[sgk-go] / doc / dragon.texi
CommitLineData
7eeb782e
AT
1@menu
2* Worms:: Worms
3* Amalgamation:: How two Worms are amalgamated.
4* Connection:: Connections.
5* Half Eyes:: Half Eyes and False Eyes.
6* Dragons:: Union of WORMS.
7* Dragons in Color:: Colored display of DRAGONS.
8@end menu
9
10Before considering its move, GNU Go collects some data in several
11arrays. Two of these arrays, called @code{worm} and @code{dragon}, are
12discussed in this document. Others are discussed in @xref{Eyes}.
13
14This information is intended to help evaluate the connectedness, eye
15shape, escape potential and life status of each group.
16
17Later routines called by @code{genmove()} will then have access to this
18information. This document attempts to explain the philosophy and
19algorithms of this preliminary analysis, which is carried out by the
20two routines @code{make_worm()} and @code{make_dragon()} in
21@file{dragon.c}.
22
23@cindex dragon
24@cindex worm
25@cindex string
26A @dfn{worm} is a maximal set of stones on the board which are connected
27along the horizontal and vertical lines, and are of the same color.
28We often say @dfn{string} instead of worm.
29
30A @dfn{dragon} is a union of strings of the same color which will be
31treated as a unit. The dragons are generated anew at each move. If two strings
32are in the dragon, it is the computer's working hypothesis that they will live
33or die together and are effectively connected.
34
35The purpose of the dragon code is to allow the computer to formulate
36meaningful statements about life and death. To give one example,
37consider the following situation:
38@example
39
40 OOOOO
41 OOXXXOO
42 OX...XO
43 OXXXXXO
44 OOOOO
45
46@end example
47
48The X's here should be considered a single group with one three-space
49eye, but they consist of two separate strings. Thus we must
50amalgamate these two strings into a single dragon. Then the assertion
51makes sense, that playing at the center will kill or save the dragon,
52and is a vital point for both players. It would be difficult to
53formulate this statement if the X's are not perceived as a unit.
54
55The present implementation of the dragon code involves simplifying
56assumptions which can be refined in later implementations.
57
58@node Worms
59@section Worms
60@cindex worm
61
62The array @code{struct worm_data worm[MAX_BOARD]} collects information about
63the worms. We will give definitions of the various fields. Each field has
64constant value at each vertex of the worm. We will define each field.
65
66@example
67
68struct worm_data @{
69 int color;
70 int size;
71 float effective_size;
72 int origin;
73 int liberties;
74 int liberties2;
75 int liberties3;
76 int liberties4;
77 int lunch;
78 int cutstone;
79 int cutstone2;
80 int genus;
81 int inessential;
82 int invincible;
83 int unconditional_status;
84 int attack_points[MAX_TACTICAL_POINTS];
85 int attack_codes[MAX_TACTICAL_POINTS];
86 int defense_points[MAX_TACTICAL_POINTS];
87 int defend_codes[MAX_TACTICAL_POINTS];
88 int attack_threat_points[MAX_TACTICAL_POINTS];
89 int attack_threat_codes[MAX_TACTICAL_POINTS];
90 int defense_threat_points[MAX_TACTICAL_POINTS];
91 int defense_threat_codes[MAX_TACTICAL_POINTS];
92@};
93@end example
94
95@itemize @bullet
96@item @code{color}
97@quotation
98The color of the worm.
99@end quotation
100@item @code{size}
101@quotation
102This field contains the cardinality of the worm.
103@end quotation
104@item @code{effective_size}
105@quotation
106@cindex effective size (worm)
107This is the number of stones in a worm plus the number
108of empty intersections that are at least as close to this worm as to any
109other worm. Intersections that are shared are counted with equal
110fractional values for each worm. This measures the direct territorial
111value of capturing a worm. @dfn{effective_size} is a floating point number.
112Only intersections at a distance of 4 or less are counted.
113@end quotation
114@item @code{origin}
115@quotation
116@cindex origin (worm)
117Each worm has a distinguished member, called its @dfn{origin}.
118The purpose of this field is to make it easy to determine when two vertices
119lie in the same worm: we compare their origin. Also if we wish to perform some
120test once for each worm, we simply perform it at the origin and ignore the
121other vertices. The origin is characterized by the test:
122@example
123worm[pos].origin == pos.
124@end example
125@end quotation
126@item @code{liberties}
127@item @code{liberties2}
128@item @code{liberties3}
129@item @code{liberties4}
130@quotation
131@cindex liberties (worm)
132@cindex liberties, higher order (worm)
133For a nonempty worm the field liberties is the number of liberties of the
134string. This is supplemented by @code{LIBERTIES2}, @code{LIBERTIES3} and
135@code{LIBERTIES4}, which are the number of second order, third order, and
136fourth order liberties, respectively.
137The definition of liberties of order >1 is adapted to the
138problem of detecting the shape of the surrounding
139empty space. In particular we want to be able to see if a group
140is loosely surrounded. A @dfn{liberty of order n} is an empty
141vertex which may be connected to the string by placing n
142stones of the same color on the board, but no fewer. The
143path of connection may pass through an intervening group
144of the same color. The stones placed at distance >1 may
145not touch a group of the opposite color. Connections through
146ko are not permitted. Thus in the following configuration:
147@example
148
149 .XX... We label the .XX.4.
150 XO.... liberties of XO1234
151 XO.... order < 5 of XO1234
152 ...... the O group: .12.4.
153 .X.X.. .X.X..
154
155@end example
156
157The convention that liberties of order >1 may not touch a
158group of the opposite color means that knight's moves and
159one space jumps are perceived as impenetrable barriers.
160This is useful in determining when the string is becoming
161surrounded.
162
163The path may also not pass through a liberty at distance
1641 if that liberty is flanked by two stones of the opposing color. This
165reflects the fact that the O stone is blocked from expansion to the
166left by the two X stones in the following situation:
167@example
168
169 X.
170 .O
171 X.
172
173@end example
174@cindex distance from liberty to dragon
175We say that n is the @dfn{distance} of the liberty of order n from the dragon.
176@end quotation
177@item @code{lunch}
178@quotation
179@cindex lunch (worm)
180If nonzero, @code{lunch} points to a boundary worm which can be easily
181captured. (It does not matter whether or not the string can be
182defended.)
183@end quotation
184@end itemize
185
186We have two distinct notions of cutting stone, which we keep track
187of in the separate fields @code{worm.cutstone} and @code{worm.cutstone2}.
188We use currently use both concepts in parallel.
189
190@itemize
191@item @code{cutstone}
192@quotation
193@cindex cutting stone
194This field is equal to 2 for cutting stones, 1 for potential cutting
195stones. Otherwise it is zero. Definitions for this field: a @dfn{cutting
196stone} is one adjacent to two enemy strings, which do not have a liberty in
197common. The most common type of cutting string is in this situation:
198
199@example
200
201 XO
202 OX
203
204@end example
205@cindex cutting stone, potential
206@cindex potential cutting stone
207
208A @dfn{potential cutting stone} is adjacent to two enemy strings which do
209share a liberty. For example, X in:
210
211@example
212
213 XO
214 O.
215
216@end example
217
218For cutting strings we set @code{worm[].cutstone=2}. For
219potential cutting strings we set @code{worm[].cutstone=1}.
220@end quotation
221@item @code{cutstone2}
222@quotation
223Cutting points are identified by the patterns in the connections
224database. Proper cuts are handled by the fact that attacking and
225defending moves also count as moves cutting or connecting the
226surrounding dragons. The @code{cutstone2} field is set during
227@code{find_cuts()}, called from @code{make_domains()}.
228@end quotation
229@findex find_cuts
230@findex make_domains
231@item @code{genus}
232@quotation
233@cindex genus (worm)
234There are two separate notions of @dfn{genus} for worms and
235dragons. The dragon notion is more important, so
236@code{dragon[pos].genus} is a far more useful field than
237@code{worm[pos].genus}. Both fields are intended as approximations
238to the number of eyes. The @dfn{genus} of a string is the number
239of connected components of its complement, minus one. It is
240an approximation to the number of eyes of the string.
241@end quotation
242@item @code{inessential}
243@quotation
244@cindex inessential string
245An @dfn{inessential} string is one which meets a
246criterion designed to guarantee that it has no life
247potential unless a particular surrounding string of the
248opposite color can be killed. More precisely an
249@dfn{inessential string} is a string S of genus zero,
250not adjacent to any opponent string which can be easily
251captured, and which has no edge liberties or second
252order liberties, and which satisfies the following
253further property: If the string is removed from the
254board, then the remaining cavity only borders worms of the
255opposite color.
256
257@end quotation
258@findex unconditional_life
259@item @code{invincible}
260@quotation
261@cindex invincible worm
262An @dfn{invincible} worm is one which GNU Go thinks
263cannot be captured. Invincible worms are computed by the
264function @code{unconditional_life()} which tries to
265find those worms of the given color that can never be captured,
266even if the opponent is allowed an arbitrary number of consecutive
267moves.
268@end quotation
269@item unconditional_status
270@quotation
271Unconditional status is also set by the function
272@code{unconditional_life}. This is set @code{ALIVE} for stones which are
273invincible. Stones which can not be turned invincible even if the
274defender is allowed an arbitrary number of consecutive moves are given
275an unconditional status of @code{DEAD}. Empty points where the opponent
276cannot form an invincible worm are called unconditional territory. The
277unconditional status is set to @code{WHITE_TERRITORY} or
278@code{BLACK_TERRITORY} depending on who owns the territory. Finally, if
279a stone can be captured but is adjacent to unconditional territory of
280its own color, it is also given the unconditional status @code{ALIVE}.
281In all other cases the unconditional status is @code{UNKNOWN}.
282
283To make sense of these definitions it is important to notice that any
284stone which is alive in the ordinary sense (even if only in seki) can be
285transformed into an invincible group by some number of consecutive
286moves. Well, this is not entirely true because there is a rare class of
287seki groups not satisfying this condition. Exactly which these are is
288left as an exercise for the reader. Currently @code{unconditional_life},
289which strictly follows the definitions above, calls such seki groups
290unconditionally dead, which of course is a misfeature. It is possible to
291avoid this problem by making the algorithm slightly more complex, but
292this is left for a later revision.
293@end quotation
294@item @code{int attack_points[MAX_TACTICAL_POINTS]}
295@item @code{attack_codes[MAX_TACTICAL_POINTS]}
296@item @code{int defense_points[MAX_TACTICAL_POINTS];}
297@item @code{int defend_codes[MAX_TACTICAL_POINTS];}
298@quotation
299If the tactical reading code (@pxref{Tactical Reading}) finds that the
300worm can be attacked, @code{attack_points[0]} is a point of attack, and
301@code{attack_codes[0]} is the attack code, @code{WIN}, @code{KO_A} or
302@code{KO_B}. If multiple attacks are known, @code{attack_points[k]} and
303@code{attack_codes[k]} are used. Similarly with the defense
304codes and defense points.
305@end quotation
306@item @code{int attack_threat_points[MAX_TACTICAL_POINTS];}
307@item @code{int attack_threat_codes[MAX_TACTICAL_POINTS];}
308@item @code{int defense_threat_points[MAX_TACTICAL_POINTS];}
309@item @code{int defense_threat_codes[MAX_TACTICAL_POINTS];}
310@quotation
311These are points that threaten to attack or defend a worm.
312@end quotation
313@end itemize
314
315The function @code{makeworms()} will generate data for all worms.
316
317@node Amalgamation
318@section Amalgamation
319@cindex amalgamation of worms into dragons
320
321A dragon, we have said, is a group of stones which are treated as a
322unit. It is a working hypothesis that these stones will live or die
323together. Thus the program will not expect to disconnect an opponent's
324strings if they have been amalgamated into a single dragon.
325
326The function @code{make_dragons()} will amalgamate worms into dragons by
327maintaining separate arrays @code{worm[]} and @code{dragon[]} containing
328similar data. Each dragon is a union of worms. Just as the data maintained in
329@code{worm[]} is constant on each worm, the data in
330@code{dragon[]} is constant on each dragon.
331
332Amalgamation of worms in GNU Go proceeds as follows.
333First we amalgamate all boundary components of an eyeshape. Thus in
334the following example:
335
336@example
337
338.OOOO. The four X strings are amalgamated into a
339OOXXO. single dragon because they are the boundary
340OX..XO components of a blackbordered cave. The
341OX..XO cave could contain an inessential string
342OOXXO. with no effect on this amalgamation.
343XXX...
344
345@end example
346@findex dragon_eye
347
348The code for this type of amalgamation is in the routine
349@code{dragon_eye()}, discussed further in EYES.
350
351Next, we amalgamate strings which seem uncuttable. We amalgamate dragons
352which either share two or more common liberties, or share one liberty
353into the which the opponent cannot play without being
354captured. (ignores ko rule).
355
356@example
357
358 X. X.X XXXX.XXX X.O
359 .X X.X X......X X.X
360 XXXXXX.X OXX
361
362@end example
363
364A database of connection patterns may be found in @file{patterns/conn.db}.
365
366@node Connection
367@section Connection
368@cindex connections
369
370The fields @code{black_eye.cut} and @code{white_eye.cut} are set where the
371opponent can cut, and this is done by the B (break) class patterns in
372@file{conn.db}. There are two important uses for this field, which can be
373accessed by the autohelper functions @code{xcut()} and @code{ocut()}. The
374first use is to stop amalgamation in positions like
375
376@example
377
378..X..
379OO*OO
380X.O.X
381..O..
382
383@end example
384
385@noindent
386where X can play at * to cut off either branch. What happens
387here is that first connection pattern CB1 finds the double cut
388and marks * as a cutting point. Later the C (connection) class
389patterns in conn.db are searched to find secure connections
390over which to amalgamate dragons. Normally a diagonal
391connection would be deemed secure and amalgamated by connection
392pattern CC101, but there is a constraint requiring that neither of
393the empty intersections is a cutting point.
394@findex amalgamate_most_valuable_helper
395
396A weakness with this scheme is that X can only cut one connection, not
397both, so we should be allowed to amalgamate over one of the connections.
398This is performed by connection pattern CC401, which with the help of
399@code{amalgamate_most_valuable_helper()} decides which connection to
400prefer.
401
402The other use is to simplify making alternative connection patterns to
403the solid connection. Positions where the diag_miai helper thinks a
404connection is necessary are marked as cutting points by connection
405pattern 12. Thus we can write a connection pattern like @code{CC6}:
406
407@example
408
409?xxx? straight extension to connect
410XOO*?
411O...?
412
413:8,C,NULL
414
415?xxx?
416XOOb?
417Oa..?
418
419;xcut(a) && odefend_against(b,a)
420
421@end example
422
423@noindent
424where we verify that a move at @code{*} would stop the enemy from safely
425playing at the cutting point, thus defending against the cut.
426
427@node Half Eyes
428@section Half Eyes and False Eyes
429@cindex half eye
430@cindex false eye
431
432A @dfn{half eye} is a place where, if the defender plays first, an eye
433will materialize, but where if the attacker plays first, no eye will
434materialize. A @dfn{false eye} is a vertex which is surrounded by a
435dragon yet is not an eye. Here is a half eye:
436
437@example
438@group
439
440XXXXX
441OO..X
442O.O.X
443OOXXX
444
445@end group
446@end example
447
448Here is a false eye:
449
450@example
451@group
452
453XXXXX
454XOO.X
455O.O.X
456OOXXX
457
458@end group
459@end example
460
461The "topological" algorithm for determining half and false eyes
462is described elsewhere (@pxref{Eye Topology}).
463
464The half eye data is collected in the dragon array. Before this is done,
465however, an auxiliary array called half_eye_data is filled with
466information. The field @code{type} is 0, or else @code{HALF_EYE} or
467@code{FALSE_EYE} depending on which type is found; the fields
468@code{attack_point[]} point to up to 4 points to attack
469the half eye, and similarly @code{defense_point[]} gives points
470to defend the half eye.
471
472@example
473@group
474
475struct half_eye_data half_eye[MAX_BOARD];
476
477struct half_eye_data @{
478 float value; /* Topological eye value */
479 int type; /* HALF_EYE or FALSE_EYE */
480 int num_attacks; /* Number of attacking points */
481 int attack_point[4]; /* The moves to attack a topological halfeye */
482 int num_defends; /* Number of defending points */
483 int defense_point[4]; /* The moves to defend a topological halfeye */
484@};
485
486@end group
487@end example
488
489The array @code{struct half_eye_data half_eye[MAX_BOARD]}
490contains information about half and false eyes. If the type is
491@code{HALF_EYE} then up to four moves are recorded which can
492either attack or defend the eye. In rare cases the attack points
493could be different from the defense points.
494
495@node Dragons
496@section Dragons
497@cindex dragons
498
499The array @code{struct dragon_data dragon[MAX_BOARD]}
500collects information about the dragons. We will give definitions of the
501various fields. Each field has constant value at each vertex of the
502dragon. (Fields will be discussed below.)
503
504@example
505
506struct dragon_data @{
507 int color; /* its color */
508 int id; /* the index into the dragon2 array */
509 int origin; /* the origin of the dragon. Two vertices */
510 /* are in the same dragon iff they have */
511 /* same origin. */
512 int size; /* size of the dragon */
513 float effective_size; /* stones and surrounding spaces */
514 int crude_status; /* (ALIVE, DEAD, UNKNOWN, CRITICAL)*/
515 int status; /* best trusted status */
516@};
517
518extern struct dragon_data dragon[BOARDMAX];
519
520@end example
521
522Other fields attached to the dragon are contained in the @code{dragon_data2}
523struct array. (Fields will be discussed below.)
524
525@example
526
527struct dragon_data2 @{
528 int origin;
529 int adjacent[MAX_NEIGHBOR_DRAGONS];
530 int neighbors;
531 int hostile_neighbors;
532 int moyo_size;
533 float moyo_territorial_value;
534 int safety;
535 float weakness;
536 float weakness_pre_owl;
537 int escape_route;
538 struct eyevalue genus;
539 int heye;
540 int lunch;
541 int surround_status;
542 int surround_size;
543 int semeais;
544 int semeai_margin_of_safety;
545 int semeai_defense_point;
546 int semeai_defense_certain;
547 int semeai_attack_point;
548 int semeai_attack_certain;
549 int owl_threat_status;
550 int owl_status;
551 int owl_attack_point;
552 int owl_attack_code;
553 int owl_attack_certain;
554 int owl_second_attack_point;
555 int owl_defense_point;
556 int owl_defense_code;
557 int owl_defense_certain;
558 int owl_second_defense_point;
559 int owl_attack_kworm;
560 int owl_defense_kworm;
561@};
562
563extern struct dragon_data2 *dragon2;
564
565@end example
566
567The difference between the two arrays is that the @code{dragon} array
568is indexed by the board, and there is a copy of the dragon data
569at every stone in the dragon, while there is only one copy of
570the dragon2 data. The dragons are numbered, and the @code{id} field
571of the dragon is a key into the dragon2 array. Two macros DRAGON
572and DRAGON2 are provided for gaining access to the two arrays.
573
574@example
575#define DRAGON2(pos) dragon2[dragon[pos].id]
576#define DRAGON(d) dragon[dragon2[d].origin]
577@end example
578
579Thus if you know the position @code{pos} of a stone in the dragon
580you can access the dragon array directly, for example accessing the
581origin with @code{dragon[pos].origin}. However if you need a field
582from the dragon2 array, you can access it using the DRAGON2 macro,
583for example you can access its neighor dragons by
584
585@example
586for (k = 0; k < DRAGON2(pos).neighbors; k++) @{
587 int d = DRAGON2(pos).adjacent[k];
588 int apos = dragon2[d].origin;
589 do_something(apos);
590@}
591@end example
592
593Similarly if you know the dragon number (which is @code{dragon[pos].id})
594then you can access the @code{dragon2} array directly, or you can
595access the @code{dragon} array using the DRAGON macro.
596
597Here are the definitions of each field in the @code{dragon} arrray.
598
599@itemize @bullet
600@item @code{color}
601@quotation
602@cindex color (dragon)
603The color of the dragon.
604@end quotation
605@item @code{id}
606@cindex dragon number
607@quotation
608The dragon number, used as a key into the @code{dragon2} array.
609@end quotation
610@item origin
611@cindex dragon origin
612@quotation
613The origin of the dragon is a unique particular vertex
614of the dragon, useful for determining when two vertices belong
615to the same dragon. Before amalgamation the worm origins are
616copied to the dragon origins. Amalgamation of two dragons
617amounts to changing the origin of one.
618@end quotation
619@item size
620@cindex dragon size
621@quotation
622The number of stones in the dragon.
623@end quotation
624@item effective size
625@cindex effective size
626@quotation
627The sum of the effective sizes of the constituent worms.
628Remembering that vertices equidistant between two or more worms are
629counted fractionally in @code{worm.effective_size}, this equals the
630cardinality of the dragon plus the number of empty vertices which are
631nearer this dragon than any other.
632@end quotation
633@item crude_status
634@quotation
635(ALIVE, DEAD, UNKNOWN, CRITICAL). An early measure of the life
636potential of the dragon. It is computed before the owl code is
637run and is superceded by the status as soon as that becomes
638available.
639@end quotation
640@item status
641@cindex dragon status
642@quotation
643The dragon status is the best measure of the dragon's health.
644It is computed after the owl code is run, then revised again
645when the semeai code is run.
646@end quotation
647@end itemize
648
649Here are definitions of the fields in the @code{dragon2} array.
650
651@itemize @bullet
652@item origin
653@quotation
654The origin field is duplicated here.
655@end quotation
656@item adjacent
657@item @code{adjacent[MAX_NEIGHBOR_DRAGONS]}
658@cindex neighbor dragons
659@cindex adjacent dragons
660@findex find_neighbor_dragons
661@quotation
662Dragons of either color near the given one are called @dfn{neighbors}.
663They are computed by the function @code{find_neighbor_dragons()}.
664The @code{dragon2.adjacent} array gives the dragon numbers of
665these dragons.
666@end quotation
667@item @code{neighbors}
668@cindex neighbor dragons
669@cindex adjacent dragons
670@findex find_neighbor_dragons
671@quotation
672Dragons of either color near the given one are called @dfn{neighbors}.
673They are computed by the function @code{find_neighbor_dragons()}.
674The @code{dragon2.adjacent} array gives the dragon numbers of
675these dragons.
676@end quotation
677@item neighbors
678@quotation
679The number of neighbor dragons.
680@end quotation
681@item hostile_neighbors
682@quotation
683The number of neighbor dragons of the opposite color.
684@end quotation
685@item moyo_size
686@item float moyo_territorial_value
687@findex compute_surrounding_moyo_sizes
688@quotation
689The function @code{compute_surrounding_moyo_sizes()} assigns
690a size and a territorial value to the moyo around
691each dragon (@pxref{Territory and Moyo}). This is the
692moyo size. They are recorded in these fields.
693@end quotation
694@item safety
695@cindex dragon safety
696@quotation
697The dragon safety can take on one of the values
698@itemize @minus
699@item TACTICALLY_DEAD - a dragon consisting of a single worm found dead by the
700reading code (very reliable)
701@item ALIVE - found alive by the owl or semeai code
702@item STRONGLY_ALIVE - alive without much question
703@item INVINCIBLE - definitively alive even after many tenukis
704@item ALIVE_IN_SEKI - determined to be seki by the semeai code
705@item CRITICAL - lives or dies depending on who moves first
706@item DEAD - found to be dead by the owl code
707@item INESSENTIAL - the dragon is unimportant (e.g. nakade stones) and dead
708@end itemize
709@end quotation
710@item weakness
711@item weakness_pre_owl
712@cindex dragon weakness
713@cindex weakness
714@quotation
715A floating point measure of the safety of a dragon. The dragon
716weakness is a number between 0. and 1., higher numbers for
717dragons in greater need of safety. The field @code{weakness_pre_owl}
718is a preliminary computation before the owl code is run.
719@end quotation
720@item escape_route
721@cindex dragon escape_route
722@cindex escape_route
723@findex compute_escape
724@quotation
725A measure of the dragon's potential to escape towards safety,
726in case it cannot make two eyes locally. Documentation
727may be found in @ref{Escape}.
728@end quotation
729@item struct eyevalue genus
730@cindex dragon genus
731@cindex genus
732@quotation
733The approximate number of eyes the dragon can be expected to
734get. Not guaranteed to be accurate. The eyevalue struct, which
735is used throughout the engine, is declared thus:
736@example
737
738struct eyevalue @{
739 unsigned char a; /* # of eyes if attacker plays twice */
740 unsigned char b; /* # of eyes if attacker plays first */
741 unsigned char c; /* # of eyes if defender plays first */
742 unsigned char d; /* # of eyes if defender plays twice */
743@};
744
745@end example
746@end quotation
747@item heye
748@quotation
749Location of a half eye attached to the dragon.
750@end quotation
751@item lunch
752@cindex dragon lunch
753@cindex lunch
754@quotation
755If nonzero, this is the location of a boundary string which
756can be captured. In contrast with worm lunches, a dragon
757lunch must be able to defend itself.
758@end quotation
759@item surround_status
760@item surround_size
761@cindex surround_status
762@cindex surround_size
763@cindex surround
764@quotation
765In estimating the safety of a dragon it is useful to know if
766it is @dfn{surrounded}. See @ref{Surrounded Dragons} and
767the comments in @file{surround.c} for more information about the
768algorithm. Used in computing the escape_route, and also callable
769from patterns (currently used by CB258).
770@end quotation
771@item semeais
772@item semeai_defense_point
773@item semeai_defense_certain
774@item semeai_attack_point
775@item semeai_attack_certain
776@cindex semeai
777@cindex semeai_defense_point
778@cindex semeai_defense_certain
779@cindex semeai_attack_point
780@cindex semeai_attack_certain
781@quotation
782If two dragons of opposite color both have the status CRITICAL
783or DEAD they are in a @dfn{semeai} (capturing race), and their
784status must be adjudicated by the function
785@code{owl_analyze_semeai()} in @file{owl.c}, which attempts to
786determine which is alive, which dead, or if the result is
787seki, and whether it is important who moves first. The
788function @file{new_semeai()} in @file{semeai.c} attempts
789to revise the statuses and to generate move reasons based
790on these results. The field @code{dragon2.semeais} is nonzero
791if the dragon is an element of a semeai, and equals the
792number of semeais (seldom more than one). The semeai defense
793and attack points are locations the defender or attacker
794must move to win the semeai. The field @code{semeai_margin_of_safety}
795is intended to indicate whether the semeai is close or not
796but currently this field is not maintained. The fields
797@code{semeai_defense_certain} and @code{semeai_attack_certain}
798indicate that the semeai code was able to finish analysis
799without running out of nodes.
800@end quotation
801@item owl_status
802@quotation
803This is a classification similar to @code{dragon.crude_status}, but
804based on the life and death reading in @file{owl.c}.
805The owl code (@pxref{The Owl Code}) is skipped for dragons
806which appear safe by certain heuristics. If the owl code
807is not run, the owl status is @code{UNCHECKED}.
808If @code{owl_attack()} determines that the dragon cannot be
809attacked, it is classified as @code{ALIVE}. Otherwise,
810@code{owl_defend()} is run, and if it can be defended it
811is classified as @code{CRITICAL}, and if not, as @code{DEAD}.
812@end quotation
813@item owl_attack_point
814@cindex owl_attack_point
815@quotation
816If the dragon can be attacked this is the point to attack the dragon.
817@end quotation
818@item owl_attack_code
819@cindex owl_attack_code
820@quotation
821The owl attack code, It can be WIN, KO_A, KO_B or 0 (@pxref{Return Codes}).
822@end quotation
823@item owl_attack_certain
824@cindex owl_attack_certain
825@quotation
826The owl reading is able to finish analyzing the attack
827without running out of nodes.
828@end quotation
829@item owl_second_attack_point
830@cindex owl_second_attack_point
831@quotation
832A second attack point.
833@end quotation
834@item owl_defense_point
835@cindex owl_defense_point
836@quotation
837If the dragon can be defended, this is the place to play.
838@end quotation
839@item owl_defense_code
840@cindex owl_defense_code
841@quotation
842The owl defense code, It can be WIN, KO_A, KO_B or 0 (@pxref{Return Codes}).
843@end quotation
844@item owl_defense_certain
845@cindex owl_defense_certain
846@quotation
847The owl code is able to finish analyzing the defense without
848running out of nodes.
849@end quotation
850@item owl_second_defense_point
851@cindex owl_second_defense_point
852@quotation
853A second owl defense point.
854@end quotation
855@end itemize
856
857@node Dragons in Color
858@section Colored Dragon Display
859@cindex colored display
860
861You can get a colored ASCII display of the board in which each dragon
862is assigned a different letter; and the different values of
863@code{dragon.status} values (@code{ALIVE}, @code{DEAD}, @code{UNKNOWN},
864@code{CRITICAL}) have different colors. This is very handy for debugging.
865A second diagram shows the values of @code{owl.status}. If this
866is @code{UNCHECKED} the dragon is displayed in White.
867
868Save a game in sgf format using CGoban, or using the @option{-o} option with
869GNU Go itself.
870
871Open an @command{xterm} or @command{rxvt} window. You may also use the Linux
872console. Using the console, you may need to use ``SHIFT-PAGE UP'' to see the
873first diagram. Xterm will only work if it is compiled with color support---if
874you do not see the colors try @command{rxvt}. Make the background color black
875and the foreground color white.
876
877Execute:
878
879@command{gnugo -l [filename] -L [movenum] -T} to get the colored display.
880
881The color scheme: Green = @code{ALIVE}; Yellow = @code{UNKNOWN};
882Cyan = @code{DEAD} and Red = @code{CRITICAL}. Worms which have been
883amalgamated into the same dragon are labelled with the same letter.
884
885Other useful colored displays may be obtained by using instead:
886
887@itemize @bullet
888@item the option -E to display eye spaces (@pxref{Eyes}).
889@item the option -m 0x0180 to display territory, moyo and area
890(@pxref{Territory and Moyo}).
891@end itemize
892
893The colored displays are documented elsewhere (@pxref{Colored Display}).
894