def generate_game(board_size, rounds, max_moves, temperature): boards, moves = [], [] encoder = get_encoder_by_name('oneplane', board_size) game = goboard.GameState.new_game(board_size) bot = mcts.MCTSAgent(rounds, temperature) num_moves = 0 while not game.is_over(): print_board(game.board) move = bot.select_move(game) # <5> if move.is_play: boards.append(encoder.encode(game)) # <6> move_one_hot = np.zeros(encoder.num_points()) move_one_hot[encoder.encode_point(move.point)] = 1 moves.append(move_one_hot) # <7> print_move(game.next_player, move) game = game.apply_move(move) # <8> num_moves += 1 if num_moves > max_moves: # <9> break return np.array(boards), np.array(moves)
def __init__(self, encoder='simple', data_directory='data', count_stones_debute=None, count_stones_middle=None, count_stones_end=None): self.encoder_string = encoder self.encoder = get_encoder_by_name(encoder, 19) self.data_dir = data_directory self.count_stones_debute = count_stones_debute # Nail counts stones on board debute self.count_stones_middle = count_stones_middle # Nail counts stones on board middle self.count_stones_end = count_stones_end # Nail counts stones on board end
def generate_game(board_size, rounds, max_moves, temperature): # In `boards` we store encoded board state, `moves` is for encoded moves. boards, moves = [], [] # We initialize a OnePlaneEncoder by name with given board size. encoder = get_encoder_by_name('oneplane', board_size) # An new game of size `board_size` is instantiated. game = goboard.GameState.new_game(board_size) # A Monte Carlo tree search agent with specified number of rounds and temperature will serve as our bot. bot = mcts.MCTSAgent(rounds, temperature) num_moves = 0 while not game.is_over(): print_board(game.board) # The next move is selected by the bot. move = bot.select_move(game) if move.is_play: boards.append(encoder.encode( game)) # The encoded board situation is appended to `boards`. move_one_hot = np.zeros(encoder.num_points()) move_one_hot[encoder.encode_point(move.point)] = 1 moves.append( move_one_hot ) # The one-hot-encoded next move is appended to `moves`. print_move(game.next_player, move) game = game.apply_move( move) # Afterwards the bot move is applied to the board. num_moves += 1 if num_moves > max_moves: # continue with the next move, unless the maximum number of moves has been reached break return np.array(boards), np.array(moves)
def __init__(self, encoder='train', data_directory='data'): self.encoder_string = encoder self.encoder = get_encoder_by_name(encoder, 19) self.data_dir = data_directory
def __init__( self, encoder='oneplane', data_directory='D:\\CODE\\Python\\Go\\code\\dlgo\\data\\tarfiles'): self.encoder = get_encoder_by_name(encoder, 19) self.data_dir = data_directory
def __init__(self, encoder='simple', data_directory='data'): self.encoder_string = encoder self.encoder = get_encoder_by_name(encoder, 19) fpath = os.path.join(CODE_ROOT_DIR, data_directory) self.data_dir = fpath
def __init__(self, encoder='oneplane', data_directory=DATA_DIRECTORY): self.encoder = get_encoder_by_name(encoder, 19) self.data_dir = data_directory
def __init__(self, encoder='oneplane', data_directory='data'): self.encoder = get_encoder_by_name(encoder, 19) self.data_dir = data_directory
def __init__(self, encoder='simple', data_directory='datasets'): self.encoder_string = encoder self.encoder = get_encoder_by_name(encoder, 19) self.data_dir = data_directory
def __init__(self, encoder='simple', data_directory=DATA_DIRECTORY): # process_zipを行い,ファイルを特徴量とラベルに変換するエンコーダ self.encoder_string = encoder self.encoder = get_encoder_by_name(encoder, 19) self.data_dir = data_directory