Fill the board with random tiles based on the Tile class.
356521
def _random_fill(self):
        """"""
        a = self._array
        for p, tile in self.positions_with_tile():
            if tile.is_blank():
                a[p] = Tile.random_tile()
578810
function getBoardWithPieces(board, pieces) {
    return mapBoard(board, function (p) {
        var x = p.x,
            y = p.y;

        var piece = Position.getPositionFromPositions(pieces, p);
        return piece ? { x: x, y: y, isBlack: piece.isBlack } : { x: x, y: y };
    });
}
56660
private static BitSet randomBitSet(int size, int cardinality, Random random) {
        BitSet result = new BitSet(size);
        int[] chosen = new int[cardinality];

        for (int i = 0; i < cardinality; ++i) {
            chosen[i] = i;
            result.set(i);
        }
        for (int i = cardinality; i < size; ++i) {
            int j = random.nextInt(i+1);
            if (j < cardinality) {
                result.clear(chosen[j]);
                result.set(i);
                chosen[j] = i;
            }
        }
        return result;
    }
906029
def expand_seed(self, start_seed, num_iterations, val):
        
        self.grd.set_tile(start_seed[0], start_seed[1], val)
        cur_pos = [start_seed[0], start_seed[1]]
        while num_iterations > 0:   # don't use loop as it will hit boundaries often
            num_iterations -= 1
            for y in range(cur_pos[0]-randint(0,2), cur_pos[0] + randint(0,2)):
                for x in range(cur_pos[1]-randint(0,2), cur_pos[1] + randint(0,2)):
                    if x < self.grd.grid_width and x >= 0 and y >= 0 and y < self.grd.grid_height:
                        #print(x,y,val)
                        if self.grd.get_tile(y,x) != val:
                            self.grd.set_tile(y, x, TERRAIN_LAND)
                            num_iterations -= 1
            new_x = cur_pos[0] + randint(0,3)-2
            new_y = cur_pos[1] + randint(0,3)-2
            if new_x > self.grd.grid_width - 1:
                new_x = 0
            if new_y > self.grd.grid_height - 1:
                new_y = 0
            if new_x < 0:
                new_x = self.grd.grid_width - 1
            if new_y < 0:
                new_y = self.grd.grid_height - 1
            cur_pos = [new_y, new_x]
227375
def grid(opts = {})
      range = Args::CardRange.new(opts[:range], deck_size: size)
      draw  = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
      box   = Args::Box.new(self).load!(opts, expand_by: size, layout: layout, dpi: dpi)
      range.each { |i| @cards[i].grid(box[i], draw[i]) }
    end
1295837
def random_init_map(interface, state, label, inp):
    """"""
    import random
    out = interface.output(0)
    centers = {}

    for row in inp:
        row = row.strip().split(state["delimiter"])
        if len(row) > 1:
            x = [(0 if row[i] in state["missing_vals"] else float(row[i])) for i in state["X_indices"]]
            cluster = random.randint(0, state['k'] - 1)
            vertex = state['create'](x, 1.0)
            centers[cluster] = vertex if cluster not in centers else state["update"](centers[cluster], vertex)
    for cluster, values in centers.iteritems():
        out.add(cluster, values)
293523
def pick_random_target(self):
        
        start_x = math.floor(self.grd.grid_height/2)
        start_y = math.floor(self.grd.grid_width /2)
        min_dist_from_x = 3
        min_dist_from_y = 5
        move_random_x = randint(1, math.floor(self.grd.grid_height/2))
        move_random_y = randint(1, math.floor(self.grd.grid_width/2))
        x = start_x + move_random_x - min_dist_from_x
        y = start_y + move_random_y - min_dist_from_y
        return [x,y]
564083
def set_random_seed():
  """"""
  tf.set_random_seed(FLAGS.random_seed)
  random.seed(FLAGS.random_seed)
  np.random.seed(FLAGS.random_seed)
1102965
def set_random_state(state):
    """"""
    randgen.state_set = True
    randgen.setstate(state)

    faker.generator.random.setstate(state)
373140
def get_tiles(self):
        """"""
        for x, y in griditer(self.root_tile.x, self.root_tile.y, ncol=self.tiles_per_row):
            yield TileCoordinate(self.root_tile.zoom, x, y)
72377
def iter_tiles(image, tile_size):
    
    w, h = image.size
    for y in xrange(0, h, tile_size):
        for x in xrange(0, w, tile_size):
            yield x, y
186298
def fillRectangle(self, x, y, width, height, color):
        """"""
        #fallback variant, use update recatngle
        #override with specialized function for better performance
        self.updateRectangle(x, y, width, height, color*width*height)
652359
def fill_layer_combo(self):
        """"""
        project = QgsProject.instance()
        # MapLayers returns a QMap<QString id, QgsMapLayer layer>
        layers = list(project.mapLayers().values())

        extensions = tuple(extension_siblings.keys())
        for layer in layers:
            if layer.source().lower().endswith(extensions):
                icon = layer_icon(layer)
                self.layers.addItem(icon, layer.name(), layer.id())
673943
function(){
            this.fillBg();
            for (var x = this.width - 1; x >= 0; x--) {
                for (var y = this.height - 1; y >= 0; y--) {
                    // get the actual map tile coord from view coord using offset
                    var tileX = x + this.originX,
                        tileY = y + this.originY;
                    this.drawTile(tileX, tileY);
                }
            }

            this.drawBufferToCanvas();
        }
147915
function (puzzle) {
                for (var i = 0, height = puzzle.length; i < height; i++) {
                    var row = puzzle[i];
                    for (var j = 0, width = row.length; j < width; j++) {
                        if (!puzzle[i][j]) {
                            var randomLetter = Math.floor(Math.random() * letters.length);
                            puzzle[i][j] = letters[randomLetter];
                        }
                    }
                }
            }
829954
private void regenerate() {
		try {
			ArrayList list = new ArrayList();
			for (int i=0;i<sprites.size();i++) {
				list.add(sprites.elementAt(i));
			}
			
			int b = ((Integer) border.getValue()).intValue();
			Sheet sheet = pack.packImages(list, twidth, theight, b, null);
			sheetPanel.setImage(sheet);
		} catch (IOException e) {
			// shouldn't happen 
			e.printStackTrace();
		}
	}
469181
@Override
	public RandomVariable floor(double floor) {
		return apply(OperatorType.FLOOR, new RandomVariable[]{this, constructNewAADRandomVariable(floor)});
	}