def get_handicap(sgf): """ sgfファイルの初期ハンディキャップを適用した盤を返す Parameters ---------- sgf : str sgfの棋譜データコンテンツ Returns ------- game_state : GameState ハンディキャップ適用後の盤 first_move_done : bool ハンディキャップ適用があったか(盤面が空でないか) """ go_board = Board(19, 19) first_move_done = False move = None game_state = GameState.new_game(19) if sgf.get_handicap() != None and sgf.get_handicap() != 0: for setup in sgf.get_root().get_setup_stones(): for move in setup: row, col = move go_board.place_stone(Player.black, Point(row + 1, col + 1)) first_move_done = True game_state = GameState(go_board, Player.white, None, move) return game_state, first_move_done
def get_handicap(self, sgf): go_board = Board(19, 19) first_move_done = False game_state = GameState.new_game(19) if sgf.get_handicap() != None and sgf.get_handicap() != 0: for setup in sgf.get_root().get_setup_stones(): for move in setup: row, col = move go_board.place_stone(Player.black, Point(row + 1, col + 1)) first_move_done = True game_state = GameState(go_board, Player.white, None, move) return game_state, first_move_done
def game(self) -> GameState: if not self._game: black = batch_translate_labels_to_coordinates(self.initial_black) white = batch_translate_labels_to_coordinates(self.initial_white) move_points = batch_translate_labels_to_coordinates(self.moves) player = Player.black if self.initial_player == 'b' else Player.white board = Board(19, 19) for b in black: board.place_stone(Player.black, b) for w in white: board.place_stone(Player.white, w) self._game = GameState(board, player, None, None) for move_point in move_points: move = Move.pass_turn() if not move_point else Move.play( move_point) self._game = self._game.apply_move(move) return self._game
def get_handicap(sgf): # Get handicap stones go_board = Board(19, 19) first_move_done = False move = None game_state = GameState.new_game(19) board_ext = Board_Ext(game_state.board) if sgf.get_handicap() is not None and sgf.get_handicap() != 0: for setup in sgf.get_root().get_setup_stones(): for move in setup: row, col = move go_board.place_stone(Player.black, Point(row + 1, col + 1)) # black gets handicap #My inserting Nail point = Point(row + 1, col + 1) ret = board_ext.place_stone_ext( go_board, 'b', point) # Handicap for black Player #### Nail first_move_done = True game_state = GameState(go_board, Player.white, None, move) return game_state, first_move_done, board_ext