script for converting ASCII to sgf
authorTomas Musil <tomik.musil@gmail.com>
Tue, 7 May 2013 20:56:35 +0000 (22:56 +0200)
committerTomas Musil <tomik.musil@gmail.com>
Tue, 7 May 2013 20:56:35 +0000 (22:56 +0200)
sgf.py [new file with mode: 0644]

diff --git a/sgf.py b/sgf.py
new file mode 100644 (file)
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 ")"