Algorithm | Example tree | pre-order |
WriteTree(Root) End WriteTree(Node) Write(Node) for each child of Node WriteTree(child) end for end | root a b c d e f g h i j | |
SGF | ||
(;FF[4]C[root](;C[a];C[b](;C[c]) (;C[d];C[e])) (;C[f](;C[g];C[h];C[i]) (;C[j]))) |
Have a look at the EBNF definition again. Check the SGF example file and the User Guide for more details, such as problems with annotations and variations. Related properties: ST, C, N.
Here are some examples to make it easier to understand the
EBNF definition and its application to variations.
Pictures taken from cgoban
No Variation | |
(;FF[4]GM[1]SZ[19];B[aa];W[bb];B[cc];W[dd];B[ad];W[bd]) | |
One variation at move 3 | |
(;FF[4]GM[1]SZ[19];B[aa];W[bb](;B[cc];W[dd];B[ad];W[bd]) (;B[hh];W[hg])) | |
Note the beginning of a new game tree in front of B[cc] and the variation itself on the second line. There are two ")" at the end: one for the variation gametree and one for the end of the main gametree starting at FF[4]. | |
Two variations at move 3 | |
(;FF[4]GM[1]SZ[19];B[aa];W[bb](;B[cc]N[Var A];W[dd];B[ad];W[bd]) (;B[hh]N[Var B];W[hg]) (;B[gg]N[Var C];W[gh];B[hh];W[hg];B[kk])) | |
Usually the main line is labeled variation "A", the first variation "B", the second variation "C" and so on. That's why many annotations refer to the next move as "A". | |
Two variations at different moves | |
(;FF[4]GM[1]SZ[19];B[aa];W[bb](;B[cc];W[dd](;B[ad];W[bd]) (;B[ee];W[ff])) (;B[hh];W[hg])) | |
The new gametree starts in front of B[ad]. Note that the second varition (2nd line) is in front of the first variation (3rd line). Have a look at the closing brackets as well. | |
Variation of a variation | |
(;FF[4]GM[1]SZ[19];B[aa];W[bb](;B[cc]N[Var A];W[dd];B[ad];W[bd]) (;B[hh]N[Var B];W[hg]) (;B[gg]N[Var C];W[gh];B[hh] (;W[hg]N[Var A];B[kk]) (;W[kl]N[Var B]))) | |
The new game tree starts in front of W[hg]. Note that there are three ")" at the end: one for the W[kl] variation, one for the B[gg] variation, and one for the main gametree. |
Properties are part of a node, therefore (W[tt]) is an error. Correct is (;W[tt])
No properties outside a gametree! E.g. (;)W[tt] is an error.