Exemplo n.º 1
0
    def test_encode_with_treasure_position_layer(self):
        state = GridWorld(4, 4)
        state.add_object(Treasure(2, 3))

        encoder = OneHotEncoder(4, 4, agent_position=False, treasure_position=True)

        expected = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]

        assert_array_equal(expected, encoder.encode(state))
Exemplo n.º 2
0
 def define_agent(self, width, height, num_actions):
     return NStepDQNAgent(
         config=Config(num_actions=num_actions,
                       encoder=OneHotEncoder(width, height),
                       optimizer=AdamOptimizer(0.01),
                       network=MLP(),
                       policy=EpsilonGreedyPolicy(1, 0.01, 1000),
                       discount=0.95,
                       n_step=8))
Exemplo n.º 3
0
 def define_agent(self, width, height, num_actions):
     return DQNAgent(config=Config(num_actions=num_actions,
                                   encoder=OneHotEncoder(width, height),
                                   optimizer=AdamOptimizer(0.01),
                                   network=MLP(),
                                   policy=EpsilonGreedyPolicy(1, 0.01, 500),
                                   discount=0.95,
                                   capacity=100,
                                   batch_size=16))
Exemplo n.º 4
0
    def test_shape_with_agent_position_layer(self):
        encoder = OneHotEncoder(4, 4, agent_position=True, treasure_position=False)

        self.assertEqual(16, encoder.shape())
Exemplo n.º 5
0
    def test_encode_with_no_layers(self):
        state = GridWorld(4, 4)

        encoder = OneHotEncoder(4, 4, agent_position=False, treasure_position=False)

        assert_array_equal(np.empty(0), encoder.encode(state))
Exemplo n.º 6
0
    def test_shape_with_multiple_layers(self):
        encoder = OneHotEncoder(4, 4, agent_position=True, treasure_position=True)

        self.assertEqual(32, encoder.shape())