def play_sgf(sgf: str) -> Optional[Dict]: try: board_size = int(SZ(sgf)) except: raise Exception('Illegal Board Size %s' % SZ(sgf)) if '(;W[' in sgf or '(;B[' in sgf: raise Exception('Analysis Currently Unsupported') go = Go(board_size) black, white = sgf_add_stones(sgf) print(black, white) for loc in black: go._board[loc] = Go.BLACK for loc in white: go._board[loc] = Go.WHITE # print(go) for p, move in sgf_moves(sgf): # print(p,move) go._turn = p go = go.place(move) # print(go) return { 'board': go, 'RE': RE(sgf), 'WR': WR(sgf), 'BR': BR(sgf), 'SZ': SZ(sgf), }
def _get_go(): try: go = Go(board_size=gamedata()['width']) for x,y,_ in gamedata()['moves']: go = go.place((x,y)) return go except: return Go()