From 727f7da5f0c7880daa43e39040abcd3fd6c5f6d0 Mon Sep 17 00:00:00 2001 From: Giacomo Spigler <spiglerg@gmail.com> Date: Wed, 19 Jun 2019 13:57:18 +0200 Subject: [PATCH] fixed pylint --- flatland/envs/agent_utils.py | 9 +++++++-- flatland/envs/rail_env.py | 13 +++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/flatland/envs/agent_utils.py b/flatland/envs/agent_utils.py index 40bca7e..2d07eee 100644 --- a/flatland/envs/agent_utils.py +++ b/flatland/envs/agent_utils.py @@ -34,7 +34,12 @@ class EnvAgentStatic(object): # cell if speed=1, as default) speed_data = attrib(default=dict({'position_fraction': 0.0, 'speed': 1.0, 'transition_action_on_cellexit': 0})) - def __init__(self, position, direction, target, moving=False, speed_data={'position_fraction': 0.0, 'speed': 1.0, 'transition_action_on_cellexit': 0}): + def __init__(self, + position, + direction, + target, + moving=False, + speed_data={'position_fraction': 0.0, 'speed': 1.0, 'transition_action_on_cellexit': 0}): self.position = position self.direction = direction self.target = target @@ -47,7 +52,7 @@ class EnvAgentStatic(object): """ speed_datas = [] for i in range(len(positions)): - speed_datas.append( {'position_fraction': 0.0, 'speed': 1.0, 'transition_action_on_cellexit': 0} ) + speed_datas.append({'position_fraction': 0.0, 'speed': 1.0, 'transition_action_on_cellexit': 0}) return list(starmap(EnvAgentStatic, zip(positions, directions, targets, [False] * len(positions), speed_datas))) def to_list(self): diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py index 090e0cc..43a0766 100644 --- a/flatland/envs/rail_env.py +++ b/flatland/envs/rail_env.py @@ -227,9 +227,13 @@ class RailEnv(Environment): if action != RailEnvActions.DO_NOTHING and action != RailEnvActions.STOP_MOVING: # Now perform a movement. # If the agent is in an initial position within a new cell (agent.speed_data['position_fraction']<eps) - # store the desired action in `transition_action_on_cellexit' (only if the desired transition is allowed! otherwise DO_NOTHING!) - # Then in any case (if agent.moving) and the `transition_action_on_cellexit' is valid, increment the position_fraction by the speed of the agent (regardless of action taken, as long as no STOP_MOVING, but that makes agent.moving=False) - # If the new position fraction is >= 1, reset to 0, and perform the stored transition_action_on_cellexit + # store the desired action in `transition_action_on_cellexit' (only if the desired transition is + # allowed! otherwise DO_NOTHING!) + # Then in any case (if agent.moving) and the `transition_action_on_cellexit' is valid, increment the + # position_fraction by the speed of the agent (regardless of action taken, as long as no + # STOP_MOVING, but that makes agent.moving=False) + # If the new position fraction is >= 1, reset to 0, and perform the stored + # transition_action_on_cellexit if agent.speed_data['position_fraction'] < 0.01: # Is the desired transition valid? @@ -266,7 +270,8 @@ class RailEnv(Environment): # Perform stored action to transition to the next cell - # Now 'transition_action_on_cellexit' will be guaranteed to be valid; it was checked on entering the cell + # Now 'transition_action_on_cellexit' will be guaranteed to be valid; it was checked on entering + # the cell cell_isFree, new_cell_isValid, new_direction, new_position, transition_isValid = \ self._check_action_on_agent(agent.speed_data['transition_action_on_cellexit'], agent) agent.old_direction = agent.direction -- GitLab