Randomize my card deck

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

Hello!

So, I’m making a Memory Card Game. It works fine so far but the cards are not shuffling and to be honest, I don’t really know how to make them appear in random order on my deck. I tried randi() but it seems I just don’t know how to use it. The only thing I know is that I should add some randomize/shuffle code under my “func dealDeck()” function. But how to do it? Here’s my code: Memory-Game-Code hosted at ImgBB — ImgBB

MemoryGame file

:bust_in_silhouette: Reply From: fractile

Store them in array and use shuffle() ?

Or make a copy of your deck array and pick elements in randomized indices from that array and remove them afterwards.