Commit edd0f927 authored by Egli Adrian (IT-SCI-API-PFI)'s avatar Egli Adrian (IT-SCI-API-PFI)
Browse files

test is working.

parent b4acc823
Pipeline #2516 passed with stages
in 41 minutes and 4 seconds
......@@ -199,120 +199,161 @@ def test_get_shortest_paths_max_depth():
def test_get_shortest_paths_agent_handle():
env = load_flatland_environment_from_file('Level_distance_map_shortest_path.pkl', 'env_data.tests')
actual = get_shortest_paths(env.distance_map, agent_handle=3)
actual = get_shortest_paths(env.distance_map, agent_handle=6)
print(actual, file=sys.stderr)
expected = {3:
[WalkingElement(position=(20, 5),
direction=3,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(20, 4), next_direction=3)),
WalkingElement(position=(20, 4),
direction=3,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(20, 3), next_direction=3)),
WalkingElement(position=(20, 3),
direction=3,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(20, 2), next_direction=3)),
WalkingElement(position=(20, 2),
direction=3,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(20, 1), next_direction=3)),
WalkingElement(position=(20, 1),
direction=3,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(20, 0), next_direction=3)),
WalkingElement(position=(20, 0),
direction=3,
expected = {6:
[WalkingElement(position=(5, 5),
direction=0,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(19, 0), next_direction=0)),
WalkingElement(position=(19, 0),
next_position=(4, 5), next_direction=0)),
WalkingElement(position=(4, 5),
direction=0,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(18, 0), next_direction=0)),
WalkingElement(position=(18, 0),
next_position=(3, 5), next_direction=0)),
WalkingElement(position=(3, 5),
direction=0,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(17, 0), next_direction=0)),
WalkingElement(position=(17, 0),
next_position=(2, 5), next_direction=0)),
WalkingElement(position=(2, 5),
direction=0,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(16, 0), next_direction=0)),
WalkingElement(position=(16, 0),
next_position=(1, 5), next_direction=0)),
WalkingElement(position=(1, 5),
direction=0,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(15, 0), next_direction=0)),
WalkingElement(position=(15, 0),
next_position=(0, 5), next_direction=0)),
WalkingElement(position=(0, 5),
direction=0,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(15, 1), next_direction=1)),
WalkingElement(position=(15, 1),
next_position=(0, 6), next_direction=1)),
WalkingElement(position=(0, 6),
direction=1,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(15, 2), next_direction=1)),
WalkingElement(position=(15, 2),
next_position=(0, 7), next_direction=1)),
WalkingElement(position=(0, 7),
direction=1,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(15, 3), next_direction=1)),
WalkingElement(position=(15, 3),
next_position=(0, 8), next_direction=1)),
WalkingElement(position=(0, 8),
direction=1,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(15, 4), next_direction=1)),
WalkingElement(position=(15, 4),
next_position=(0, 9), next_direction=1)),
WalkingElement(position=(0, 9),
direction=1,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(15, 5), next_direction=1)),
WalkingElement(position=(15, 5),
next_position=(0, 10), next_direction=1)),
WalkingElement(position=(0, 10),
direction=1,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(14, 5), next_direction=0)),
WalkingElement(position=(14, 5),
direction=0,
next_position=(1, 10), next_direction=2)),
WalkingElement(position=(1, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(13, 5), next_direction=0)),
WalkingElement(position=(13, 5),
direction=0,
next_position=(2, 10), next_direction=2)),
WalkingElement(position=(2, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(12, 5), next_direction=0)),
WalkingElement(position=(12, 5),
direction=0,
next_position=(3, 10), next_direction=2)),
WalkingElement(position=(3, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(11, 5), next_direction=0)),
WalkingElement(position=(11, 5),
direction=0,
next_position=(4, 10), next_direction=2)),
WalkingElement(position=(4, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(10, 5), next_direction=0)),
WalkingElement(position=(10, 5),
direction=0,
next_position=(5, 10), next_direction=2)),
WalkingElement(position=(5, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(9, 5), next_direction=0)),
WalkingElement(position=(9, 5),
direction=0,
next_position=(6, 10), next_direction=2)),
WalkingElement(position=(6, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(8, 5), next_direction=0)),
WalkingElement(position=(8, 5),
direction=0, next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_RIGHT,
next_position=(8, 6),
next_direction=1)),
WalkingElement(position=(8, 6),
direction=1,
next_position=(7, 10), next_direction=2)),
WalkingElement(position=(7, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(7, 6), next_direction=0)),
WalkingElement(position=(7, 6),
direction=0,
next_position=(8, 10), next_direction=2)),
WalkingElement(position=(8, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(6, 6), next_direction=0)),
WalkingElement(position=(6, 6),
direction=0,
next_position=(9, 10), next_direction=2)),
WalkingElement(position=(9, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(5, 6), next_direction=0)),
WalkingElement(position=(5, 6),
direction=0,
next_position=(10, 10), next_direction=2)),
WalkingElement(position=(10, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(11, 10), next_direction=2)),
WalkingElement(position=(11, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(12, 10), next_direction=2)),
WalkingElement(position=(12, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(13, 10), next_direction=2)),
WalkingElement(position=(13, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(14, 10), next_direction=2)),
WalkingElement(position=(14, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(15, 10), next_direction=2)),
WalkingElement(position=(15, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(16, 10), next_direction=2)),
WalkingElement(position=(16, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(17, 10), next_direction=2)),
WalkingElement(position=(17, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(18, 10), next_direction=2)),
WalkingElement(position=(18, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(19, 10), next_direction=2)),
WalkingElement(position=(19, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(20, 10), next_direction=2)),
WalkingElement(position=(20, 10),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(20, 9), next_direction=3)),
WalkingElement(position=(20, 9),
direction=3,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(20, 8), next_direction=3)),
WalkingElement(position=(20, 8),
direction=3, next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_LEFT,
next_position=(21, 8),
next_direction=2)),
WalkingElement(position=(21, 8),
direction=2,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(21, 7), next_direction=3)),
WalkingElement(position=(21, 7),
direction=3,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(21, 6), next_direction=3)),
WalkingElement(position=(21, 6),
direction=3,
next_action_element=RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD,
next_position=(21, 5), next_direction=3)),
WalkingElement(position=(21, 5),
direction=3,
next_action_element=RailEnvNextAction(action=RailEnvActions.STOP_MOVING,
next_position=(5, 6), next_direction=0))
next_position=(21, 5), next_direction=3))
]}
for agent_handle in expected:
assert np.array_equal(actual[agent_handle], expected[agent_handle]), \
"[{}] actual={},expected={}".format(agent_handle, actual[agent_handle], expected[agent_handle])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment