Commit 8cec2335 authored by Erik Nygren's avatar Erik Nygren
Browse files

updated action behavior at curve. deviation left and right not allowed at curve

parent 482a73e5
Pipeline #459 failed with stage
in 1 minute and 52 seconds
......@@ -112,7 +112,7 @@ for trials in range(1, n_trials + 1):
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)
#env.obs_builder.util_print_obs_subtree(tree=obs[a], num_features_per_node=5)
# Environment step
next_obs, all_rewards, done, _ = env.step(action_dict)
for a in range(env.number_of_agents):
......
......@@ -340,7 +340,7 @@ 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)")
print("WRONG CELL TYPE detected in tree-search (0 transitions possible) at cell",position[0], position[1] )
last_isTerminal = True
break
......
......@@ -998,7 +998,7 @@ class RailEnv(Environment):
for i in range(len(self.agents_handles)):
handle = self.agents_handles[i]
transition_isValid = None
if handle not in action_dict:
continue
......@@ -1027,9 +1027,13 @@ class RailEnv(Environment):
movement = direction
if action == 1:
movement = direction - 1
if nbits <= 2:
transition_isValid == False
elif action == 3:
movement = direction + 1
if nbits <= 2:
transition_isValid == False
if movement < 0:
movement += 4
if movement >= 4:
......@@ -1089,9 +1093,10 @@ class RailEnv(Environment):
else:
new_cell_isValid = False
transition_isValid = self.rail.get_transition(
(pos[0], pos[1], direction),
movement) or is_deadend
if transition_isValid == None:
transition_isValid = self.rail.get_transition(
(pos[0], pos[1], direction),
movement) or is_deadend
cell_isFree = True
for j in range(self.number_of_agents):
......
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