choose random cards from list for each player

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By harrytrump

i want to make a turn base card game,suppose there are four players, each player gets 13 random cards without repeating, i can program in python,

import random
cards = ['club1' , 'club2',  'club3',  'club4', 'club5', 'club6','club7','club8','club9','club10' ,'club11','club12','club13','heart1', 'heart2', 'heart3',  'heart4', 'heart5', 'heart6', 'heart7',  
'heart8', 'heart9','heart10',  'heart11', 'heart12','heart13',  'diamond1','diamond2','diamond3', 'diamond4', 'diamond5','diamond6', 'diamond7','diamond8','diamond9','diamond10','diamond11',  'diamond12', 'diamond13', 'spades1','spades2', 'spades3', 'spades4', 'spades5', 'spades6', 'spades7', 'spades8', 'spades9','spades10','spades11', 'spades12', 'spades13' ]


num_to_selects = 13
player1 = random.sample(cards,num_to_selects)



remainingcardsset1 = list(set(cards)-set(player1))

player2 = random.sample(remainingcardsset1,num_to_selects)
remainingcardsset2 = list(set(remainingcardsset1)-set(player2))
player3 = random.sample(remainingcardsset2,num_to_selects)
player4 = list(set(remainingcardsset2)-set(player3))

print (player1)
print("\n")
print(player2)
print("\n")
print(player3)
print("\n")
print(player4)

i am new to gdscript, i tried with set method, but set not working in gdscript, how to allocate 13 cards to each player without repeating?

:bust_in_silhouette: Reply From: njamster

Check out this answer.

That answer did not return remaining cards list,

harrytrump | 2020-04-09 18:41

That answer did not return remaining cards list,

Yes it did? The last snippet maintains two disjoint sets cards and picked_cards. Actually the only comments under that answer are precisely about your problem…

njamster | 2020-04-09 19:19