示例#1
0
    def test_rate_2(self):
        """
        Test with rate=2.
        """
        low = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
        high = np.array([[9, 10, 11, 12], [13, 14, 15, 16]])
        env = DownsampleEnv(ShapeEnv(low, high), 2)
        self.assertEqual(env.observation_space.shape, (1, 2))
        self.assertTrue((env.observation_space.low == np.array([[1, 3]])).all())
        self.assertTrue((env.observation_space.high == np.array([[9, 11]])).all())

        low = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 6, 7, 8]])
        high = np.array([[9, 10, 11, 12], [13, 14, 15, 16], [16, 14, 15, 16]])
        env = DownsampleEnv(ShapeEnv(low, high), 2)
        self.assertEqual(env.observation_space.shape, (2, 2))
        self.assertTrue((env.observation_space.low == np.array([[1, 3], [9, 7]])).all())
        self.assertTrue((env.observation_space.high == np.array([[9, 11], [16, 15]])).all())
示例#2
0
def test_downsample_rate_2():
    """
    Test DownsampleEnv with rate=2.
    """
    low = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
    high = np.array([[9, 10, 11, 12], [13, 14, 15, 16]])
    env = DownsampleEnv(ShapeEnv(low, high), 2)
    assert env.observation_space.shape == (1, 2)
    assert (env.observation_space.low == np.array([[1, 3]])).all()
    assert (env.observation_space.high == np.array([[9, 11]])).all()

    low = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 6, 7, 8]])
    high = np.array([[9, 10, 11, 12], [13, 14, 15, 16], [16, 14, 15, 16]])
    env = DownsampleEnv(ShapeEnv(low, high), 2)
    assert env.observation_space.shape == (2, 2)
    assert (env.observation_space.low == np.array([[1, 3], [9, 7]])).all()
    assert (env.observation_space.high == np.array([[9, 11], [16, 15]])).all()
示例#3
0
 def test_rate_1(self):
     """
     Test with rate=1.
     """
     low = np.array([[1, 2], [3, 4]])
     high = np.array([[3, 4], [5, 6]])
     env = DownsampleEnv(ShapeEnv(low, high), 1)
     self.assertTrue((env.observation_space.low == low).all())
     self.assertTrue((env.observation_space.high == high).all())
示例#4
0
def test_downsample_rate_1():
    """
    Test DownsampleEnv with rate=1.
    """
    low = np.array([[1, 2], [3, 4]])
    high = np.array([[3, 4], [5, 6]])
    env = DownsampleEnv(ShapeEnv(low, high), 1)
    assert (env.observation_space.low == low).all()
    assert (env.observation_space.high == high).all()
示例#5
0
def make_single_env(game):
    """Make a preprocessed gym.Env."""
    if 'MiniGrid' in game:
        env = PreprocessEnv(FullyObsWrapper(gym.make(game)))
    else:
        env = gym.make(game)

    print(
        'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    )

    print('action space: %s obs space: %s' %
          (env.action_space, env.observation_space))
    print(
        'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    )

    #sys.exit()

    return GrayscaleEnv(DownsampleEnv(env, 2))
示例#6
0
def make_single_env(game):
    """Make a preprocessed gym.Env."""
    env = gym.make(game)
    return GrayscaleEnv(DownsampleEnv(env, 2))
示例#7
0
def make_single_env():
    """Make a preprocessed gym.Env."""
    env = gym.make('PongNoFrameskip-v4')
    return FrameStackEnv(GrayscaleEnv(DownsampleEnv(env, 2)), num_images=4)