sgfutils

The package sgfutils contains a few command line utilities that help working with SGF files that describe go (igo, weiqi, baduk) games. This page is about sgfx.

See also sgf, sgfcharset, sgfcheck, sgfcmp, sgfdb, sgfdbinfo, sgfinfo, sgfmerge, sgfsplit, sgfstrip, sgftf, sgftopng, sgfvarsplit, ugi2sgf.

sgfx

% sgfx [options] [input]

The utility sgfx reads a single SGF file, and reports on the number of games, the number of variations, the number of moves in each variation, the properties (e.g. labels or comments) for a given move, the moves following a given move, etc.

The input file is the only non-option parameter if there is one. Otherwise input is read from stdin. This utility operates on a single game, and if the input is a multi-game file, then -g asks for the number of games in the input file, and -g12 selects game number 12 from the input.

Options:

--
Following parameters are filenames, not options.
-after ab,cd,ef
This is an option with a single parameter that is a sequence of moves starting at the current move (or the start of the game). Select the move in the tree (if any) reached by playing this sequence.
-d
Print the number of the first move where the current variation differs from the previous.
-flatten
Select the current variation only, turning the variation tree into a linear game.
-g
Print the number of games in the input file.
-g7
Select game number 7 in the input file. (By default the first game is used.)
-M
Print the current move.
-m
Print the number of moves in the current variation.
-m12
Select move #12. Default is move #0, the root node.
-pm
Print the numbers of the moves in the current variation that have additional properties (other than the move itself, e.g. labels or comments).
-prop
Print the properties (tags) for the current move.
-propXY
Print the value of property XY for the current move. E.g., -propC will print a comment.
-q
Quiet: suppress some informative messages.
-replies
Print the replies to the current move discussed in this file.
-s", "
Define the separator for the output of multiple values via -propXY.
-showtree
Print the move numbers of the tree of variations.
-v
Print the number of variations in the current game.
-v5
Select variation 5 in the current game. (By default the first variation is used.)
-x
Synonym for -g.

For example,

% cat prob0.sgf
(;SZ[7]AB[ab][bb][cb][da][db]AW[ac][bc][cc][dc][ea][eb][ec]PL[W]
C[W kan kill the B group. How?]
(;W[ba]C[Correct])
(;W[aa];B[ba]C[B lives])
(;W[ca];B[ba]C[B lives])
(;W[gg]C[Really?]))

% sgfx -g prob0.sgf
1 game

% sgfx -v prob0.sgf
4 variations

% sgfx -v1 -m prob0.sgf
1 move

% sgfx -m0 -prop prob0.sgf
SZ AB AW PL C

% sgfx -m0 -propAB prob0.sgf
ab, bb, cb, da, db

% sgfx -propAB -s: prob0.sgf
ab:bb:cb:da:db

% sgfx -propPL -propC prob0.sgf
W
W kan kill the B group. How?

% sgfx -replies prob0.sgf
ba aa ca gg

% sgfx -after ba -prop prob0.sgf
W C

% sgfx -after ba -propC prob0.sgf
Correct

% sgfx -after aa -replies prob0.sgf
ba

% sgfx -after aa,ba -propC prob0.sgf
B lives