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 sgfcmp.

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

sgfcmp

% sgfcmp [options] file1 file2
The program sgfcmp reads two SGF files and compares the games (not the metadata). It will try to recognize rotated, reflected, or truncated versions of games.

Options:

-1
Single-line output (instead of 1 difference per line).
-A
Output moves like B14 instead of bf.
-q
Quiet: output only the first difference.
-s
Straight, simple: just output the differences. Don't try to match boards by rotations or reflections.
-m#
Output at most # (an integer) differences. Default is 10.
-a
Output all differences.
-sz#
Set board size to #. Default is 19.
--
Can be used to end the option list (in case filenames start with -).
Single-symbol options can be combined.

Examples:

% sgfcmp 1.sgf 2.sgf
#42:  kb lb
#43:  jb kb
#46:  lb ma

% sgf -1A 1.sgf 2.sgf
moves 42-43,46 : L18,K18,M18 vs M18,L18,N19

% sgfcmp 1.sgf 1.sgf
identical

% sgfcmp 1.sgf 3.sgf
different games

% sgfcmp -1s 1.sgf 3.sgf
moves 1-10,... : pd,dd,pq,dp,fq,cn,jp,qn,qp,qk vs qd,qq,dc,de,co,cc,dq,oc,ld,pg

% sgfcmp 1.sgf 1a.sgf
comparing  1.sgf  with the result of 'sgftf -rot270 < 1a.sgf':
identical

% sgfcmp 1.sgf 1b.sgf
comparing  1.sgf  with the result of 'sgftf -hflip < 1b.sgf':
files have 78 and 76 moves
identical truncations to 76 moves

% sgfcmp 6.sgf 10.sgf
common: moves 1-123
common: moves 124-125 / 126-127: em,bn
common: moves 126-127 / 124-125: dp,dr
common: moves 128-148
game 2: moves 149-150: fj,ej
common: moves 149-184 / 151-186: ll,nh,ji,ng,pf,ki,oi,ni,kg,ol,...