Skip to content
Snippets Groups Projects
Commit dcc279a2 authored by Erik Nygren's avatar Erik Nygren
Browse files

added TODO: Tree Observation needs to be adjusted to new transition possibilities.

parent 653c291d
No related branches found
No related tags found
No related merge requests found
......@@ -30,13 +30,13 @@ env = RailEnv(width=20,
rail_generator=complex_rail_generator(nr_start_goal=20, min_dist=10, max_dist=99999, seed=0),
number_of_agents=5)
"""
env = RailEnv(width=20,
height=20,
rail_generator=rail_from_list_of_saved_GridTransitionMap_generator(
['../env-data/tests/circle.npy']),
number_of_agents=1)
"""
env_renderer = RenderTool(env, gl="QT")
handle = env.get_agent_handles()
......@@ -109,7 +109,7 @@ for trials in range(1, n_trials + 1):
for a in range(env.number_of_agents):
if demo:
eps = 0
action = 2 #agent.act(np.array(obs[a]), eps=eps)
action = agent.act(np.array(obs[a]), eps=eps)
action_prob[action] += 1
action_dict.update({a: action})
#env.obs_builder.util_print_obs_subtree(tree=obs[a], num_features_per_node=5)
......
......@@ -243,6 +243,7 @@ class TreeObsForRailEnv(ObservationBuilder):
# Start from the current orientation, and see which transitions are available;
# organize them as [left, forward, right, back], relative to the current orientation
# TODO: Adjust this to the novel movement dynamics --> Only Forward present when one transition is possible.
for branch_direction in [(orientation + 4 + i) % 4 for i in range(-1, 3)]:
if self.env.rail.get_transition((position[0], position[1], orientation), branch_direction):
new_cell = self._new_position(position, branch_direction)
......@@ -342,8 +343,8 @@ class TreeObsForRailEnv(ObservationBuilder):
elif num_transitions == 0:
# Wrong cell type, but let's cover it and treat it as a dead-end, just in case
#print("WRONG CELL TYPE detected in tree-search (0 transitions possible) at cell", position[0],
# position[1], direction)
print("WRONG CELL TYPE detected in tree-search (0 transitions possible) at cell", position[0],
position[1], direction)
last_isTerminal = True
break
......
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