def brushfireFromObstacles(ogm, brush, ogml):
        assert brush.flags["C_CONTIGUOUS"]

        xi, n, m = Cffi.to_double_pointer_copy(ogm)
        yi = ffi.cast('int*', brush.ctypes.data)

        lib.brushfireFromObstacles(xi, yi, n, m, ogml['min_x'], ogml['max_x'],
                                   ogml['min_y'], ogml['max_y'])
        return brush
    def brushfireFromObstacles(ogm, brush, ogml):

        x = [np.array(v, dtype='int32') for v in ogm]
        xi = ffi.new(("int* [%d]") % (len(x)))
        for i in range(len(x)):
            xi[i] = ffi.cast("int *", x[i].ctypes.data)

        y = [np.array(v, dtype='int32') for v in brush]
        yi = ffi.new(("int* [%d]") % (len(y)))
        for i in range(len(y)):
            yi[i] = ffi.cast("int *", y[i].ctypes.data)

        lib.brushfireFromObstacles(xi, yi, len(x), len(x[0]), ogml['min_x'], ogml['max_x'], ogml['min_y'], ogml['max_y'])
        brush = cp_brush(brush, yi, brush.shape[0], brush.shape[1])

        return brush
Esempio n. 3
0
    def brushfireFromObstacles(ogm, brush, ogml):
        #TODO improve: by map limits
        x = [np.array(v, dtype='int32') for v in ogm]
        xi = ffi.new(("int* [%d]") % (len(x)))
        for i in range(len(x)):
            xi[i] = ffi.cast("int *", x[i].ctypes.data)

        y = [np.array(v, dtype='int32') for v in brush]
        yi = ffi.new(("int* [%d]") % (len(y)))
        for i in range(len(y)):
            yi[i] = ffi.cast("int *", y[i].ctypes.data)

        br_c = lib.brushfireFromObstacles(xi, yi, len(x), len(x[0]),
                                          ogml['min_x'], ogml['max_x'],
                                          ogml['min_y'], ogml['max_y'])
        # # TODO: Must be faster!
        # for i in range(ogm.shape[0]):
        #   for j in range(ogm.shape[1]):
        #     brush[i][j] = yi[i][j]
        #
        # Extra challenge #2
        # Optimize targer selection calculations
        brush[:ogm.shape[0], :ogm.shape[1]] = np.array(y)

        return brush
Esempio n. 4
0
    def brushfireFromObstacles(ogm, brush, ogml):
      #TODO improve: by map limits
      x = [np.array(v, dtype='int32') for v in ogm]
      xi = ffi.new(("int* [%d]") % (len(x)))
      for i in range(len(x)):
        xi[i] = ffi.cast("int *", x[i].ctypes.data)

      y = [np.array(v, dtype='int32') for v in brush]
      yi = ffi.new(("int* [%d]") % (len(y)))
      for i in range(len(y)):
        yi[i] = ffi.cast("int *", y[i].ctypes.data)

      br_c = lib.brushfireFromObstacles(xi, yi, len(x), len(x[0]),
          ogml['min_x'], ogml['max_x'], ogml['min_y'], ogml['max_y'])
      # TODO: Must be faster!
      for i in range(ogm.shape[0]):
        for j in range(ogm.shape[1]):
          brush[i][j] = yi[i][j]

      return brush