コード例 #1
0
def test_do_calculate_reward_if_goal_reached():
    env = NavigationGoal()
    env._ranges = np.array([2, 1, 10, 4, 5])
    env._distance_from_goal = 0.01

    reward = env._do_calculate_reward(env._FORWARD)

    assert reward == 200
コード例 #2
0
def test_do_calculate_reward_if_collision():
    env = NavigationGoal()
    env._ranges = np.array([0.5, 1, 0.01, 4, 5])
    env._distance_from_goal = 10

    reward = env._do_calculate_reward(env._FORWARD)

    assert reward == -200
コード例 #3
0
def test_do_check_if_done_false():
    env = NavigationGoal()
    env._ranges = np.array([2, 1, 10, 4, 5])
    env._distance_from_goal = 10

    done = env._do_check_if_done()

    assert not done
コード例 #4
0
def test_do_check_if_done_true_goal_reached():
    env = NavigationGoal()
    env._ranges = np.array([2, 1, 10, 4, 5])
    env._distance_from_goal = 0.01

    done = env._do_check_if_done()

    assert done
コード例 #5
0
def test_do_check_if_done_true_collision():
    env = NavigationGoal()
    env._ranges = np.array([0.5, 1, 0.01, 4, 5])
    env._distance_from_goal = 10

    done = env._do_check_if_done()

    assert done
コード例 #6
0
def test_do_calculate_reward_if_action():
    env = NavigationGoal()
    env._ranges = np.array([2, 1, 10, 4, 5])
    env._distance_from_goal = 1
    env._observation = np.array([2, 1, 10, 4, 5, 3, 0.5])

    reward = env._do_calculate_reward(env._FORWARD)

    assert reward == 20