Commit 1b084f8f authored by Erik Nygren's avatar Erik Nygren
Browse files

if agent stopps. It's predicted path is reduced to its current position

parent ffa48c3b
Pipeline #1094 failed with stages
in 9 minutes and 40 seconds
......@@ -178,6 +178,7 @@ class TreeObsForRailEnv(ObservationBuilder):
self.predicted_pos = {}
self.predicted_dir = {}
self.predictions = self.predictor.get(self.distance_map)
print(self.predictions)
for t in range(len(self.predictions[0])):
pos_list = []
dir_list = []
......
......@@ -114,12 +114,14 @@ class ShortestPathPredictorForRailEnv(PredictionBuilder):
prediction = np.zeros(shape=(self.max_depth + 1, 5))
prediction[0] = [0, _agent_initial_position[0], _agent_initial_position[1], _agent_initial_direction, 0]
for index in range(1, self.max_depth + 1):
action_done = False
# if we're at the target, stop moving...
if agent.position == agent.target:
prediction[index] = [index, agent.target[0], agent.target[1], agent.direction,
RailEnvActions.STOP_MOVING]
continue
if not agent.moving:
prediction[index] = [index, agent.position[0], agent.position[1], agent.direction,
RailEnvActions.STOP_MOVING]
continue
# Take shortest possible path
cell_transitions = self.env.rail.get_transitions((*agent.position, agent.direction))
......
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