1 |
=head1 NAME |
2 |
|
3 |
Games::Go::SGF::Grove - SGF the Perl way |
4 |
|
5 |
=head1 SYNOPSIS |
6 |
|
7 |
use Games::Go::SGF::Grove; |
8 |
|
9 |
$game = load_sgf $path; |
10 |
save_sgf $path, $game; |
11 |
|
12 |
$game = decode_sgf $sgf_data; |
13 |
$sgf_data = encode_sgf $game; |
14 |
|
15 |
=head1 DESCRIPTION |
16 |
|
17 |
This module loads and saves Go SGF files. Unlike other modules, it doesn't |
18 |
build a very fancy data structure with lot's of java-like accessors |
19 |
but instead returns a simple Perl data structure you can inspect with |
20 |
Data::Dumper and modify easily. The structure follows the SGF file format |
21 |
very closely. |
22 |
|
23 |
The SGF format is documented here: L<http://www.red-bean.com/sgf/>. |
24 |
|
25 |
All the functions below use a common data format and throw exceptions on |
26 |
any errors. |
27 |
|
28 |
=over 4 |
29 |
|
30 |
=cut |
31 |
|
32 |
package Games::Go::SGF::Grove; |
33 |
|
34 |
use strict; |
35 |
no warnings; |
36 |
|
37 |
use Carp; |
38 |
|
39 |
use base Exporter::; |
40 |
|
41 |
our $VERSION = 0.1; |
42 |
our @EXPORT = qw(load_sgf save_sgf encode_sgf decode_sgf); |
43 |
|
44 |
=item $game = load_sgf $path |
45 |
|
46 |
Tries to read the file given by C<$path> and parses it as an SGF file, |
47 |
returning the parsed data structure. |
48 |
|
49 |
=item save_sgf $path, $game |
50 |
|
51 |
Saves the SGF data to the specified file. |
52 |
|
53 |
=item $game = decode_sgf $sgf_data |
54 |
|
55 |
Tries to parse the given string into a Pelr data structure and returns it. |
56 |
|
57 |
=item $sgf_data = encode_sgf $game |
58 |
|
59 |
Takes a Perl data structure and serialises it into an SGF file. Anything |
60 |
stored in the structure that isn't understood by this module will be |
61 |
silently ignored. |
62 |
|
63 |
=cut |
64 |
|
65 |
sub decode_sgf($) { |
66 |
my ($sgf_data) = @_; |
67 |
|
68 |
Games::Go::SGF::Grove::Parser::->new->decode_sgf ($sgf_data) |
69 |
} |
70 |
|
71 |
sub encode_sgf($) { |
72 |
my ($game) = @_; |
73 |
|
74 |
Games::Go::SGF::Grove::Parser::->new->encode_sgf ($game) |
75 |
} |
76 |
|
77 |
sub load_sgf($) { |
78 |
my ($path) = @_; |
79 |
|
80 |
open my $fh, "<:perlio", $path |
81 |
or Carp::croak "$path: $!"; |
82 |
|
83 |
local $/; |
84 |
decode_sgf <$fh> |
85 |
} |
86 |
|
87 |
sub save_sgf($$) { |
88 |
my ($path, $game) = @_; |
89 |
|
90 |
open my $fh, ">:perlio", $path |
91 |
or Carp::croak "$path: $!"; |
92 |
|
93 |
print $fh encode_sgf $game; |
94 |
} |
95 |
|
96 |
=back |
97 |
|
98 |
=head2 The Game Data structure |
99 |
|
100 |
The SGF game is represented by a linked Perl data structure consisting of |
101 |
unblessed hashes and arrays. |
102 |
|
103 |
SGF files are a forest of trees, called a collection (i.e. you can have |
104 |
multiple games stored in a file). The C<load_sgf> and C<decode_sgf> |
105 |
functions returns this collection as a reference to an array containing |
106 |
the individual game trees (usually there is only one, though). |
107 |
|
108 |
Each individual tree is again an array of nodes representing the main line |
109 |
of play. |
110 |
|
111 |
Each node is simply a hash reference. Each SGF property is stored with the |
112 |
(uppercase) property name as the key, and a property-dependent value for |
113 |
the contents (e.g., a black move is stored as C<< B => [3, 5] >>. |
114 |
|
115 |
If there are any variations/branches/alternate lines of play, then these |
116 |
are stored in the array reference in the C<variations> key (those again |
117 |
are game trees, so array references themselves). |
118 |
|
119 |
This module reserves all uppercase key names for SGF properties, the key |
120 |
C<variations> and all keys starting with an underscore (C<_xxx>) as it's |
121 |
own. Users of this module may store additional attributes that don't |
122 |
conflict with these names in any node. |
123 |
|
124 |
Unknown properties will be stored as scalars with the (binary) property |
125 |
contents. Text nodes will always be decoded into Unicode text and encoded |
126 |
into whatever the CA property of the root node says (default: C<UTF-8>). |
127 |
|
128 |
When saving, all uppercase keys will be saved, lowercase keys will be |
129 |
ignored. |
130 |
|
131 |
For the actual encoding of other types, best decode some example game that |
132 |
contains them and use Data::Dumper. Here is such an example: |
133 |
|
134 |
[ # list of game-trees, only one here |
135 |
[ # the main node sequence |
136 |
{ # the root node, contains some variations |
137 |
DI => '7k', |
138 |
AP => undef, |
139 |
CO => '5', |
140 |
DP => '40', |
141 |
GE => 'tesuji', |
142 |
AW => [ |
143 |
[ 2, 16 ], [ 3, 15 ], [ 15, 9 ], [ 14, 13 ], ... |
144 |
], |
145 |
C => 'White just played a ladder block at h12.', |
146 |
variations => [ # list of variations, only one |
147 |
[ # sequence of variation moves |
148 |
{ B => [ 7, 5 ] }, # a black move |
149 |
{ W => [ 12, 12 ] }, # a white move |
150 |
... and so on |
151 |
] |
152 |
], |
153 |
} |
154 |
] |
155 |
} |
156 |
|
157 |
=cut |
158 |
|
159 |
package Games::Go::SGF::Grove::Parser; |
160 |
|
161 |
no warnings; |
162 |
use strict 'vars'; |
163 |
|
164 |
use Encode (); |
165 |
use Carp qw(croak); |
166 |
|
167 |
my $ws = qr{[\x00-\x20]*}s; |
168 |
my $property; # property => propertyinfo |
169 |
|
170 |
sub new { |
171 |
my $class = shift; |
172 |
bless { @_ }, $class; |
173 |
} |
174 |
|
175 |
sub error { |
176 |
my ($self, $error) = @_; |
177 |
|
178 |
my $pos = pos $self->{sgf}; |
179 |
|
180 |
my $tail = substr $self->{sgf}, $pos, 32; |
181 |
$tail =~ s/[\x00-\x1f]+/ /g; |
182 |
|
183 |
croak "$error (at octet $pos, '$tail')"; |
184 |
} |
185 |
|
186 |
sub decode_sgf { |
187 |
my ($self, $sgf) = @_; |
188 |
|
189 |
# correct lines |
190 |
if ($sgf =~ /[^\015\012]\015/) { |
191 |
$sgf =~ s/\015\012?/\n/g; |
192 |
} else { |
193 |
$sgf =~ s/\012\015?/\n/g; |
194 |
} |
195 |
|
196 |
$self->{sgf} = $sgf; |
197 |
|
198 |
$self->{FF} = 1; |
199 |
$self->{CA} = 'WINDOWS-1252'; # too many files are |
200 |
$self->{GM} = 1; |
201 |
|
202 |
my @trees; |
203 |
|
204 |
eval { |
205 |
while ($self->{sgf} =~ /\G$ws(?=\()/sgoc) { |
206 |
push @trees, $self->decode_GameTree; |
207 |
} |
208 |
}; |
209 |
|
210 |
croak $@ if $@; |
211 |
|
212 |
\@trees |
213 |
} |
214 |
|
215 |
sub decode_GameTree { |
216 |
my ($self) = @_; |
217 |
|
218 |
$self->{sgf} =~ /\G$ws\(/sgoc |
219 |
or $self->error ("GameTree does not start with '('"); |
220 |
|
221 |
my $nodes = $self->decode_Sequence; |
222 |
|
223 |
while ($self->{sgf} =~ /\G$ws(?=\()/sgoc) { |
224 |
push @{$nodes->[-1]{variations}}, $self->decode_GameTree; |
225 |
} |
226 |
$self->{sgf} =~ /\G$ws\)/sgoc |
227 |
or $self->error ("GameTree does not end with ')'"); |
228 |
|
229 |
$nodes |
230 |
} |
231 |
|
232 |
sub postprocess { |
233 |
my $self = shift; |
234 |
|
235 |
for (@_) { |
236 |
if ("ARRAY" eq ref) { |
237 |
$self->postprocess (@$_); |
238 |
} elsif ("HASH" eq ref) { |
239 |
if (my $value = $_->{_text}) { |
240 |
$value =~ s/\\\n/ /g; |
241 |
$value =~ s/\\(.)/$1/g; |
242 |
$_ = eval { Encode::decode $self->{CA}, $value } || $value |
243 |
} else { |
244 |
$self->postprocess (values %$_); |
245 |
} |
246 |
} |
247 |
} |
248 |
} |
249 |
|
250 |
sub decode_Sequence { |
251 |
my ($self) = @_; |
252 |
|
253 |
my (@nodes, $node, $name, $value, $prop, @val); |
254 |
|
255 |
while ($self->{sgf} =~ /\G$ws;/goc) { |
256 |
push @nodes, $node = {}; |
257 |
# Node |
258 |
while ($self->{sgf} =~ /\G$ws([A-Za-z]+)/goc) { |
259 |
# Property |
260 |
$name = $1; |
261 |
$name =~ y/a-z//d; # believe me, they exist |
262 |
$prop = $property->{$name}; |
263 |
|
264 |
while ($self->{sgf} =~ /\G $ws \[ ( (?: [^\\\]]+ | \\. | \] (?! \s* [A-Z\[;()] ) )* ) \] /sgocx) { |
265 |
# PropValue |
266 |
$value = $1; |
267 |
if ($prop) { |
268 |
@val = $prop->{in}->($self, $value, $prop); |
269 |
|
270 |
if ($prop->{is_list}) { |
271 |
push @{$node->{$name}}, @val |
272 |
} else { |
273 |
$node->{$name} = $val[0]; |
274 |
|
275 |
$self->{CA} = $val[0] if $name eq "CA"; |
276 |
} |
277 |
} else { |
278 |
#warn "unknown property '$name', will be saved unchanged.";#d# |
279 |
push @{$node->{$name}}, $value; |
280 |
} |
281 |
} |
282 |
} |
283 |
|
284 |
# postprocess nodes, currently only to decode text and simpletext |
285 |
$self->postprocess ($node); |
286 |
} |
287 |
|
288 |
\@nodes |
289 |
} |
290 |
|
291 |
sub encode_sgf($) { |
292 |
my ($self, $game) = @_; |
293 |
|
294 |
$self->{sgf} = ""; |
295 |
|
296 |
$self->{FF} = 4; |
297 |
$self->{CA} = 'UTF-8'; |
298 |
$self->{GM} = 1; |
299 |
$self->{AP} = ["Games::Go::SGF::Grove", $VERSION]; |
300 |
|
301 |
$self->encode_GameTree ($_, 1) for @$game; |
302 |
|
303 |
$self->{sgf} |
304 |
} |
305 |
|
306 |
sub encode_GameTree { |
307 |
my ($self, $sequence, $is_root) = @_; |
308 |
|
309 |
if ($is_root) { |
310 |
my $root = $sequence->[0]; |
311 |
|
312 |
$root->{CA} ||= $self->{CA}; |
313 |
$root->{FF} ||= $self->{FF}; |
314 |
$root->{GM} ||= $self->{GM}; |
315 |
$root->{AP} ||= $self->{AP}; |
316 |
|
317 |
$self->{CA} = $root->{CA}; |
318 |
} |
319 |
|
320 |
$self->{sgf} .= "("; |
321 |
$self->encode_Sequence ($sequence); |
322 |
$self->{sgf} .= ")"; |
323 |
} |
324 |
|
325 |
sub encode_Sequence { |
326 |
my ($self, $sequence) = @_; |
327 |
|
328 |
my ($value, $prop); |
329 |
|
330 |
for my $node (@$sequence) { |
331 |
$self->{sgf} .= ";"; |
332 |
|
333 |
for my $name (sort keys %$node) { |
334 |
next unless $name eq uc $name; |
335 |
|
336 |
$value = $node->{$name}; |
337 |
|
338 |
$self->{sgf} .= "$name\["; |
339 |
|
340 |
if ($prop = $property->{$name}) { |
341 |
if ($prop->{is_list}) { |
342 |
$self->{sgf} .= join "][", map $prop->{out}->($self, $_), @$value; |
343 |
} else { |
344 |
$self->{sgf} .= $prop->{out}->($self, $value); |
345 |
} |
346 |
} else { |
347 |
$self->{sgf} .= |
348 |
ref $value |
349 |
? join "][", @$value |
350 |
: $value; |
351 |
} |
352 |
|
353 |
$self->{sgf} .= "]"; |
354 |
} |
355 |
|
356 |
$self->encode_GameTree ($_) for @{ $node->{variations} }; |
357 |
} |
358 |
} |
359 |
|
360 |
############################################################################# |
361 |
|
362 |
=head2 Property Type Structure |
363 |
|
364 |
A property type is a hash like this: |
365 |
|
366 |
{ |
367 |
name => "SQ", |
368 |
group => { |
369 |
name => "Markup properties", |
370 |
restrictions => "CR, MA, SL, SQ and TR points must be unique, ...", |
371 |
}, |
372 |
related => "TR, CR, LB, SL, AR, MA, LN", |
373 |
function => "Marks the given points with a square.\nPoints must be unique.", |
374 |
propertytype => "-", |
375 |
propvalue => "list of point" |
376 |
is_list => 1, |
377 |
} |
378 |
|
379 |
=cut |
380 |
|
381 |
|
382 |
{ |
383 |
my ($group, $name, $value, $prop); |
384 |
|
385 |
my (%char2coord, %coord2char); |
386 |
|
387 |
{ |
388 |
my @coord = ("a" .. "z", "A" .. "Z"); |
389 |
|
390 |
for (0.. $#coord) { |
391 |
$char2coord{ $coord[$_] } = $_; |
392 |
$coord2char{ $_ } = $coord[$_]; |
393 |
} |
394 |
} |
395 |
|
396 |
sub _parsetype($); |
397 |
sub _parsetype { |
398 |
for (shift) { |
399 |
if (s/e?list of //) { |
400 |
$prop->{is_list} = 1; |
401 |
return _parsetype $_; |
402 |
|
403 |
} elsif (s/composed (\S+)\s+(?:':'\s+)?(\S+)//) { |
404 |
$prop->{composed} = 1; |
405 |
my ($i, $o) = ($1, $2); |
406 |
my ($i1, $o1, $i2, $o2) = (_parsetype $i, _parsetype $o); |
407 |
return ( |
408 |
sub { |
409 |
if ($_[1] =~ /^((?:[^\\:]+|\\.)*)(?::(.*))?$/s) { |
410 |
# or $_[0]->error ("'Compose' ($i:$o) expected, got '$_[1]'"); |
411 |
my ($l, $r) = ($1, $2); |
412 |
|
413 |
[ |
414 |
$i1->($_[0], $l), |
415 |
defined $r ? $i2->($_[0], $r) : undef, |
416 |
] |
417 |
} |
418 |
}, |
419 |
sub { |
420 |
$o1->($_[0], $_[1][0]) |
421 |
. ":" |
422 |
. $o2->($_[0], $_[1][1]) |
423 |
}, |
424 |
); |
425 |
|
426 |
} elsif (s/double//) { |
427 |
return ( |
428 |
sub { |
429 |
$_[1] =~ /^[12]$/ |
430 |
or $_[0]->error ("'Double' (1|2) expected, got '$_[1]'"); |
431 |
$_[1] |
432 |
}, |
433 |
sub { |
434 |
$_[1] |
435 |
}, |
436 |
); |
437 |
} elsif (s/color//) { |
438 |
return ( |
439 |
sub { |
440 |
# too many broken programs write this wrong |
441 |
return "B" if $_[1] eq "1"; |
442 |
return "W" if $_[1] eq "2"; |
443 |
|
444 |
$_[1] =~ /^[BW]$/i |
445 |
or $_[0]->error ("'Color' (B|W) expected, got '$_[1]'"); |
446 |
lc $_[1] |
447 |
}, |
448 |
sub { |
449 |
uc $_[1] |
450 |
}, |
451 |
); |
452 |
} elsif (s/none//) { |
453 |
return ( |
454 |
sub { |
455 |
$_[1] =~ /^$/i |
456 |
or $_[0]->error ("'None' expected, got '$_[1]'"); |
457 |
undef |
458 |
}, |
459 |
sub { |
460 |
"", |
461 |
}, |
462 |
); |
463 |
} elsif (s/point// || s/move// || s/stone//) { |
464 |
return ( |
465 |
sub { |
466 |
if ($_[2]->{is_list}) { |
467 |
if ($_[1] =~ /^([^:]+):(.*)$/) { |
468 |
my ($ul, $dr) = ($1, $2); |
469 |
my ($x1, $y1) = map $char2coord{$_}, split //, $ul; |
470 |
my ($x2, $y2) = map $char2coord{$_}, split //, $dr; |
471 |
my @stones; |
472 |
for (my $d = $x1; $d < $x2; $d++) { |
473 |
for (my $i = $y1; $i < $y2; $i++) { |
474 |
push @stones, [$d, $i]; |
475 |
} |
476 |
} |
477 |
return @stones; |
478 |
} |
479 |
} |
480 |
$_[1] =~ /^(.)(.)$/ |
481 |
? [ $char2coord{$1}, $char2coord{$2} ] |
482 |
: [] |
483 |
}, |
484 |
sub { |
485 |
$coord2char{$_[1][0]} . $coord2char{$_[1][1]} |
486 |
}, |
487 |
); |
488 |
} elsif (s/real//) { |
489 |
return ( |
490 |
sub { |
491 |
$_[1]+0 |
492 |
}, |
493 |
sub { |
494 |
$_[1]+0 |
495 |
}, |
496 |
); |
497 |
} elsif (s/number//) { |
498 |
return ( |
499 |
sub { |
500 |
$_[1]+0 |
501 |
}, |
502 |
sub { |
503 |
int $_[1] |
504 |
}, |
505 |
); |
506 |
} elsif (s/text// || s/simpletext//i) { |
507 |
return ( |
508 |
sub { |
509 |
{ _text => $_[1] } |
510 |
}, |
511 |
sub { |
512 |
my $str = Encode::encode $_[0]{CA}, $_[1]; |
513 |
$str =~ s/([\:\]\\])/\\$1/g; |
514 |
$str |
515 |
}, |
516 |
); |
517 |
} else { |
518 |
die "FATAL: garbled DATA section, unknown type '$_'"; |
519 |
} |
520 |
} |
521 |
} |
522 |
|
523 |
while (<DATA>) { |
524 |
if (/^(\S+):\t(.*)/) { |
525 |
if ($name eq "Restrictions") { |
526 |
$group->{restrictions} = $value; |
527 |
} elsif ($name eq "Property") { |
528 |
$property->{$value} = |
529 |
$prop = { |
530 |
name => $value, |
531 |
group => $group, |
532 |
}; |
533 |
} elsif ($name ne "") { |
534 |
$prop->{lc $name} = $value; |
535 |
if ($name eq "Propvalue") { |
536 |
($prop->{in}, $prop->{out}) = _parsetype $value; |
537 |
} |
538 |
} |
539 |
$name = $1; |
540 |
$value = $2; |
541 |
} elsif (/^\t\t(.*)/) { |
542 |
$value .= "\n$1"; |
543 |
} elsif (/(\S.*)/) { |
544 |
$group = { |
545 |
name => $1, |
546 |
}; |
547 |
} elsif (/^$/) { |
548 |
# nop |
549 |
} else { |
550 |
die "FATAL: DATA section garbled\n"; |
551 |
} |
552 |
} |
553 |
} |
554 |
|
555 |
1; |
556 |
|
557 |
=head1 AUTHOR |
558 |
|
559 |
Marc Lehmann <schmorp@schmorp.de> |
560 |
Robin Redeker <elmex@ta-sa.org> |
561 |
|
562 |
=cut |
563 |
|
564 |
# now node descriptions follow |
565 |
|
566 |
__DATA__ |
567 |
Move properties |
568 |
|
569 |
Property: B |
570 |
Propvalue: move |
571 |
Propertytype: move |
572 |
Function: Execute a black move. This is one of the most used properties |
573 |
in actual collections. As long as |
574 |
the given move is syntactically correct it should be executed. |
575 |
It doesn't matter if the move itself is illegal |
576 |
(e.g. recapturing a ko in a Go game). |
577 |
Have a look at how to execute a Go-move. |
578 |
B and W properties must not be mixed within a node. |
579 |
Related: W, KO |
580 |
|
581 |
Property: KO |
582 |
Propvalue: none |
583 |
Propertytype: move |
584 |
Function: Execute a given move (B or W) even it's illegal. This is |
585 |
an optional property, SGF viewers themselves should execute |
586 |
ALL moves. It's purpose is to make it easier for other |
587 |
applications (e.g. computer-players) to deal with illegal |
588 |
moves. A KO property without a black or white move within |
589 |
the same node is illegal. |
590 |
Related: W, B |
591 |
|
592 |
Property: MN |
593 |
Propvalue: number |
594 |
Propertytype: move |
595 |
Function: Sets the move number to the given value, i.e. a move |
596 |
specified in this node has exactly this move-number. This |
597 |
can be useful for variations or printing. |
598 |
Related: B, W, FG, PM |
599 |
|
600 |
Property: W |
601 |
Propvalue: move |
602 |
Propertytype: move |
603 |
Function: Execute a white move. This is one of the most used properties |
604 |
in actual collections. As long as |
605 |
the given move is syntactically correct it should be executed. |
606 |
It doesn't matter if the move itself is illegal |
607 |
(e.g. recapturing a ko in a Go game). |
608 |
Have a look at how to execute a Go-move. |
609 |
B and W properties must not be mixed within a node. |
610 |
Related: B, KO |
611 |
|
612 |
Setup properties |
613 |
Restrictions: AB, AW and AE must have unique points, i.e. it is illegal to place different colors on the same point within one node. |
614 |
AB, AW and AE values which don't change the board, e.g. placing a black stone with AB[] over a black stone that's already there, is bad style. Applications may want to delete these values and issue a warning. |
615 |
|
616 |
Property: AB |
617 |
Propvalue: list of stone |
618 |
Propertytype: setup |
619 |
Function: Add black stones to the board. This can be used to set up |
620 |
positions or problems. Adding is done by 'overwriting' the |
621 |
given point with black stones. It doesn't matter what |
622 |
was there before. Adding a stone doesn't make any prisoners |
623 |
nor any other captures (e.g. suicide). Thus it's possible |
624 |
to create illegal board positions. |
625 |
Points used in stone type must be unique. |
626 |
Related: AW, AE, PL |
627 |
|
628 |
Property: AE |
629 |
Propvalue: list of point |
630 |
Propertytype: setup |
631 |
Function: Clear the given points on the board. This can be used |
632 |
to set up positions or problems. Clearing is done by |
633 |
'overwriting' the given points, so that they contain no |
634 |
stones. It doesn't matter what was there before. |
635 |
Clearing doesn't count as taking prisoners. |
636 |
Points must be unique. |
637 |
Related: AB, AW, PL |
638 |
|
639 |
Property: AW |
640 |
Propvalue: list of stone |
641 |
Propertytype: setup |
642 |
Function: Add white stones to the board. This can be used to set up |
643 |
positions or problems. Adding is done by 'overwriting' the |
644 |
given points with white stones. It doesn't matter what |
645 |
was there before. Adding a stone doesn't make any prisoners |
646 |
nor any other captures (e.g. suicide). Thus it's possible |
647 |
to create illegal board positions. |
648 |
Points used in stone type must be unique. |
649 |
Related: AB, AE, PL |
650 |
|
651 |
Property: PL |
652 |
Propvalue: color |
653 |
Propertytype: setup |
654 |
Function: PL tells whose turn it is to play. This can be used when |
655 |
setting up positions or problems. |
656 |
Related: AE, AB, AW |
657 |
|
658 |
Node annotation properties |
659 |
|
660 |
Property: C |
661 |
Propvalue: text |
662 |
Propertytype: - |
663 |
Function: Provides a comment text for the given node. The purpose of |
664 |
providing both a node name and a comment is to have a short |
665 |
identifier like "doesn't work" or "Dia. 15" that can be |
666 |
displayed directly with the properties of the node, even if |
667 |
the comment is turned off or shown in a separate window. |
668 |
See text-type for more info. |
669 |
Related: N, ST, V, UC, DM, HO |
670 |
|
671 |
Property: DM |
672 |
Propvalue: double |
673 |
Propertytype: - |
674 |
Function: The position is even. SGF viewers should display a |
675 |
message. This property may indicate main variations in |
676 |
opening libraries (joseki) too. Thus DM[2] indicates an |
677 |
even result for both players and that this is a main |
678 |
variation of this joseki/opening. |
679 |
This property must not be mixed with UC, GB or GW |
680 |
within a node. |
681 |
Related: UC, GW, GB |
682 |
|
683 |
Property: GB |
684 |
Propvalue: double |
685 |
Propertytype: - |
686 |
Function: Something good for black. SGF viewers should display a |
687 |
message. The property is not related to any specific place |
688 |
on the board, but marks the whole node instead. |
689 |
GB must not be mixed with GW, DM or UC within a node. |
690 |
Related: GW, C, UC, DM |
691 |
|
692 |
Property: GW |
693 |
Propvalue: double |
694 |
Propertytype: - |
695 |
Function: Something good for white. SGF viewers should display a |
696 |
message. The property is not related to any specific place |
697 |
on the board, but marks the whole node instead. |
698 |
GW must not be mixed with GB, DM or UC within a node. |
699 |
Related: GB, C, UC, DM |
700 |
|
701 |
Property: HO |
702 |
Propvalue: double |
703 |
Propertytype: - |
704 |
Function: Node is a 'hotspot', i.e. something interesting (e.g. |
705 |
node contains a game-deciding move). |
706 |
SGF viewers should display a message. |
707 |
The property is not related to any specific place |
708 |
on the board, but marks the whole node instead. |
709 |
Sophisticated applications could implement the navigation |
710 |
command next/previous hotspot. |
711 |
Related: GB, GW, C, UC, DM |
712 |
|
713 |
Property: N |
714 |
Propvalue: simpletext |
715 |
Propertytype: - |
716 |
Function: Provides a name for the node. For more info have a look at |
717 |
the C-property. |
718 |
Related: C, ST, V |
719 |
|
720 |
Property: UC |
721 |
Propvalue: double |
722 |
Propertytype: - |
723 |
Function: The position is unclear. SGF viewers should display a |
724 |
message. This property must not be mixed with DM, GB or GW |
725 |
within a node. |
726 |
Related: DM, GW, GB |
727 |
|
728 |
Property: V |
729 |
Propvalue: real |
730 |
Propertytype: - |
731 |
Function: Define a value for the node. Positive values are good for |
732 |
black, negative values are good for white. |
733 |
The interpretation of particular values is game-specific. |
734 |
In Go, this is the estimated score. |
735 |
Related: C, N, RE |
736 |
|
737 |
Move annotation properties |
738 |
Restrictions: Move annotation properties without a move (B[] or W[]) within the same node are senseless and therefore illegal. Applications should delete such properties and issue a warning. |
739 |
BM, TE, DO and IT are mutual exclusive, i.e. they must not be mixed within a single node. |
740 |
|
741 |
Property: BM |
742 |
Propvalue: double |
743 |
Propertytype: move |
744 |
Function: The played move is bad. |
745 |
Viewers should display a message. |
746 |
Related: TE, DO, IT |
747 |
|
748 |
Property: DO |
749 |
Propvalue: none |
750 |
Propertytype: move |
751 |
Function: The played move is doubtful. |
752 |
Viewers should display a message. |
753 |
Related: BM, TE, IT |
754 |
|
755 |
Property: IT |
756 |
Propvalue: none |
757 |
Propertytype: move |
758 |
Function: The played move is interesting. |
759 |
Viewers should display a message. |
760 |
Related: BM, DO, TE |
761 |
|
762 |
Property: TE |
763 |
Propvalue: double |
764 |
Propertytype: move |
765 |
Function: The played move is a tesuji (good move). |
766 |
Viewers should display a message. |
767 |
Related: BM, DO, IT |
768 |
|
769 |
Markup properties |
770 |
Restrictions: CR, MA, SL, SQ and TR points must be unique, i.e. it's illegal to have two or more of these markups on the same point within a node. |
771 |
|
772 |
Property: AR |
773 |
Propvalue: list of composed point point |
774 |
Propertytype: - |
775 |
Function: Viewers should draw an arrow pointing FROM the first point |
776 |
TO the second point. |
777 |
It's illegal to specify the same arrow twice, |
778 |
e.g. (Go) AR[aa:bb][aa:bb]. Different arrows may have the same |
779 |
starting or ending point though. |
780 |
It's illegal to specify a one point arrow, e.g. AR[cc:cc] |
781 |
as it's impossible to tell into which direction the |
782 |
arrow points. |
783 |
Related: TR, CR, LB, SL, MA, SQ, LN |
784 |
|
785 |
Property: CR |
786 |
Propvalue: list of point |
787 |
Propertytype: - |
788 |
Function: Marks the given points with a circle. |
789 |
Points must be unique. |
790 |
Related: TR, MA, LB, SL, AR, SQ, LN |
791 |
|
792 |
Property: DD |
793 |
Propvalue: elist of point |
794 |
Propertytype: inherit |
795 |
Function: Dim (grey out) the given points. |
796 |
DD[] clears any setting, i.e. it undims everything. |
797 |
Related: VW |
798 |
|
799 |
Property: LB |
800 |
Propvalue: list of composed point simpletext |
801 |
Propertytype: - |
802 |
Function: Writes the given text on the board. The text should be |
803 |
centered around the given point. Note: there's no longer |
804 |
a restriction to the length of the text to be displayed. |
805 |
Have a look at the FF4 example file on possibilities |
806 |
to display long labels (pictures five and six). |
807 |
Points must be unique. |
808 |
Related: TR, CR, MA, SL, AR, SQ, LN |
809 |
|
810 |
Property: LN |
811 |
Propvalue: list of composed point point |
812 |
Propertytype: - |
813 |
Function: Applications should draw a simple line form one point |
814 |
to the other. |
815 |
It's illegal to specify the same line twice, |
816 |
e.g. (Go) LN[aa:bb][aa:bb]. Different lines may have the same |
817 |
starting or ending point though. |
818 |
It's illegal to specify a one point line, e.g. LN[cc:cc]. |
819 |
Related: TR, CR, MA, SL, AR, SQ, LB |
820 |
|
821 |
|
822 |
Property: MA |
823 |
Propvalue: list of point |
824 |
Propertytype: - |
825 |
Function: Marks the given points with an 'X'. |
826 |
Points must be unique. |
827 |
Related: TR, CR, LB, SL, AR, SQ, LN |
828 |
|
829 |
Property: SL |
830 |
Propvalue: list of point |
831 |
Propertytype: - |
832 |
Function: Selected points. Type of markup unknown |
833 |
(though SGB inverts the colors of the given points). |
834 |
Points must be unique. |
835 |
Related: TR, CR, LB, MA, AR, LN |
836 |
|
837 |
Property: SQ |
838 |
Propvalue: list of point |
839 |
Propertytype: - |
840 |
Function: Marks the given points with a square. |
841 |
Points must be unique. |
842 |
Related: TR, CR, LB, SL, AR, MA, LN |
843 |
|
844 |
Property: TR |
845 |
Propvalue: list of point |
846 |
Propertytype: - |
847 |
Function: Marks the given points with a triangle. |
848 |
Points must be unique. |
849 |
Related: MA, CR, LB, SL, AR, LN |
850 |
|
851 |
Root properties |
852 |
|
853 |
Property: AP |
854 |
Propvalue: composed simpletext simpletext |
855 |
Propertytype: root |
856 |
Function: Provides the name and version number of the application used |
857 |
to create this gametree. |
858 |
The name should be unique and must not be changed for |
859 |
different versions of the same program. |
860 |
The version number itself may be of any kind, but the format |
861 |
used must ensure that by using an ordinary string-compare, |
862 |
one is able to tell if the version is lower or higher |
863 |
than another version number. |
864 |
Here's the list of known applications and their names: |
865 |
|
866 |
Application System Name |
867 |
--------------------------- ----------- -------------------- |
868 |
[CGoban:1.6.2] Unix CGoban |
869 |
[Hibiscus:2.1] Windows 95 Hibiscus Go Editor |
870 |
[IGS:5.0] Internet Go Server |
871 |
[Many Faces of Go:10.0] Windows 95 The Many Faces of Go |
872 |
[MGT:?] DOS/Unix MGT |
873 |
[NNGS:?] Unix No Name Go Server |
874 |
[Primiview:3.0] Amiga OS3.0 Primiview |
875 |
[SGB:?] Macintosh Smart Game Board |
876 |
[SmartGo:1.0] Windows SmartGo |
877 |
|
878 |
Related: FF, GM, SZ, ST, CA |
879 |
|
880 |
Property: CA |
881 |
Propvalue: simpletext |
882 |
Propertytype: root |
883 |
Function: Provides the used charset for SimpleText and Text type. |
884 |
Default value is 'ISO-8859-1' aka 'Latin1'. |
885 |
Only charset names (or their aliases) as specified in RFC 1345 |
886 |
(or updates thereof) are allowed. |
887 |
Basically this field uses the same names as MIME messages in |
888 |
their 'charset=' field (in Content-Type). |
889 |
RFC's can be obtained via FTP from DS.INTERNIC.NET, |
890 |
NIS.NSF.NET, WUARCHIVE.WUSTL.EDU, SRC.DOC.IC.AC.UK |
891 |
or FTP.IMAG.FR. |
892 |
Related: FF, C, text type |
893 |
|
894 |
Property: FF |
895 |
Propvalue: number (range: 1-4) |
896 |
Propertytype: root |
897 |
Function: Defines the used file format. For difference between those |
898 |
formats have a look at the history of SGF. |
899 |
Default value: 1 |
900 |
Applications must be able to deal with different file formats |
901 |
within a collection. |
902 |
Related: GM, SZ, ST, AP, CA |
903 |
|
904 |
Property: GM |
905 |
Propvalue: number (range: 1-16) |
906 |
Propertytype: root |
907 |
Function: Defines the type of game, which is stored in the current |
908 |
gametree. The property should help applications |
909 |
to reject games, they cannot handle. |
910 |
Valid numbers are: Go = 1, Othello = 2, chess = 3, |
911 |
Gomoku+Renju = 4, Nine Men's Morris = 5, Backgammon = 6, |
912 |
Chinese chess = 7, Shogi = 8, Lines of Action = 9, |
913 |
Ataxx = 10, Hex = 11, Jungle = 12, Neutron = 13, |
914 |
Philosopher's Football = 14, Quadrature = 15, Trax = 16, |
915 |
Tantrix = 17, Amazons = 18, Octi = 19, Gess = 20. |
916 |
Default value: 1 |
917 |
Different kind of games may appear within a collection. |
918 |
Related: FF, SZ, ST, AP, CA |
919 |
|
920 |
Property: ST |
921 |
Propvalue: number (range: 0-3) |
922 |
Propertytype: root |
923 |
Function: Defines how variations should be shown (this is needed to |
924 |
synchronize the comments with the variations). If ST is omitted |
925 |
viewers should offer the possibility to change the mode online. |
926 |
Basically most programs show variations in two ways: |
927 |
as markup on the board (if the variation contains a move) |
928 |
and/or as a list (in a separate window). |
929 |
The style number consists two options. |
930 |
1) show variations of successor node (children) (value: 0) |
931 |
show variations of current node (siblings) (value: 1) |
932 |
affects markup & list |
933 |
2) do board markup (value: 0) |
934 |
no (auto-) board markup (value: 2) |
935 |
affects markup only. |
936 |
Using no board markup could be used in problem collections |
937 |
or if variations are marked by subsequent properties. |
938 |
Viewers should take care, that the automatic variation |
939 |
board markup DOESN'T overwrite any markup of other |
940 |
properties. |
941 |
The final number is calculated by adding the values of each |
942 |
option. Example: 3 = no board markup/variations of current node |
943 |
1 = board markup/variations of current node |
944 |
Default value: 0 |
945 |
Related: C, FF, GM, SZ, AP, CA |
946 |
|
947 |
Property: SZ |
948 |
Propvalue: number |
949 |
Propertytype: root |
950 |
Function: Defines the size of the board. If only a single value |
951 |
is given, the board is a square; with two numbers given, |
952 |
rectangular boards are possible. |
953 |
If a rectangular board is specified, the first number specifies |
954 |
the number of columns, the second provides the number of rows. |
955 |
Square boards must not be defined using the compose type |
956 |
value: e.g. SZ[19:19] is illegal. |
957 |
The valid range for SZ is any size greater or equal to 1x1. |
958 |
For Go games the maximum size is limited to 52x52. |
959 |
Default value: game specific |
960 |
for Go: 19 (square board) |
961 |
for Chess: 8 (square board) |
962 |
Different board sizes may appear within a collection. |
963 |
See move-/point-type for more info. |
964 |
Related: FF, GM, ST, AP, CA |
965 |
|
966 |
Game info properties |
967 |
|
968 |
Property: AN |
969 |
Propvalue: simpletext |
970 |
Propertytype: game-info |
971 |
Function: Provides the name of the person, who made the annotations |
972 |
to the game. |
973 |
Related: US, SO, CP |
974 |
|
975 |
Property: BR |
976 |
Propvalue: simpletext |
977 |
Propertytype: game-info |
978 |
Function: Provides the rank of the black player. |
979 |
For Go (GM[1]) the following format is recommended: |
980 |
"..k" or "..kyu" for kyu ranks and |
981 |
"..d" or "..dan" for dan ranks. |
982 |
Go servers may want to add '?' for an uncertain rating and |
983 |
'*' for an established rating. |
984 |
Related: PB, BT, WR |
985 |
|
986 |
Property: BT |
987 |
Propvalue: simpletext |
988 |
Propertytype: game-info |
989 |
Function: Provides the name of the black team, if game was part of a |
990 |
team-match (e.g. China-Japan Supermatch). |
991 |
Related: PB, PW, WT |
992 |
|
993 |
Property: CP |
994 |
Propvalue: simpletext |
995 |
Propertytype: game-info |
996 |
Function: Any copyright information (e.g. for the annotations) should |
997 |
be included here. |
998 |
Related: US, SO, AN |
999 |
|
1000 |
Property: DT |
1001 |
Propvalue: simpletext |
1002 |
Propertytype: game-info |
1003 |
Function: Provides the date when the game was played. |
1004 |
It is MANDATORY to use the ISO-standard format for DT. |
1005 |
Note: ISO format implies usage of the Gregorian calendar. |
1006 |
Syntax: |
1007 |
"YYYY-MM-DD" year (4 digits), month (2 digits), day (2 digits) |
1008 |
Do not use other separators such as "/", " ", "," or ".". |
1009 |
Partial dates are allowed: |
1010 |
"YYYY" - game was played in YYYY |
1011 |
"YYYY-MM" - game was played in YYYY, month MM |
1012 |
For games that last more than one day: separate other dates |
1013 |
by a comma (no spaces!); following shortcuts may be used: |
1014 |
"MM-DD" - if preceded by YYYY-MM-DD, YYYY-MM, MM-DD, MM or DD |
1015 |
"MM" - if preceded by YYYY-MM or MM |
1016 |
"DD" - if preceded by YYYY-MM-DD, MM-DD or DD |
1017 |
Shortcuts acquire the last preceding YYYY and MM (if |
1018 |
necessary). |
1019 |
Note: interpretation is done from left to right. |
1020 |
Examples: |
1021 |
1996-05,06 = played in May,June 1996 |
1022 |
1996-05-06,07,08 = played on 6th,7th,8th May 1996 |
1023 |
1996,1997 = played in 1996 and 1997 |
1024 |
1996-12-27,28,1997-01-03,04 = played on 27th,28th |
1025 |
of December 1996 and on 3rd,4th January 1997 |
1026 |
Note: it's recommended to use shortcuts whenever possible, |
1027 |
e.g. 1997-05-05,06 instead of 1997-05-05,1997-05-06 |
1028 |
Related: EV, RO, PC, RU, RE, TM |
1029 |
|
1030 |
Property: EV |
1031 |
Propvalue: simpletext |
1032 |
Propertytype: game-info |
1033 |
Function: Provides the name of the event (e.g. tournament). |
1034 |
Additional information (e.g. final, playoff, ..) |
1035 |
shouldn't be included (see RO). |
1036 |
Related: GC, RO, DT, PC, RU, RE, TM |
1037 |
|
1038 |
Property: GN |
1039 |
Propvalue: simpletext |
1040 |
Propertytype: game-info |
1041 |
Function: Provides a name for the game. The name is used to |
1042 |
easily find games within a collection. |
1043 |
The name should therefore contain some helpful information |
1044 |
for identifying the game. 'GameName' could also be used |
1045 |
as the file-name, if a collection is split into |
1046 |
single files. |
1047 |
Related: GC, EV, DT, PC, RO, ID |
1048 |
|
1049 |
Property: GC |
1050 |
Propvalue: text |
1051 |
Propertytype: game-info |
1052 |
Function: Provides some extra information about the following game. |
1053 |
The intend of GC is to provide some background information |
1054 |
and/or to summarize the game itself. |
1055 |
Related: GN, ON, AN, CP |
1056 |
|
1057 |
Property: ON |
1058 |
Propvalue: simpletext |
1059 |
Propertytype: game-info |
1060 |
Function: Provides some information about the opening played |
1061 |
(e.g. san-ren-sei, Chinese fuseki, etc.). |
1062 |
Related: GN, GC |
1063 |
|
1064 |
Property: OT |
1065 |
Propvalue: simpletext |
1066 |
Propertytype: game-info |
1067 |
Function: Describes the method used for overtime (byo-yomi). |
1068 |
Examples: "5 mins Japanese style, 1 move / min", |
1069 |
"25 moves / 10 min". |
1070 |
Related: TM, BL, WL, OB, OW |
1071 |
|
1072 |
Property: PB |
1073 |
Propvalue: simpletext |
1074 |
Propertytype: game-info |
1075 |
Function: Provides the name of the black player. |
1076 |
Related: PW, BT, WT |
1077 |
|
1078 |
Property: PC |
1079 |
Propvalue: simpletext |
1080 |
Propertytype: game-info |
1081 |
Function: Provides the place where the games was played. |
1082 |
Related: EV, DT, RO, RU, RE, TM |
1083 |
|
1084 |
Property: PW |
1085 |
Propvalue: simpletext |
1086 |
Propertytype: game-info |
1087 |
Function: Provides the name of the white player. |
1088 |
Related: PB, BT, WT |
1089 |
|
1090 |
Property: RE |
1091 |
Propvalue: simpletext |
1092 |
Propertytype: game-info |
1093 |
Function: Provides the result of the game. It is MANDATORY to use the |
1094 |
following format: |
1095 |
"0" (zero) or "Draw" for a draw (jigo), |
1096 |
"B+" ["score"] for a black win and |
1097 |
"W+" ["score"] for a white win |
1098 |
Score is optional (some games don't have a score e.g. chess). |
1099 |
If the score is given it has to be given as a real value, |
1100 |
e.g. "B+0.5", "W+64", "B+12.5" |
1101 |
Use "B+R" or "B+Resign" and "W+R" or "W+Resign" for a win by |
1102 |
resignation. Applications must not write "Black resigns". |
1103 |
Use "B+T" or "B+Time" and "W+T" or "W+Time" for a win on time, |
1104 |
"B+F" or "B+Forfeit" and "W+F" or "W+Forfeit" for a win by |
1105 |
forfeit, |
1106 |
"Void" for no result or suspended play and |
1107 |
"?" for an unknown result. |
1108 |
|
1109 |
Related: EV, DT, PC, RO, RU, TM |
1110 |
|
1111 |
Property: RO |
1112 |
Propvalue: simpletext |
1113 |
Propertytype: game-info |
1114 |
Function: Provides round-number and type of round. It should be |
1115 |
written in the following way: RO[xx (tt)], where xx is the |
1116 |
number of the round and (tt) the type: |
1117 |
final, playoff, league, ... |
1118 |
Related: EV, DT, PC, RU, RE, TM |
1119 |
|
1120 |
Property: RU |
1121 |
Propvalue: simpletext |
1122 |
Propertytype: game-info |
1123 |
Function: Provides the used rules for this game. |
1124 |
Because there are many different rules, SGF requires |
1125 |
mandatory names only for a small set of well known rule sets. |
1126 |
Note: it's beyond the scope of this specification to give an |
1127 |
exact specification of these rule sets. |
1128 |
Mandatory names for Go (GM[1]): |
1129 |
"AGA" (rules of the American Go Association) |
1130 |
"GOE" (the Ing rules of Goe) |
1131 |
"Japanese" (the Nihon-Kiin rule set) |
1132 |
"NZ" (New Zealand rules) |
1133 |
|
1134 |
Related: EV, DT, PC, RO, RE, TM |
1135 |
|
1136 |
Property: SO |
1137 |
Propvalue: simpletext |
1138 |
Propertytype: game-info |
1139 |
Function: Provides the name of the source (e.g. book, journal, ...). |
1140 |
Related: US, AN, CP |
1141 |
|
1142 |
Property: TM |
1143 |
Propvalue: real |
1144 |
Propertytype: game-info |
1145 |
Function: Provides the time limits of the game. |
1146 |
The time limit is given in seconds. |
1147 |
Related: EV, DT, PC, RO, RU, RE |
1148 |
|
1149 |
Property: US |
1150 |
Propvalue: simpletext |
1151 |
Propertytype: game-info |
1152 |
Function: Provides the name of the user (or program), who entered |
1153 |
the game. |
1154 |
Related: SO, AN, CP |
1155 |
|
1156 |
Property: WR |
1157 |
Propvalue: simpletext |
1158 |
Propertytype: game-info |
1159 |
Function: Provides the rank of the white player. For recommended |
1160 |
format see BR. |
1161 |
Related: PW, WT, BR |
1162 |
|
1163 |
Property: WT |
1164 |
Propvalue: simpletext |
1165 |
Propertytype: game-info |
1166 |
Function: Provide the name of the white team, if game was part of a |
1167 |
team-match (e.g. China-Japan Supermatch). |
1168 |
Related: PB, PW, BT |
1169 |
|
1170 |
Timing properties |
1171 |
|
1172 |
Property: BL |
1173 |
Propvalue: real |
1174 |
Propertytype: move |
1175 |
Function: Time left for black, after the move was made. |
1176 |
Value is given in seconds. |
1177 |
Related: TM, OT, WL, OB, OW |
1178 |
|
1179 |
Property: OB |
1180 |
Propvalue: number |
1181 |
Propertytype: move |
1182 |
Function: Number of black moves left (after the move of this node was |
1183 |
played) to play in this byo-yomi period. |
1184 |
Related: TM, OT, BL, WL, OW |
1185 |
|
1186 |
Property: OW |
1187 |
Propvalue: number |
1188 |
Propertytype: move |
1189 |
Function: Number of white moves left (after the move of this node was |
1190 |
played) to play in this byo-yomi period. |
1191 |
Related: TM, OT, BL, WL, OB |
1192 |
|
1193 |
Property: WL |
1194 |
Propvalue: real |
1195 |
Propertytype: move |
1196 |
Function: Time left for white after the move was made. |
1197 |
Value is given in seconds. |
1198 |
Related: TM, OT, BL, OB, OW |
1199 |
|
1200 |
Miscellaneous properties |
1201 |
|
1202 |
Property: FG |
1203 |
Propvalue: composed number SimpleText |
1204 |
Propertytype: - |
1205 |
Function: The figure property is used to divide a game into |
1206 |
different figures for printing: a new figure starts at the |
1207 |
node containing a figure property. |
1208 |
If the value is not empty then |
1209 |
- Simpletext provides a name for the diagram |
1210 |
- Number specifies some flags (for printing). |
1211 |
These flags are: |
1212 |
- coordinates on/off (value: 0/1) |
1213 |
- diagram name on/off (value: 0/2) |
1214 |
- list moves not shown in figure on/off (value: 0/4) |
1215 |
Some moves can't be shown in a diagram (e.g. ko |
1216 |
captures in Go) - these moves may be listed as text. |
1217 |
- remove captured stones on/off (value: 0/256) |
1218 |
'remove off' means: keep captured stones in the |
1219 |
diagram and don't overwrite stones played earlier - |
1220 |
this is the way diagrams are printed in books. |
1221 |
'remove on' means: capture and remove the stones from |
1222 |
the display - this is the usual viewer mode. |
1223 |
This flag is specific to Go (GM[1]). |
1224 |
- hoshi dots on/off (value: 0/512) |
1225 |
This flag is specific to Go (GM[1]). |
1226 |
- Ignore flags on/off (value: 32768) |
1227 |
If on, then all other flags should be ignored and |
1228 |
the application should use its own defaults. |
1229 |
The final number is calculated by summing up all flag values. |
1230 |
E.g. 515 = coordinates and diagram name off, remove captured |
1231 |
stones, list unshown moves, hoshi dots off; |
1232 |
257 = coordinates off, diagram name on, list unshown moves, |
1233 |
don't remove captured stones, hoshi dots on. |
1234 |
(this is how diagrams are printed in e.g. Go World) |
1235 |
Note: FG combined with VW, MN and PM are mighty tools to print |
1236 |
and compile diagrams. |
1237 |
Related: MN, PM, VW |
1238 |
|
1239 |
Property: PM |
1240 |
Propvalue: number |
1241 |
Propertytype: inherit |
1242 |
Function: This property is used for printing. |
1243 |
It specifies how move numbers should be printed. |
1244 |
0 ... don't print move numbers |
1245 |
1 ... print move numbers as they are |
1246 |
2 ... print 'modulo 100' move numbers |
1247 |
This mode is usually used in books or magazines. |
1248 |
Note: Only the first move number is calculated |
1249 |
'modulo 100' and the obtained number is increased |
1250 |
for each move in the diagram. |
1251 |
E.g. A figure containing moves |
1252 |
32-78 is printed as moves 32-78 |
1253 |
102-177 is printed as moves 2-77 |
1254 |
67-117 is printed as moves 67-117 |
1255 |
154-213 is printed as moves 54-113 |
1256 |
Default value: 1 |
1257 |
Related: MN, FG |
1258 |
|
1259 |
Property: VW |
1260 |
Propvalue: elist of point |
1261 |
Propertytype: inherit |
1262 |
Function: View only part of the board. The points listed are |
1263 |
visible, all other points are invisible. |
1264 |
Note: usually the point list is given in compressed |
1265 |
format (see 'point' type)! |
1266 |
Points have to be unique. |
1267 |
Have a look at the picture to get an idea. |
1268 |
VW[] clears any setting, i.e. the whole board is |
1269 |
visible again. |
1270 |
Related: DD, PM, FG |
1271 |
|
1272 |
Go properties |
1273 |
Restrictions: TW and TB points must be unique, i.e. it's illegal to list the same point in TB and TW within the same node. |
1274 |
Gametype: 1 |
1275 |
|
1276 |
Property: HA |
1277 |
Propvalue: number |
1278 |
Propertytype: game-info |
1279 |
Function: Defines the number of handicap stones (>=2). |
1280 |
If there is a handicap, the position should be set up with |
1281 |
AB within the same node. |
1282 |
HA itself doesn't add any stones to the board, nor does |
1283 |
it imply any particular way of placing the handicap stones. |
1284 |
Related: KM, RE, RU |
1285 |
|
1286 |
Property: KM |
1287 |
Propvalue: real |
1288 |
Propertytype: game-info |
1289 |
Function: Defines the komi. |
1290 |
Related: HA, RE, RU |
1291 |
|
1292 |
Property: TB |
1293 |
Propvalue: elist of point |
1294 |
Propertytype: - |
1295 |
Function: Specifies the black territory or area (depends on |
1296 |
rule set used). |
1297 |
Points must be unique. |
1298 |
Related: TW |
1299 |
|
1300 |
Property: TW |
1301 |
Propvalue: elist of point |
1302 |
Propertytype: - |
1303 |
Function: Specifies the white territory or area (depends on |
1304 |
rule set used). |
1305 |
Points must be unique. |
1306 |
Related: TB |
1307 |
|
1308 |
Octi properties |
1309 |
Gametype: 19 |
1310 |
|
1311 |
Property: RU (rules) |
1312 |
Propvalue: simpletext |
1313 |
Propertytype: game-info |
1314 |
Function: Valid values are one major variation ("full", "fast", |
1315 |
or "kids") followed by a colon and a comma separated |
1316 |
elist of variations ("edgeless", "superprong", etc.). |
1317 |
|
1318 |
The colon may be omitted if either side is empty. |
1319 |
The default is 2-player full, no variations. |
1320 |
The 4-player game is not currently available. |
1321 |
|
1322 |
Property: BO (black octisquares) |
1323 |
Propvalue: list of point |
1324 |
Propertytype: game-info |
1325 |
Function: The position of Black's octi squares. Black will be |
1326 |
setup with one empty pod on each of these points. |
1327 |
It is illegal to list the same point twice. |
1328 |
Traditionally, Black sits at the south end of the board. |
1329 |
Related: WO |
1330 |
|
1331 |
Property: WO (white octisquares) |
1332 |
Propvalue: list of point |
1333 |
Propertytype: game-info |
1334 |
Function: The position of White's octi squares. White will be |
1335 |
setup with one empty pod on each of these points. |
1336 |
It is illegal to list the same point twice. |
1337 |
Traditionally, White sits at the north end of the board. |
1338 |
Related: BO |
1339 |
|
1340 |
Property: NP (number of prongs) |
1341 |
Propvalue: number |
1342 |
Propertytype: game-info |
1343 |
Function: This is the number of prongs each players has at the |
1344 |
start of the game. |
1345 |
The default will be derived from the rules. |
1346 |
Related: NR |
1347 |
|
1348 |
Property: NR (number of reserve) |
1349 |
Propvalue: number |
1350 |
Propertytype: game-info |
1351 |
Function: This is the number of pods in each players reserve at |
1352 |
the start of the game. |
1353 |
The default will be derived from the rules. |
1354 |
Related: NP, NS |
1355 |
|
1356 |
Property: NS (number of superprongs) |
1357 |
Propvalue: number |
1358 |
Propertytype: game-info |
1359 |
Function: This is the number of superprongs each players has at |
1360 |
the start of the game. |
1361 |
The default will be derived from the rules. |
1362 |
Related: NR |
1363 |
|
1364 |
Property: AS (arrow stone) |
1365 |
Propvalue: list of composed stone ':' point |
1366 |
Propertytype: - |
1367 |
Function: Most of the same restriction from AR apply. |
1368 |
The same arrow must not occur twice; however, two arrows |
1369 |
from different stones at the same point may have arrows |
1370 |
to the same destination. Single point arrows are also |
1371 |
illegal. |
1372 |
Related: AR |
1373 |
|
1374 |
Property: CS (circle stone) |
1375 |
Propvalue: list of stone |
1376 |
Propertytype: - |
1377 |
Function: Marks the given stones, each with a circle. |
1378 |
Related: CR |
1379 |
|
1380 |
Property: MS (mark stone) |
1381 |
Propvalue: list of stone |
1382 |
Propertytype: - |
1383 |
Function: Marks the given stones, each with an ex. |
1384 |
Related: MA |
1385 |
|
1386 |
Property: SS (square stone) |
1387 |
Propvalue: list of stone |
1388 |
Propertytype: - |
1389 |
Function: Marks the given stones, each with a square. |
1390 |
Related: SQ |
1391 |
|
1392 |
Property: TS (triangle stone) |
1393 |
Propvalue: list of stone |
1394 |
Propertytype: - |
1395 |
Function: Marks the given stones, each with a triangle. |
1396 |
Related: TR |
1397 |
|
1398 |
Property: RP (remove pod) |
1399 |
Propvalue: list of stone |
1400 |
Propertytype: setup |
1401 |
Function: Removes a stone from the board. |
1402 |
More selective than AddEmpty. |
1403 |
Related: AE |
1404 |
|
1405 |
Backgammon properties |
1406 |
Gametype: 6 |
1407 |
|
1408 |
Property: CO |
1409 |
Propvalue: simpletext |
1410 |
Propertytype: setup |
1411 |
Function: Set the position of the doubling cube. The value |
1412 |
should be `b' (black), `w' (white), `c' (centred), or `n' |
1413 |
(none -- for cubeless or Crawford games). |
1414 |
Related: CV |
1415 |
|
1416 |
Property: CV |
1417 |
Propvalue: number |
1418 |
Propertytype: setup |
1419 |
Function: Set the value of the doubling cube. This value |
1420 |
defaults to 1 at the beginning of the game, but a CV property |
1421 |
should be added when setting up a position where a double has |
1422 |
been made, or at the beginning of a money game if automatic |
1423 |
doubles occur. |
1424 |
Related: CP |
1425 |
|
1426 |
Property: DI |
1427 |
Propvalue: number |
1428 |
Propertytype: setup |
1429 |
Function: Set the dice without moving (this could be useful for |
1430 |
creating problem positions, e.g. DI[31]) |
1431 |
Related: CO |
1432 |
|
1433 |
Property: MI |
1434 |
Propvalue: list of composed simpletext ':' simpletext |
1435 |
Propertytype: game-info |
1436 |
Function: Specifies information about the match the game belongs to. |
1437 |
This property should specify a list of tag/value pairs, where |
1438 |
the allowable tags are case-insensitive, and include: |
1439 |
|
1440 |
length - the match length (number of points); value should |
1441 |
be a number |
1442 |
game - the number of this game within the match (the |
1443 |
first game is 1); value should be a number |
1444 |
bs - the score for Black at the start of the game; |
1445 |
value should be a number |
1446 |
ws - the score for White at the start of the game; |
1447 |
value should be a number |
1448 |
|
1449 |
Unknown tags should be ignored (a warning may be produced). |
1450 |
The order of tags in the list is not significant. An example |
1451 |
MI property is: |
1452 |
MI[length:7][game:3][ws:2][bs:1] |
1453 |
Related: EV, GN, RE, RO |
1454 |
|
1455 |
Property: RE |
1456 |
Propvalue: simpletext |
1457 |
Propertytype: game-info |
1458 |
Function: The general RE property has the following |
1459 |
modification in backgammon games: in the case of a |
1460 |
resignation, the value should also specify the number of |
1461 |
points before the R(esign). Here are three example RE |
1462 |
properties: |
1463 |
|
1464 |
RE[B+6R] -- White resigns a backgammon on a 2 |
1465 |
cube (worth 6 points). |
1466 |
RE[W+2Resign] -- Black resigns a gammon on a 1 cube |
1467 |
(worth 2 points). |
1468 |
RE[W+4] -- Black drops a redouble to 8 (note |
1469 |
this is considered a normal loss, not |
1470 |
a resignation). |
1471 |
Related: RE |
1472 |
|
1473 |
Property: RU |
1474 |
Propvalue: simpletext |
1475 |
Propertytype: game-info |
1476 |
Function: Backgammon-specific values for the general RU property |
1477 |
include the following: |
1478 |
|
1479 |
[Crawford] -- the Crawford rule is being used in this match, |
1480 |
although this is not the Crawford game. |
1481 |
[Crawford:CrawfordGame] -- this IS the Crawford game. |
1482 |
[Jacoby] -- the Jacoby rule is in use for this game. |
1483 |
Related: RU |
1484 |
|
1485 |
Lines of Action properties |
1486 |
Gametype: 9 |
1487 |
|
1488 |
Property: AS |
1489 |
Propvalue: SimpleText |
1490 |
Propertytype: - |
1491 |
Function: Adding stones - the color of the player who is adding |
1492 |
stones to the board. The valid strings are 'Black', 'White' |
1493 |
or 'None'. The puropse of this property is to define a |
1494 |
board position where the human is expected to continue placing |
1495 |
stones on the board through some user interface. |
1496 |
|
1497 |
Property: IP |
1498 |
Propvalue: SimpleText |
1499 |
Propertytype: game-info |
1500 |
Function: Designates the initial position in the game to be |
1501 |
displayed by the viewer. |
1502 |
The only value currently supported is 'End', which causes |
1503 |
the viewer to initially display the final position of the game. |
1504 |
The default is to display the position after setup but before |
1505 |
any moves. |
1506 |
|
1507 |
Property: IY |
1508 |
Propvalue: SimpleText |
1509 |
Propertytype: game-info |
1510 |
Function: Invert Y axis. Values are 'true' or 'false'. |
1511 |
If 'true', the board should be displayed with numbers |
1512 |
increasing in value from bottom to top of the screen. |
1513 |
Default: 'false' |
1514 |
|
1515 |
Property: SE |
1516 |
Propvalue: point |
1517 |
Propertytype: - |
1518 |
Function: Mark the given point and up to 8 additional points, |
1519 |
depending on where the provided point (stone) could legally |
1520 |
move. |
1521 |
|
1522 |
Property: SU |
1523 |
Propvalue: SimpleText |
1524 |
Propertytype: game-info |
1525 |
Function: Setup type - designates the intial placement of pieces, |
1526 |
and also the implicitly the variation on the basic rules to be |
1527 |
employed. The currently valid values include the following |
1528 |
strings: |
1529 |
'Standard', 'Scrambled-eggs', 'Parachute', 'Gemma' and 'Custom' |
1530 |
(the initial board is empty, AB and AW properties |
1531 |
will be used to establish the starting position). |
1532 |
Default: 'Standard' |
1533 |
For details on the setups and rule variations, consult the |
1534 |
LOA home pages. |
1535 |
|
1536 |
Hex properties |
1537 |
Gametype: 11 |
1538 |
|
1539 |
Property: IS |
1540 |
Propvalue: list of composed SimpleText ':' SimpleText |
1541 |
Propertytype: root |
1542 |
Function: This property allows applications to store and read |
1543 |
an initial viewer setting. The property value is a list of |
1544 |
"keyword followed by ':' followed by either 'on' or 'off'". |
1545 |
Valid keywords are: |
1546 |
'tried' - identify future moves that have been tried? |
1547 |
'marked' - show good/bad move markings? |
1548 |
'lastmove' - identify the last cell played? |
1549 |
'headings' - display column/row headings (a b.., 1 2..)? |
1550 |
'lock' - lock the game against new moves (for analysis)? |
1551 |
This property is allowed in the root node only. |
1552 |
Example: IS[tried:on][lock:off][marked:off] |
1553 |
|
1554 |
Property: IP |
1555 |
Propvalue: SimpleText |
1556 |
Propertytype: game-info |
1557 |
Function: Designates the initial position that the viewer |
1558 |
should display. It will most frequently indicate the |
1559 |
current position of play in the game. This is necessary |
1560 |
because future possible moves may have been explored, |
1561 |
and the user must be able to distinguish real moves |
1562 |
actually made from exploratory moves. More than one IP[] |
1563 |
property in a game is illegal, and the behaviour undefined. |
1564 |
The property value should be empty (""); it is specified |
1565 |
as SimpleText for compatibility. |
1566 |
|
1567 |
Amazons properties |
1568 |
Gametype: 18 |
1569 |
|
1570 |
Property: AA |
1571 |
Propvalue: list of point |
1572 |
Propertytype: setup |
1573 |
Function: Adding arrows to the board. This can be used to set up |
1574 |
positions or problems. |
1575 |
|
1576 |
End: this marks the end |
1577 |
|