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