Skip to content
Snippets Groups Projects
Commit 653126fe authored by Erik Nygren's avatar Erik Nygren :bullettrain_front:
Browse files

catchin error with None observation

parent c09f5f01
No related branches found
No related tags found
No related merge requests found
......@@ -64,7 +64,7 @@ env = RailEnv(width=x_dim,
number_of_agents=n_agents,
stochastic_data=stochastic_data, # Malfunction data generator
obs_builder_object=TreeObservation)
env.reset(True, True)
env.reset()
env_renderer = RenderTool(env, gl="PILSVG", )
num_features_per_node = env.obs_builder.observation_dim
......@@ -126,10 +126,12 @@ for trials in range(1, n_trials + 1):
action_dict.update({a: action})
# Environment step
obs, all_rewards, done, _ = env.step(action_dict)
env_renderer.render_env(show=True, show_predictions=True, show_observations=False)
# Build agent specific observations and normalize
for a in range(env.get_num_agents()):
agent_obs[a] = normalize_observation(obs[a], tree_depth, observation_radius=10)
if obs[a]:
agent_obs[a] = normalize_observation(obs[a], tree_depth, observation_radius=10)
if done['__all__']:
......
......@@ -117,8 +117,9 @@ def main(argv):
env_renderer.reset()
# Build agent specific observations
for a in range(env.get_num_agents()):
agent_obs[a] = normalize_observation(obs[a], tree_depth, observation_radius=10)
agent_obs_buffer[a] = agent_obs[a].copy()
if obs[a]:
agent_obs[a] = normalize_observation(obs[a], tree_depth, observation_radius=10)
agent_obs_buffer[a] = agent_obs[a].copy()
# Reset score and done
score = 0
......@@ -150,7 +151,8 @@ def main(argv):
agent_obs_buffer[a] = agent_obs[a].copy()
agent_action_buffer[a] = action_dict[a]
agent_obs[a] = normalize_observation(next_obs[a], tree_depth, observation_radius=10)
if next_obs[a]:
agent_obs[a] = normalize_observation(next_obs[a], tree_depth, observation_radius=10)
score += all_rewards[a] / env.get_num_agents()
......
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