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

updated agent fixed behavior

parent 31293020
No related branches found
No related tags found
No related merge requests found
......@@ -64,7 +64,8 @@ class EnvAgentStatic(object):
malfunction_datas.append({'malfunction': 0,
'malfunction_rate': schedule.agent_malfunction_rates[i] if schedule.agent_malfunction_rates is not None else 0.,
'next_malfunction': 0,
'nr_malfunctions': 0})
'nr_malfunctions': 0,
'fixed':False})
return list(starmap(EnvAgentStatic, zip(schedule.agent_positions,
schedule.agent_directions,
......
......@@ -407,13 +407,16 @@ class RailEnv(Environment):
return True
# Restart fixed agents
if agent.malfunction_data['malfunction'] < 1 and agent.malfunction_data['next_malfunction'] > 0:
if agent.malfunction_data['malfunction'] < 1 and agent.malfunction_data['next_malfunction'] > 0 and not agent.malfunction_data['fixed']:
agent.malfunction_data['next_malfunction'] -= 1
agent.malfunction_data['fixed'] = True
if 'moving_before_malfunction' in agent.malfunction_data:
self.agents[i_agent].moving = agent.malfunction_data['moving_before_malfunction']
return False
# Agent has been running smoothly
elif agent.malfunction_data['malfunction'] < 1 and agent.malfunction_data['next_malfunction'] > 0:
agent.malfunction_data['next_malfunction'] -= 1
return False
# Break agents that have next_malfunction
if agent.malfunction_data['malfunction'] < 1 and agent.malfunction_data['next_malfunction'] < 1:
......@@ -436,7 +439,7 @@ class RailEnv(Environment):
if agent.malfunction_data['next_malfunction'] > 0 and agent.malfunction_data['malfunction'] < 1:
agent.malfunction_data['next_malfunction'] -= 1
return False
def step(self, action_dict_: Dict[int, RailEnvActions]):
"""
......
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