I am using a function to get a random sample of a given number of cards in a card game with random.sample. The problem is that calling the function twice results in the same sample, which is not the behaviour i want.
So always the same cards will be in the sample inside one programm, differing in each programm but staying the same sample each time the function is called inside one programm.
def distributeCards(self,cardsPerPlayer):
cards = random.sample(self.deck, cardsPerPlayer*len(self.players));
for i in range(len(self.players)):
for j in range(cardsPerPlayer):
self.players[i].append(cards[i*cardsPerPlayer + j]);
Aucun commentaire:
Enregistrer un commentaire