Home Info Statistics Problems Discuss Download Add Problem User
goproblems.com menu

The SGF Format

SGF stands for either Smart Go Format or Smart Game Format. Basically, it's an excellent and standardized way of expressing a go game as a text file, with full support for variations, markup, and even customized formatting tags. A full explanation is beyond the scope of this document, but information can be found here. (Note, it's not necessary to read this or fully understand SGF in order to submit problems to this site.)

Making SGF Files

All popular operating systems have SGF editors free to use. A list can be found at the NNGS links page, under Game Recorders. The Java client Jago will edit SGF files and can run on any modern operating system, and also the Macintosh. cgoban is a great SGF editor, and the new version is Java-based. (The old one, on linux, is excellent. And also open-sourced, unlike the current one.)

Example 1: Simplest

(;
AW[ca][cb][cc][bd][cd]
AB[da][eb][dc][ec][dd][fd][be][ce][de];
B[ab];W[bb];B[ac];W[ad];B[aa]
C[RIGHT]
)

This SGF file was generated by cgoban. This is a very simple problem, with precisely one delineated path leading to a correct solution.

Example 2: Simple Variations

(;
;AW[hh][lh][hi][ji][li][lj]
AB[kg][lg][mg][mh][mi][mj][kk][lk][mk]
C[Black to play and catch the three stones.]
(;B[ki];W[kh]
(;B[jh];W[kj];B[jj];W[ki];B[ii]C[RIGHT])
(;B[kj];W[jh])
)
(;B[jh];W[jj])
(;B[jj];W[jh])
(;B[ii];W[jj])
)

This problem has one correct path (marked RIGHT) and three paths illustrating how other attempts to catch the stones fail.

Requirements

Any problem on goproblems.com has to have at least one node (position) that is marked RIGHT. In other words, there has to be at least one correct solution for each problem. To mark a position as correct, simply put the word RIGHT (caps required) in the comment. (i.e., C[RIGHT]). The RIGHT gets taken out, so the user doesn't see it -- any other text in that comment will still be displayed, however. And basically, that's it. As long as you don't do anything tricky, a problem will come out fine. All variations that don't end in RIGHT are considered wrong, so there's no need to state something's wrong explicitly.

Restrictions

There are actually a lot of restrictions on the tags and formatting of the SGF you can submit, but mostly they're things you wouldn't do anyway, so only read this if you're rather a careful chap.

  • You must alternate colors of moves -- black can't move twice in a row.
  • Once you've reached the point in the tree where moves start, you can no longer have setup commands (like AddWhite) or nodes without moves

Choices

Often there are multiple ways to test someone trying a problem. In other words, solving a problem fully involves knowing how to cope with various responses from the other side. To this end, there exists a method for letting the computer choose randomly from various responses at certain key junctures.

By default, the computer responds with the top branch -- the first branch given in the SGF. To specify which response you desire, or to randomly pick between two or more responses, add the word CHOICE (caps required) to one or more branches. When the problem gets to a point where two or more branched responses have a CHOICE marker somewhere down the line, it will randomly pick between them. For an example of this, see problem 8. After the first correct move by the human, the computer will randomly select between two different responses.

Example
(;AW[hh][lh][hi][ji][li][lj]AB[kg][lg][mg][mh][mi][mj][kk][lk][mk]
C[Black to play and catch the three stones.]
(;B[ki]
(;W[kh]
(;B[jh]
;W[kj]
;B[jj]
;W[ki]
;B[ii]C[RIGHT
CHOICE])
(;B[kj]
;W[jh]))
(;W[kj]
(;B[kh]
;W[jj]
(;B[jj]
;W[kh]
;B[jh]
;W[ki]
;B[ii]C[CHOICE RIGHT
stones are caught
])))
(;B[jh]
;W[jj])
(;B[jj]
;W[jh])
(;B[ii]
;W[jj]))

Understood Tags

goproblems.com understands the following SGF tags (usually encoded as just the capital letters -- eg, AddWhite becomes AW)

  • White
  • Black
  • AddWhite
  • AddBlack
  • Comment
  • LaBel
  • TRiangle
  • MArk (square marker)
  • SiZe (board size)

Tips

  • Place comments either at the computer's move or at the end of a variation -- comments at the player's move won't be seen if the computer automatically responds.
  • End correct variations with the protaganist's move, wrong variations with the antagonist's.

Advanced

A special tag, NOTTHIS, can be added to a problem. This outlaws a certain move. Just add this like you would add RIGHT or CHOICE, and the user will be unable to move in this intersection. This can be used to cut down on extra variations.

Adding FORCE as part of a comment field is the counterpart to NOTTHIS. The problem solver can only play a next move in places the SGF anticipates with a branch.