예제 #1
0
    def test_scaling(self):
        tc = TileCoder({
            'dims': 2,
            'tilings': 2,
            'tiles': 2,
            'actions': 2,
            'input_ranges': [(-1, 1), (2.1, 4.1)]
        })

        rep = tc.encode([-1, 2.5], 1)
        expected = [
            0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5,
            0.0, 0.0, 0.0
        ]
        self.assertListEqual(list(rep), expected)
예제 #2
0
    def test_encode(self):
        tc = TileCoder({
            'dims': 2,
            'tilings': 2,
            'tiles': 2,
            'actions': 2,
            'scale_output': False,
        })

        rep = tc.encode([0, 0.2], 1)
        expected = [
            0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0,
            0.0, 0.0, 0.0
        ]

        self.assertListEqual(list(rep), expected)