Esempio n. 1
0
def _print_action(action):
    ''' Print out an action in a nice form

    Args:
        action (str): A string a action
    '''
    UnoCard.print_cards(action, wild_color=True)
Esempio n. 2
0
 def render(self, mode='human'):
     for player in self.agents:
         state = self.env.game.get_state(self._name_to_int(player))
         print("\n\n=============== {}'s Hand ===============".format(player))
         UnoCard.print_cards(state['hand'])
     print('\n\n================= Target Card =================')
     UnoCard.print_cards(state['target'], wild_color=True)
     print('\n')
Esempio n. 3
0
def _print_state(state, action_record):
    ''' Print out the state of a given player

    Args:
        player (int): Player id
    '''
    _action_list = []
    for i in range(1, len(action_record) + 1):
        if action_record[-i][0] == state['current_player']:
            break
        _action_list.insert(0, action_record[-i])
    for pair in _action_list:
        print('>> Player', pair[0], 'chooses ', end='')
        _print_action(pair[1])
        print('')

    print('\n=============== Your Hand ===============')
    UnoCard.print_cards(state['hand'])
    print('')
    print('=============== Last Card ===============')
    UnoCard.print_cards(state['target'], wild_color=True)
    print('')
    print('========== Players Card Number ===========')
    for i in range(state['num_players']):
        if i != state['current_player']:
            print('Player {} has {} cards.'.format(i, state['num_cards'][i]))
    print('======== Actions You Can Choose =========')
    for i, action in enumerate(state['legal_actions']):
        print(str(i) + ': ', end='')
        UnoCard.print_cards(action, wild_color=True)
        if i < len(state['legal_actions']) - 1:
            print(', ', end='')
    print('\n')
Esempio n. 4
0
    def print_state(self, player):
        ''' Print out the state of a given player

        Args:
            player (int): Player id
        '''
        state = self.game.get_state(player)
        print('\n=============== Your Hand ===============')
        UnoCard.print_cards(state['hand'])
        print('')
        print('=============== Last Card ===============')
        UnoCard.print_cards(state['target'], wild_color=True)
        print('')
        print('========== Agents Card Number ===========')
        for i in range(self.player_num):
            if i != self.active_player:
                print('Agent {} has {} cards.'.format(
                    i, len(self.game.players[i].hand)))
        print('======== Actions You Can Choose =========')
        for i, action in enumerate(state['legal_actions']):
            print(str(ACTION_SPACE[action]) + ': ', end='')
            UnoCard.print_cards(action, wild_color=True)
            if i < len(state['legal_actions']) - 1:
                print(', ', end='')
        print('\n')