How to use the rlcard.games.uno.game.UnoGame function in rlcard

To help you get started, we’ve selected a few rlcard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github datamllab / rlcard / tests / games / test_uno_game.py View on Github external
def test_get_player_id(self):
        game = Game()
        _, player_id = game.init_game()
        current = game.get_player_id()
        self.assertEqual(player_id, current)
github datamllab / rlcard / tests / games / test_uno_game.py View on Github external
def test_init_game(self):
        game = Game()
        state, _ = game.init_game()
        total_cards = list(state['hand'] + state['others_hand'])
        self.assertGreaterEqual(len(total_cards), 14)
github datamllab / rlcard / tests / games / test_uno_game.py View on Github external
def test_step_back(self):
        game = Game(allow_step_back=True)
        _, player_id = game.init_game()
        action = np.random.choice(game.get_legal_actions())
        game.step(action)
        game.step_back()
        self.assertEqual(game.round.current_player, player_id)
        self.assertEqual(len(game.history), 0)
        success = game.step_back()
        self.assertEqual(success, False)
github datamllab / rlcard / tests / games / test_uno_game.py View on Github external
def test_get_payoffs(self):
        game = Game()
        game.init_game()
        while not game.is_over():
            actions = game.get_legal_actions()
            action = np.random.choice(actions)
            state, _ = game.step(action)
            total_cards = len(state['hand']) + len(state['others_hand']) + len(state['played_cards']) + len(game.round.dealer.deck)
            self.assertEqual(total_cards, 108)
        payoffs = game.get_payoffs()
        total = 0
        for payoff in payoffs:
            total += payoff
        self.assertEqual(total, 0)
github datamllab / rlcard / tests / games / test_uno_game.py View on Github external
def test_get_legal_actions(self):
        game = Game()
        game.init_game()
        actions = game.get_legal_actions()
        for action in actions:
            self.assertIn(action, ACTION_LIST)
github datamllab / rlcard / tests / games / test_uno_game.py View on Github external
def test_get_action_num(self):
        game = Game()
        action_num = game.get_action_num()
        self.assertEqual(action_num, 61)
github datamllab / rlcard / tests / games / test_uno_game.py View on Github external
def test_step(self):
        game = Game()
        game.init_game()
        action = np.random.choice(game.get_legal_actions())
        state, next_player_id = game.step(action)
        current = game.round.current_player
        self.assertLessEqual(len(state['played_cards']), 2)
        self.assertEqual(next_player_id, current)
github datamllab / rlcard / tests / games / test_uno_game.py View on Github external
def test_get_player_num(self):
        game = Game()
        num_player = game.get_player_num()
        self.assertEqual(num_player, 2)
github datamllab / rlcard / rlcard / envs / uno.py View on Github external
def __init__(self, allow_step_back=False):
        super().__init__(Game(allow_step_back), allow_step_back)
        self.state_shape = [7, 4, 15]