Discussion Locked

card game with visual basic

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
My question is:I am trying to develop a card game, like the one we played as kids. The one where you laid out all the cards face down and tried to match by memory a pair. My problem is the code to shuffle the cards after a game has been played.

3 replies

by vinnyd

You need to generate a seq of random numbers one for each card.

Use a 2 dim array like card(52,2) where you can put each card into card(i,1) and the random number into card(i,2).

Then use a sort to sort the array by the random number in card(i,2).

Using this way you will have to assign a number to each card like 100 for Ace of Spades 101 for Deuce of Spades. 200 for Ace of Hearts etc.

This discussion is closed to new replies.