From f0548db6acfd9616ddafa443e45103fc6655e0e4 Mon Sep 17 00:00:00 2001 From: Tomas Musil Date: Tue, 7 May 2013 22:56:35 +0200 Subject: [PATCH] script for converting ASCII to sgf --- sgf.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 sgf.py diff --git a/sgf.py b/sgf.py new file mode 100644 index 0000000..13543fe --- /dev/null +++ b/sgf.py @@ -0,0 +1,22 @@ +import sys + +coords = 'abcdefghijklmnopqrs' + +board = sys.stdin.read().split('\n') +board = [line.split() for line in board] + +black = [] +white = [] + +for i in range(19): + for j in range(19): + if board[i][j] == 'B': + black.append((i, j)) + elif board[i][j] == 'W': + white.append((i, j)) + +#TODO version numbering +print "(;FF[4]GM[1]SZ[19]AP[Imago:0.1.0]" +print "AB" + ''.join('[' + coords[j] + coords[i] + ']' for (i, j) in black) +print "AW" + ''.join('[' + coords[j] + coords[i] + ']' for (i, j) in white) +print ")" -- 2.4.2