def create_patches_array(self): patch_pseudo_array = [[ self.patch_class(RowCol((r, c))) for c in range(gui.PATCH_COLS) ] for r in range(gui.PATCH_ROWS)] World.patches_array = np.array(patch_pseudo_array) # .flat is an iterator. Can't use it more than once. World.patches = list(World.patches_array.flat)
def __init__(self, row_col: RowCol, color=Color('black')): super().__init__(row_col.patch_to_center_pixel(), color) self.row_col = row_col self.agents = None self._neighbors_4 = None self._neighbors_8 = None self._neighbors_24 = None
def neighbors(self, deltas): """ The neighbors of this patch determined by the deltas. Note the addition of two RowCol objects to produce a new RowCol object: self.row_col + utils.RowCol(r, c). Wrap around is handled by RowCol. We then use the RowCol object as a tuple to access the np.ndarray """ # noinspection PyUnresolvedReferences neighbors = [World.patches_array[(self.row_col + RowCol((r, c))).wrap().as_int()] for (r, c) in deltas] return neighbors
def __init__(self, row_col: RowCol, color=Color('black')): super.__init__(row_col.patch_to_center_pixel(), color) self.delay = None self.base_delay = None self.road_type = None self.last_here = None
def createpatches_array(self): patch_pseudo_array = [[ self.patch_class(RowCol((r, c))) for c in range(gui.PATCH_COLS) ] for r in range(gui.PATCH_ROWS)] patches_array = np.array(patch_pseudo_array) return patches_array