Smart Game Format
|Part of a series of articles on|
|History and culture|
|Players and organizations|
|Computers and mathematics|
|Developed by||Anders Kierulf (1987, FF1), Martin Mueller (1993, FF3), Arno Hollosi (1997, FF4)|
|Type of format||mark up text|
|Container for||Go (game) record|
The Smart Game Format (SGF) is a computer file format used for storing records of board games. Go is the game that is most commonly represented in this format and is the default. SGF was originally created under a different name by Anders Kierulf for his SmartGO program.
The first version of SGF, FF!, was conceived by Anders Kierulf in 1987. It is Appendix A in his Ph.D. thesis (see Definition of the Smart-Go Format). FF! was written by Martin Muller in 1993. The current version of the SGF is FF! by Arno Hollosi, and is supported by most current SGF readers. FF! was never made public.
The main purposes of SGF are to store records of played games and to provide features for storing annotated and analyzed games (e.g. board markup, variations). It is a text-only, tree-based format. The tree structure makes the addition of variations simple. It is also text-based instead of binary for the sake of portability.
About the format
An SGF file is composed of pairs of properties and property values, each of which describes a feature of the game. A partial list of properties appears below. Full information can be found in the Official Guide.
|AB||Add Black: locations of Black stones to be placed on the board prior to the first move|
|AW||Add White: locations of White stones to be placed on the board prior to the first move.|
|AN||Annotations: name of the person commenting the game.|
|AP||Application: application that was used to create the SGF file (e.g. CGOban2,...).|
|B||a move by Black at the location specified by the property value.|
|BR||Black Rank: rank of the Black player.|
|BT||Black Team: name of the Black team.|
|C||Comment: a comment.|
|CP||Copyright: copyright information.|
|DT||Date: date of the game.|
|EV||Event: name of the event (e.g. 58th Honinbō Title Match).|
|FF||File format: version of SGF specification governing this SGF file.|
|GM||Game: type of game represented by this SGF file. A property value of 1 refers to Go.|
|GN||Game Name: name of the game record.|
|HA||Handicap: the number of handicap stones given to Black. Placement of the handicap stones are set using the AB property.|
|ON||Opening: information about the opening (Fuseki), rarely used in any file.|
|OT||Overtime: overtime system.|
|PB||Black Name: name of the black player.|
|PC||Place: place where the game was played (e.g.: Tokyo).|
|PL||Player: color of player to start.|
|PW||White Name: name of the white player.|
|RE||Result: result, usually in the format "B+R" (Black wins by resign) or "B+3.5" (black wins by 3.5).|
|RO||Round: round (e.g.: 5th game).|
|RU||Rules: ruleset (e.g.: Japanese).|
|SO||Source: source of the SGF file.|
|SZ||Size: size of the board, non-square boards are supported.|
|TM||Time limit: time limit in seconds.|
|US||User: name of the person who created the SGF file.|
|W||a move by White at the location specified by the property value.|
|WR||White Rank: rank of the White player.|
|WT||White Team: name of the White team.|
There is no strict checking of the contents of these tags, so it is possible to put any text into the result tag for example.
Variations are nested in brackets, and also usually assigned letters. The first branch (variation A) is the main branch. See Variation Guide.
Coordinate system for points and moves
The first letter designates the column (left to right), the second the row (top to bottom). The upper left part of the board is used for smaller boards, e.g. letters "a"-"m" for 13*13.
The author intentionally broke with the tradition of labeling moves (and points) with letters "A"-"T" (excluding "i") and numbers 1-19. Two lower-case letters in the range "a"-"s" were used instead, for reasons of simplicity and compactness.
(Column before row follows the principle "horizontal before vertical" used in x-y coordinate systems. The upper left corner as origin of the board corresponds to the way we read, and most modern computers use it as the origin of the screen coordinates to simplify integration of text and graphics.)
SGF format example
This is an example of a tsumego problem stored in SGF format. Please note that this example comes from Go Problems. See that site for copyright information. Line breaks are optional and are only for readability.
(;FF!GM!SZ! GN![Copyright goproblems.com] PB![Black] HA! PW![White] KM![5.5] DT![1999-07-21] TM! RU![Japanese] ;AW![bb]![cb]![cc]![cd]![de]![df]![cg]![ch]![dh]![ai]![bi]![ci] AB![ba]![ab]![ac]![bc]![bd]![be]![cf]![bg]![bh] C![Black to play and live.] (;B![af];W![ah] (;B![ce];W![ag]C![only one eye this way]) (;B![ag];W![ce])) (;B![ah];W![af] (;B![ae];W![bf];B![ag];W![bf] (;B![af];W![ce]C![oops! you can't take this stone]) (;B![ce];W![af];B![bg]C![RIGHT black plays under the stones and lives])) (;B![bf];W![ae])) (;B![ae];W![ag]))
Games currently supported are Amazons, Ataxx, Backgammon, Byte, Chase, Chess, DVONN, Exxit, Focus, Gess, GIPF, Go, Gobblet, Gomoku+Renju, Hex, Hive, Hnefatafl, Jungle, Kropki, Kuba, Lines of Action, Neutron, Nine Men's Morris, Octi, Philosopher's Football, Plateau, PÜNCT, Quadrature, Reversi (Othello), Sahara, Shogi, TAMSK, Tantrix, Trax, Tripples, Tumbling Down, TwixT, Xiangqi, YINSH and ZÈRTZ.
- Language: Go is most widely played in China, Japan, and Korea, but the SGF format has no way of specifying different translations for text.
- Metadata: Only a limited, fixed set of metadata can be present, for example, SGF has rank fields, but no way to represent the ranking system in use.