# Prepare game black_model.set_team(BLACK) white_model.set_team(WHITE) ## PLAY_GAME_REGION Go_Game = GameState() # board size = 19 # History buffers white_win_prob_history_buffer = [] black_win_prob_history_buffer = [] move_history_history_buffer = [] # Start from black move_count = 0 while (True): current_player = Go_Game.get_current_player() # - Calculate Proper action # - Append prob_history if (move_count != -1): if (current_player is BLACK): action, win_prob = black_model.get_move_debug(BLACK, Go_Game, debug_mode=1) black_win_prob_history_buffer.append(win_prob) print("Black win prob is : ", str(win_prob), " value (-1 ~ 1)") else: action, win_prob = white_model.get_move_debug(WHITE, Go_Game,
def Game_Collosseum( black_model, white_model, game_count, add_sample=True, debug_mode=0): # Debug mode 0 means it will not use debugging print("Enter Collosseum") Go_Game = GameState() # board size = 19 # History buffers white_win_prob_history_buffer = [] black_win_prob_history_buffer = [] move_history_buffer = [] # First player is black black_inputs_array = [] white_inputs_array = [] black_spot_prob = [] white_spot_prob = [] try: while (True): current_player = Go_Game.get_current_player() # - Calculate Proper action # - Append prob_history if (current_player is BLACK): action, win_prob, _, board_input, spot_prob = black_model.get_move( BLACK, Go_Game, game_count, debug_mode=debug_mode) black_win_prob_history_buffer.append(win_prob) black_inputs_array.append(board_input) black_spot_prob.append(spot_prob) print("Black win prob is : ", str(win_prob), " , ", str(win_prob), " value (-1 ~ 1)") else: action, win_prob, _, board_input, spot_prob = white_model.get_move( WHITE, Go_Game, game_count, debug_mode=debug_mode) white_win_prob_history_buffer.append(win_prob) white_inputs_array.append(board_input) white_spot_prob.append(spot_prob) print("White win prob is : ", str(win_prob), " , ", str(1 - win_prob), " value (-1 ~ 1)") # - Append move_history move_history_buffer.append(action) # - Act move & get results # - Break while if game is finished if (set_move(Go_Game, action) is True): winner, black_score, white_score = Go_Game.get_winner() board = np.array(Go_Game.show_result()) break # - Draw game's current state(Board) board = np.array(Go_Game.show_result()) Draw_Plot(board) # - Add sample if (add_sample is True): black_model.add_samples(black_inputs_array, black_spot_prob) white_model.add_samples(white_inputs_array, white_spot_prob) # - End of collosseum del Go_Game return winner, board, move_history_buffer, black_win_prob_history_buffer, white_win_prob_history_buffer, black_score, white_score # Exception (Error handling) except KeyboardInterrupt: return