def add(self, coords, glyph): """ Add a given glyph to the top of the map at given coordinates. coords - the coordinates at which the glyph should be added. glyph - the glyph to be displayed. """ exc.check_in_array(coords, self.dimensions) if coords in self.__map: self.__map[coords].insert(0, glyph) else: self.__map[coords] = [glyph]
def copy_array_subset(src_nw_corner, dst_nw_corner, block_dims, src_array, dst_array): """ This function differs only from copy_array_subset_lenient in that it raises exceptions whenever the coordinates given refer to squares not actually in the arrays provided. """ exc.check_in_array(src_nw_corner, src_array.shape) exc.check_in_array(dst_nw_corner, dst_array.shape) exc.check_in_array(coordinates.add(coordinates.add(src_nw_corner, block_dims), (-1, -1)), src_array.shape) exc.check_in_array(coordinates.add(coordinates.add(dst_nw_corner, block_dims), (-1, -1)), dst_array.shape) for x in range(block_dims[0]): for y in range(block_dims[1]): dst_array[coordinates.add(dst_nw_corner, (x, y))] = src_array[coordinates.add(src_nw_corner, (x, y))] return