def decide(self, state: State): while True: print('Possible actions:') print( format_in_action_grid( {action: str(action) for action in Action.iter_actions()}, cell_format='{:.2s}', default_value=' ')) user_input = input('Choose your action: ') try: action = Action.from_hex(user_input) if action in state.allowed_actions: print() return action else: print('Action %s not allowed' % action) except ValueError: print('User input is not an action')
def _play_game(args): human_player = ConsolePlayer('You') computer_player = AlphaConnectPlayer(args.model_path, 'Computer', time_budget=14500) observers = [ AlphaConnectPrinter(), GameStatePrinter(show_action_history=True) ] if args.human_first: game = TwoPlayerGame(State.empty(), human_player, computer_player, observers) else: game = TwoPlayerGame(State.empty(), computer_player, human_player, observers) if args.actions is not None: for action_hex in args.actions: game.play_action(game.next_player(), Action.from_hex(action_hex)) game.play()
def test_regression_str_with_top_plane_stones(): actions_history = [Action.from_hex(i) for i in '0cf35aa55ae9699663cb8c7447f8ec'] state = State.empty().take_actions(actions_history) str(state)