Commit 3aced3b7 authored by u214892's avatar u214892
Browse files

#44 bugfix sparse generator

parent 8bbf5b62
......@@ -422,9 +422,9 @@ class GridTransitionMap(TransitionMap):
# Check the adjacent cell is within bounds
# if not, then this transition is invalid!
if np.any(gPos2 < 0):
return False
if np.any(gPos2 >= grcMax):
return False
# Get the transitions out of gPos2, using iDirOut as the inbound direction
# if there are no available transitions, ie (0,0,0,0), then rcPos is invalid
......@@ -11,6 +11,7 @@ import numpy as np
from flatland.core.env import Environment
from flatland.core.grid.grid4_utils import get_new_position
from flatland.core.transition_map import GridTransitionMap
from flatland.envs.agent_utils import EnvAgentStatic, EnvAgent
from flatland.envs.generators import random_rail_generator
from flatland.envs.observations import TreeObsForRailEnv
......@@ -132,7 +133,7 @@ class RailEnv(Environment):
self.rail_generator = rail_generator
self.rail = None
self.rail: GridTransitionMap = None
self.width = width
self.height = height
......@@ -222,6 +223,12 @@ class RailEnv(Environment):
if regen_rail or self.rail is None:
self.rail = tRailAgents[0]
self.height, self.width = self.rail.grid.shape
for r in range(self.height):
for c in range(self.width):
rcPos = (r, c)
check = self.rail.cell_neighbours_valid(rcPos, True)
if not check:
print("WARNING: Invalid grid at {} -> {}".format(rcPos, check))
if replace_agents:
self.agents_static = EnvAgentStatic.from_lists(*tRailAgents[1:5])
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