Advertisement

How to randomize card set ?

Started by November 12, 2000 08:52 PM
1 comment, last by soberanz 24 years, 1 month ago
I want make a list of random value of 1-13 (card set). Anyone have some algorithms? Thanks.
Make the deck with a 52 element array.

Shuffle the deck by cycling through it and swapping the current card with a randomly selected card. Shuffle the deck about 4 or 5 times. Pretty simple.

_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
Advertisement
    int cards[52];  for (int i = 0; i < 52; ++i) {  cards[ i ] = i;}  std::random_shuffle(&cards[0], &cards[52]);    


---- --- -- -
Blue programmer needs food badly. Blue programmer is about to die!
---- --- -- -
New York. New York. New York. Texas. Texas. New York. New York. Canada.
---- --- -- -

Edited by - mossmoss on November 13, 2000 8:13:09 AM

This topic is closed to new replies.

Advertisement