def test_discretized(self): n = 11 min_action = -10.0 max_action = 10.0 space = Discretized(n, min_action, max_action) random_action = space.sample() self.assertGreaterEqual(random_action, 0) self.assertLess(random_action, n) expected_value = min_action step = (max_action - min_action) / (n - 1) for action in range(n): continuous_action = space.to_continuous(action) self.assertAlmostEqual(continuous_action, expected_value) expected_value += step
def doom_action_space_full_discretized(with_use=False): """ MOVE_FORWARD MOVE_BACKWARD MOVE_RIGHT MOVE_LEFT SELECT_WEAPON1 SELECT_WEAPON2 SELECT_WEAPON3 SELECT_WEAPON4 SELECT_WEAPON5 SELECT_WEAPON6 SELECT_WEAPON7 ATTACK SPEED TURN_LEFT_RIGHT_DELTA """ spaces = [ Discrete(3), # noop, forward, backward Discrete(3), # noop, move right, move left Discrete(8), # noop, select weapons 1-7 Discrete(2), # noop, attack Discrete(2), # noop, sprint ] if with_use: spaces.append(Discrete(2)) # noop, use spaces.append(Discretized( 21, min_action=-12.5, max_action=12.5)) # turning using discretized continuous control return gym.spaces.Tuple(spaces)
def doom_action_space_discretized_no_weap(): return gym.spaces.Tuple(( Discrete(3), # noop, forward, backward Discrete(3), # noop, move right, move left Discrete(2), # noop, attack Discrete(2), # noop, sprint Discretized( 11, min_action=-10.0, max_action=10.0), # turning using discretized continuous control ))