diff --git a/examples/training_navigation.py b/examples/training_navigation.py index c1182074731725091630df0f3753b2c55d0280b2..9fc83242fb4880ea6dff712100f73edf2e1ec109 100644 --- a/examples/training_navigation.py +++ b/examples/training_navigation.py @@ -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) diff --git a/flatland/core/env_observation_builder.py b/flatland/core/env_observation_builder.py index 6c6f84eb50d8e1c2264cf9ffba7d37ffe064b3e5..9953392bb7dc690ba2372994d306a99c877b537e 100644 --- a/flatland/core/env_observation_builder.py +++ b/flatland/core/env_observation_builder.py @@ -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