Produce a full, stable start board with random tiles.
480663
def random_start_board(cls):
        """"""
        board = cls()
        board._random_fill()
        destructions = True  # prime the loop
        while destructions:
            board, destructions = board.execute_once()
            board._random_fill()
        return board
227344
def build(opts=None):
    
    board = catan.board.Board()
    modify(board, opts)
    return board
1263409
def demo(quiet, shell, speed, prompt, commentecho):
    """"""
    run(
        DEMO,
        shell=shell,
        speed=speed,
        test_mode=TESTING,
        prompt_template=prompt,
        quiet=quiet,
        commentecho=commentecho,
    )
359514
def _make_tile(self, value, background, text):
        """"""
        tile = pygame.Surface((self.cell_width, self.cell_height), pygame.SRCALPHA)
        pygame.draw.rect(tile, background, (0, 0, self.cell_width, self.cell_height))
        # The "zero" tile doesn't have anything inside.
        if value:
            label = load_font(self.BOLD_NAME, 50 if value < 1000 else
                              (40 if value < 10000 else 30)).render(str(value), True, text)
            width, height = label.get_size()
            tile.blit(label, ((self.cell_width - width) / 2, (self.cell_height - height) / 2))
        return tile
554590
public Sudoku generateRandomCandidate(Random rng)
    {
        // Clone the template as the basis for this grid.
        Sudoku.Cell[][] rows = template.clone();
        for (int i = 0; i < rows.length; i++)
        {
            rows[i] = template[i].clone();
        }

        // Fill-in the non-fixed cells.
        for (int i = 0; i < rows.length; i++)
        {
            List<Integer> rowValues = nonFixedValues.get(i);
            Collections.shuffle(rowValues);
            int index = 0;
            for (int j = 0; j < rows[i].length; j++)
            {
                if (rows[i][j] == null)
                {
                    rows[i][j] = new Sudoku.Cell(rowValues.get(index), false);
                    ++index;
                }
            }
        }
        return new Sudoku(rows);
    }
726455
def random(game):
    '''
    
    '''
    game.valid_moves = tuple(sorted(game.valid_moves, key=lambda _: rand.random()))
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()
352798
def make_data(n,m):
    """"""
    p = {}
    for i in range(1,m+1):
        for j in range(1,n+1):
            p[i,j] = random.randint(1,10)
    return p
1241522
def init_random(X, n_clusters, random_state):
    """"""
    logger.info("Initializing randomly")
    idx = sorted(draw_seed(random_state, 0, len(X), size=n_clusters))
    centers = X[idx].compute()
    return centers
1320848
function() {
    // Loop through the tiles and setup the audio listeners.
    for (var i=0; i<this.grid.length; i++) {
      if (this.grid[i] === 2) {
        var y = Math.floor(i / this.size);
        var x = i % this.size;
        game.audio.speaker(x, y);
      }
    }
  }
1056801
def build_board_2048():
    
    grd = Grid(4,4, [2,4])
    grd.new_tile()
    grd.new_tile()
    print(grd)
    return grd
1109872
def random(cls):
        """"""
        axis = random_unit()
        angle = np.random.uniform(0,2*np.pi)
        invert = bool(np.random.randint(0,2))
        return Rotation.from_properties(angle, axis, invert)
564083
def set_random_seed():
  """"""
  tf.set_random_seed(FLAGS.random_seed)
  random.seed(FLAGS.random_seed)
  np.random.seed(FLAGS.random_seed)
1051435
def generate_random_level(self):
        

        # build !
        width = self.width
        height = self.height
        tiles_w = self.tiles_w
        tiles_h = self.tiles_h
        self.z = 0

        # add walls
        #self.map_layer = ti.load(os.path.join(script_dir, 'test.tmx'))['map0']
        self.map_layer = self.generator.map(tiles_w, tiles_h)
        self.map_layer.set_view(0, 0, self.map_layer.px_width, self.map_layer.px_height)
        # FIXME: Both `scale_x` and `scale_y`
        self.map_layer.scale = config.scale_x
        self.add(self.map_layer, z=self.z)
        self.z += 1

        # add floor
        # TODO: Move to `Generator.inverse(map)`
        self.visit_layer = ti.load(os.path.join(script_dir, 'assets', 'ones.tmx'))['map0']
        for i in xrange(0, len(self.map_layer.cells)):
            for j in xrange(0, len(self.map_layer.cells[i])):
                col = self.map_layer.cells[i][j]
                # If wall exists, remove floor
                if col.tile and col.tile.id > 0:
                    self.visit_layer.cells[i][j].tile = None

        self.visit_layer.set_view(0, 0, self.visit_layer.px_width, self.visit_layer.px_height)
        # FIXME: Both `scale_x` and `scale_y`
        self.visit_layer.scale = config.scale_x
        self.add(self.visit_layer, z=-1)

        # add player
        # Start in random corner
        corner = randint(0,3)
        padding = eu.Vector2(self.map_layer.tw*1.5, self.map_layer.th*1.5)
        corners = [
            eu.Vector2(padding.x, padding.y), # Bottom left
            eu.Vector2(((tiles_w+1)*self.map_layer.tw)-padding.x, padding.y), # Bottom right
            eu.Vector2(padding.x, ((tiles_h+1)*self.map_layer.th)-padding.y), # Top right
            eu.Vector2(((tiles_w+1)*self.map_layer.tw)-padding.x, ((tiles_h+1)*self.map_layer.th)-padding.y) # Top left
        ]
        rotations = [
            45,
            -45,
            135,
            -135
        ]
        self.spawn = corners[corner]
        self.player = Player(self.spawn.x, self.spawn.y)
        self.player.rotation = rotations[corner]
        self.add(self.player, z=self.z)
        self.z += 1

        self.score = ScoreLayer(self.player.stats)
        self.add(self.score, z=self.z)
        self.z += 1

        # Draw sensors
        # TODO: Decouple into view rendering
        a = math.radians(self.player.rotation)
        for sensor in self.player.sensors:
            rad = a + sensor.angle
            start = self.player.cshape.center
            end = start.copy()
            end.x += math.sin(rad) * sensor.proximity;
            end.y += math.cos(rad) * sensor.proximity;
            sensor.line = draw.Line(start, end, self.player.palette['wall'] + (int(255*0.5),))
            self.map_layer.add(sensor.line)

        # Generate obstacles
        self.create_items()
111322
def random_reseed(self, seed):
        
        return pyhsm.basic_cmd.YHSM_Cmd_Random_Reseed(self.stick, seed).execute()
284195
def MakeProbs(self):
        """"""
        for hypo, odds in self.Items():
            self.Set(hypo, Probability(odds))
1023870
def simulate(self):
        """"""
        min_ = (-sys.maxsize - 1) if self._min is None else self._min
        max_ = sys.maxsize if self._max is None else self._max
        return random.randint(min_, max_)