From 0c9a575f101c9a9732e1f43f07c713d0bab85cb0 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 7 Mar 2013 02:39:22 +0100 Subject: [PATCH] tools/sgf2gtp.py: Graceful handling of SGFs without black/white setup --- tools/sgf2gtp.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tools/sgf2gtp.py b/tools/sgf2gtp.py index a0d01cc..6c0f87d 100755 --- a/tools/sgf2gtp.py +++ b/tools/sgf2gtp.py @@ -78,18 +78,20 @@ def process_gametree(gametree, fout): if handicap and handicap != '0': print >>fout, "fixed_handicap", handicap player_next, player_other = player_other, player_next - for item in setup_black: - x, y = item - if x >= 'i': - x = chr(ord(x)+1) - y = str(col2num(y, board_size)) - print >>fout, "play B", x+y - for item in setup_white: - x, y = item - if x >= 'i': - x = chr(ord(x)+1) - y = str(col2num(y, board_size)) - print >>fout, "play W", x+y + if setup_black: + for item in setup_black: + x, y = item + if x >= 'i': + x = chr(ord(x)+1) + y = str(col2num(y, board_size)) + print >>fout, "play B", x+y + if setup_white: + for item in setup_white: + x, y = item + if x >= 'i': + x = chr(ord(x)+1) + y = str(col2num(y, board_size)) + print >>fout, "play W", x+y def print_game_step(coord): if is_pass_move(coord, board_size): -- 2.11.4.GIT