diff --git a/flatland/envs/agent_utils.py b/flatland/envs/agent_utils.py index bcc0fcc6487e2788a442d4e8681e6a05d464a776..dd639997f2b759e86b0879a84e4ab91f7ffc824b 100644 --- a/flatland/envs/agent_utils.py +++ b/flatland/envs/agent_utils.py @@ -63,19 +63,13 @@ class EnvAgent: def reset(self): self.position = None + # TODO: set direction to None: https://gitlab.aicrowd.com/flatland/flatland/issues/280 self.direction = self.initial_direction self.status = RailAgentStatus.READY_TO_DEPART self.old_position = None self.old_direction = None self.moving = False - def move(self, new_pos: Tuple[int, int], new_dir: Tuple[int, int] = None): - self.old_position = self.position - self.position = new_pos - if new_dir is not None: - self.old_direction = self.direction - self.direction = new_dir - def to_agent(self) -> Agent: return Agent(initial_position=self.initial_position, initial_direction=self.initial_direction, direction=self.direction, target=self.target, moving=self.moving, speed_data=self.speed_data, diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py index f65372747cee474b1dd9e3e943d1f9467ea26970..0dd58813b5568ba95e11f984d15f6bd256100c0f 100644 --- a/flatland/envs/rail_env.py +++ b/flatland/envs/rail_env.py @@ -338,7 +338,7 @@ class RailEnv(Environment): if optionals and 'distance_map' in optionals: self.distance_map.set(optionals['distance_map']) - if regenerate_schedule or regenerate_rail or len(self.agents) == 0: + if regenerate_schedule or regenerate_rail or self.get_num_agents() == 0: agents_hints = None if optionals and 'agents_hints' in optionals: agents_hints = optionals['agents_hints'] diff --git a/flatland/utils/editor.py b/flatland/utils/editor.py index eadea813a47efb36799e68ed87a1cd332f461ede..2a77c960450ec4fbe3aa1ee5dce50d0ab98f9c50 100644 --- a/flatland/utils/editor.py +++ b/flatland/utils/editor.py @@ -701,7 +701,8 @@ class EditorModel(object): else: # Move the selected agent to this cell agent = self.env.agents[self.selected_agent] - agent.move(cell_row_col) + agent.position = cell_row_col + agent.old_position = cell_row_col else: # Yes # Have they clicked on the agent already selected?