def __init__(self, id_game, n, m): self.__board = [[]] self.__n = n self.__m = m self.id_game = id_game self.orders self.init_random_state = random.getstate( ) # to get the same results later when we reload the game and re-simulate the orders self.prng = random.Random() print(prng.random())
def __init__(self, num, rand=False): self.rand = rand self.num = num self.idx = 0 if self.rand: self.randObj = random.Random(os.urandom(16)) self.randomFunc = self.randObj.uniform self.func = self.__next_rand else: self.func = self.__next_seq
def pack_of_cards(cube_id, num_cards, random_seed): num_cards = int(num_cards) randomizer = random.Random(random_seed) cube = Cube.query.get(cube_id) cube_wrapper = CubeWrapper(cube) cards = cube_wrapper.cards() randomizer.shuffle(cards) cards = cards[:num_cards] card_data = {} for card in cards: card_data[card.id] = card.get_json() return render_template( 'pack_of_cards.html', title=f"Pack of {num_cards} cards from {cube.name}", cards=cards, card_data=card_data, )
def shuffle_list(self, list, seed=SEED): ''' Shuffles a list passed as argument. ''' random.Random(seed).shuffle(list) return list
def shuffle(self, seed=SEED): ''' Shuffles the list of epochs in-place. ''' random.Random(seed).shuffle(self.epochs)