How to use the rlcard.envs.uno.UnoEnv 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 / envs / test_uno_env.py View on Github external
def test_step_back(self):
        env = Env(allow_step_back=True)
        state, player_id = env.init_game()
        action = np.random.choice(state['legal_actions'])
        env.step(action)
        env.step_back()
        self.assertEqual(env.game.round.current_player, player_id)

        env = Env(allow_step_back=False)
        state, player_id = env.init_game()
        action = np.random.choice(state['legal_actions'])
        env.step(action)
        # env.step_back()
        self.assertRaises(Exception, env.step_back)
github datamllab / rlcard / tests / envs / test_uno_env.py View on Github external
def test_human_mode(self):
        env = Env()
        env.set_mode(human_mode=True)
        state = env.reset()
        self.assertIsInstance(state, dict)
        for _ in range(100):
            state, _, _ = env.step(np.random.choice(state['legal_actions']))
github datamllab / rlcard / tests / envs / test_uno_env.py View on Github external
def test_init_game_and_extract_state(self):
        env = Env()
        state, _ = env.init_game()
        self.assertEqual(state['obs'].size, 420)
github datamllab / rlcard / tests / envs / test_uno_env.py View on Github external
def test_single_agent_mode(self):
        env = Env()
        env.set_mode(single_agent_mode=True)
        state = env.reset()
        self.assertIsInstance(state, dict)
        for _ in range(100):
            state, _, _ = env.step(np.random.choice(state['legal_actions']))
github datamllab / rlcard / tests / envs / test_uno_env.py View on Github external
def test_decode_action(self):
        env = Env()
        env.init_game()
        legal_actions = env.get_legal_actions()
        for legal_action in legal_actions:
            decoded = env.decode_action(legal_action)
            self.assertLessEqual(decoded, ACTION_LIST[legal_action])
github datamllab / rlcard / tests / envs / test_uno_env.py View on Github external
def test_get_legal_actions(self):
        env = Env()
        env.set_agents([RandomAgent(61), RandomAgent(61)])
        env.init_game()
        legal_actions = env.get_legal_actions()
        for legal_action in legal_actions:
            self.assertLessEqual(legal_action, 60)
github datamllab / rlcard / tests / envs / test_uno_env.py View on Github external
def test_step(self):
        env = Env()
        state, _ = env.init_game()
        action = np.random.choice(state['legal_actions'])
        _, player_id = env.step(action)
        self.assertEqual(player_id, env.game.round.current_player)
github datamllab / rlcard / tests / envs / test_uno_env.py View on Github external
def test_step_back(self):
        env = Env(allow_step_back=True)
        state, player_id = env.init_game()
        action = np.random.choice(state['legal_actions'])
        env.step(action)
        env.step_back()
        self.assertEqual(env.game.round.current_player, player_id)

        env = Env(allow_step_back=False)
        state, player_id = env.init_game()
        action = np.random.choice(state['legal_actions'])
        env.step(action)
        # env.step_back()
        self.assertRaises(Exception, env.step_back)
github datamllab / rlcard / tests / envs / test_uno_env.py View on Github external
def test_run(self):
        env = Env()
        env.set_agents([RandomAgent(309), RandomAgent(309)])
        trajectories, payoffs = env.run(is_training=False)
        self.assertEqual(len(trajectories), 2)
        total = 0
        for payoff in payoffs:
            total += payoff
        self.assertEqual(total, 0)
        trajectories, payoffs = env.run(is_training=True, seed=1)
        total = 0
        for payoff in payoffs:
            total += payoff
        self.assertEqual(total, 0)