ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Games-Go-SGF-Grove/Grove.pm
Revision: 1.18
Committed: Thu Jul 24 08:39:21 2008 UTC (15 years, 11 months ago) by elmex
Branch: MAIN
Changes since 1.17: +2 -2 lines
Log Message:
fixed off by one

File Contents

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