I took my deck of Cards (class Card) and shuffled the. But every time i ran the program it gave me the same shuffled results....
void Deck::shuffleDeck()
{
std::random_shuffle(deck.begin(), deck.end());
}
I took my deck of Cards (class Card) and shuffled the. But every time i ran the program it gave me the same shuffled results....
void Deck::shuffleDeck()
{
std::random_shuffle(deck.begin(), deck.end());
}
Did you call srand first?
just realizes i forgot that. Is it just
srand(time(NULL));?
EDIT: Nvm, works now. Dumb mistake by me :P ty
Try:
void Deck::shuffleDeck()
{
srand(time(NULL)); // Set seed for random numbers
std::random_shuffle(deck.begin(), deck.end());
}
Cheers,
Erik
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.