void DeckShuffle(int deck[52]);
Shuffle a deck of 52 cards.
Parameters
deck[52] This parameter must provide an array of 52 integers representing cards in a deck. The values 0-51 represent all cards in the deck. If deck[5] equals 9 this means that the 6th card in the deck is a 10.
To derive the suit and digit from the 1st card in the deck:
suit = deck[0]/13; // suit: 0=spades, 1=hearts, 2=diamonds, 3=clubs digit = deck[0]%13; // digit: 0=ace, 1=2, 2=3, ... 9=10, 10=jack, 11=queen, 12=king
Remarks
The DeckShuffle() function shuffles cards in a random order. There is no need to initialize the values in the Deck array before calling DeckShuffle(). When the function returns, the Deck array will be filled with 52 shuffled cards in array positions [0]-[51] with the values of 0-51 randomly distributed. Use Randomize() prior to calling DeckShuffle() to get a more truly random shuffle. Use RandomSetSeed(seed) to generate a specific (recalled) shuffle sequence.
Availability
Available in DragonFireSDK 1.0 and later.
Example
Description: This program will shuffle all cards in the deck Deck.
#include "DragonFireSDK.h"
void AppMain() { int Deck[52]; DeckShuffle(Deck); }
void AppExit() {
}
void OnTimer() {
} |