def get_next_move(node): if not node.next: return None props = node.next.properties if 'W' in props: return pc(props['W'][0]) else: return pc(props['B'][0])
def handle_node(pos, node): 'A node can either add B+W stones, play as B, or play as W.' props = node.properties black_stones_added = [pc(coords) for coords in props.get('AB', [])] white_stones_added = [pc(coords) for coords in props.get('AW', [])] if black_stones_added or white_stones_added: return add_stones(pos, black_stones_added, white_stones_added) # If B/W props are not present, then there is no move. But if it is present and equal to the empty string, then the move was a pass. elif 'B' in props: black_move = pc(props.get('B', [''])[0]) return pos.play_move(black_move, color=go.BLACK) elif 'W' in props: white_move = pc(props.get('W', [''])[0]) return pos.play_move(white_move, color=go.WHITE) else: return pos