コード例 #1
0
    def test_explicity_difficulty_setting(self):
        # Set task difficulty explicitly and confirm target and lure size is fixed.
        self.assertEqual(PointToTargetContent.difficulty_range, 3)

        content = PointToTargetContent(difficulty=0)
        self.assertEqual(content.target_sprite.width, 0.2)
        self.assertEqual(content.lure_sprite.width, 0.1)
コード例 #2
0
    def test_step(self):
        content = PointToTargetContent()

        step_size = 180 * 60

        for i in range(step_size):
            x = np.random.uniform(low=-1.0, high=1.0)
            y = np.random.uniform(low=-1.0, high=1.0)
            local_focus_pos = [x, y]
            reward, done, info = content.step(local_focus_pos)
            self.assertGreaterEqual(reward, 0)
            if i == (step_size - 1):
                # At the last frame, done becomes True
                self.assertTrue(done)
            else:
                # Otherwise done is False
                self.assertFalse(done)
コード例 #3
0
    def test_reset(self):
        content = PointToTargetContent()
        env = Environment(content)

        obs = env.reset()

        image = obs['screen']
        angle = obs['angle']

        self.assertTrue(type(image) is np.ndarray)
        self.assertEqual(image.shape, (128, 128, 3))
        self.assertEqual(len(angle), 2)
コード例 #4
0
    def test_plus_target_confolict(self):
        # Check conflict with random location and plus target region
        content = PointToTargetContent()

        for i in range(100):
            for j in range(4):
                target_width = 0.1
                pos = content.quadrants[j].get_random_location(target_width)
                x = pos[0]
                y = pos[1]
                # Check whether random location pos is not inside the plus marker
                inside_plus_marker = x > -0.15 and x < 0.15 and y > -0.15 and y < 0.15
                self.assertFalse(inside_plus_marker)
コード例 #5
0
    def test_step(self):
        content = PointToTargetContent()
        env = Environment(content)

        action = np.array([0.0, 0.0])
        obs, reward, done, _ = env.step(action)

        image = obs['screen']
        angle = obs['angle']

        self.assertTrue(type(image) is np.ndarray)
        self.assertEqual(image.shape, (128, 128, 3))
        self.assertEqual(len(angle), 2)

        self.assertTrue(type(reward) is int)
        self.assertTrue(type(done) is bool)