Esempio n. 1
0
    def test_zero_q_function_should_return_vector(self):
        # Given
        q_function = ZeroQFunction()
        state = State([])
        two_actions = Actions("Do Nothing", "Do Something")
        three_actions = Actions("Do Nothing", "Do Something",
                                "Do Something else")

        # When
        two_q_values = q_function.evaluate(state, two_actions)
        three_q_values = q_function.evaluate(state, three_actions)

        # Check
        assert len(two_q_values) == 2
        assert len(three_q_values) == 3
Esempio n. 2
0
    def test_Actions_should_supports_indexing(self):
        # Given
        actions = Actions("Hello", "World")

        # Check
        assert actions[0] == "Hello"
        assert actions[1] == "World"
Esempio n. 3
0
    def test_agent_should_return_decision(self):
        # Given
        agent = Agent()

        # When
        actions = Actions("do nothing")
        decision = agent.choose_best_action(actions)

        # Assert
        assert decision == "do nothing"
Esempio n. 4
0
    def test_empty_action_set_should_be_empty(self):
        # Given
        actions = Actions()

        # Check
        assert actions.is_empty()
Esempio n. 5
0
    def test_non_empty_action_set_shouldnt_be_empty(self):
        # Given
        actions = Actions("Hello")

        # Check
        assert not actions.is_empty()
Esempio n. 6
0
def state_to_actions(state):
    _, speed = state
    if speed > 0:
        return Actions(*[0.1 * i for i in range(11)])
    else:
        return Actions()
Esempio n. 7
0
def state_to_empty_actions(state):
    return Actions()