Skip to content
Snippets Groups Projects
Commit 845de14c authored by u214892's avatar u214892
Browse files

a_star with sets instead of lists: cleanup

parent 87776b32
No related branches found
No related tags found
No related merge requests found
......@@ -144,10 +144,7 @@ def a_star(rail_trans, rail_array, start, end):
prev_pos = None
for new_pos in [(0, -1), (0, 1), (-1, 0), (1, 0)]:
node_pos = (current_node.pos[0] + new_pos[0], current_node.pos[1] + new_pos[1])
if node_pos[0] >= rail_shape[0] or \
node_pos[0] < 0 or \
node_pos[1] >= rail_shape[1] or \
node_pos[1] < 0:
if node_pos[0] >= rail_shape[0] or node_pos[0] < 0 or node_pos[1] >= rail_shape[1] or node_pos[1] < 0:
continue
# validate positions
......@@ -315,8 +312,7 @@ def get_rnd_agents_pos_tgt_dir_on_rail(rail, num_agents):
valid_starting_directions = []
for m in valid_movements:
new_position = get_new_position(agents_position[i], m[1])
if m[0] not in valid_starting_directions and \
_path_exists(rail, new_position, m[0], agents_target[i]):
if m[0] not in valid_starting_directions and _path_exists(rail, new_position, m[0], agents_target[i]):
valid_starting_directions.append(m[0])
if len(valid_starting_directions) == 0:
......
......@@ -4,18 +4,14 @@
Tests for `flatland` package.
"""
from flatland.envs.rail_env import RailEnv, random_rail_generator
import numpy as np
#<<<<<<< HEAD
#=======
# import os
#>>>>>>> dc2fa1ee0244b15c76d89ab768c5e1bbd2716147
import sys
import matplotlib.pyplot as plt
import numpy as np
import flatland.utils.rendertools as rt
from flatland.envs.observations import TreeObsForRailEnv
from flatland.envs.rail_env import RailEnv, random_rail_generator
def checkFrozenImage(oRT, sFileImage, resave=False):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment