|
|
TdAc 5s3d Kd7d ThQh 8s4h 6dKh 2d4s TcAd Ac2s 3d9h 7d3s Qh9s 4hQd KhQs 4sKc Ad6s 2sKs 9h9d 3s3h 9s5h QdAh QsJc KcJd 6sJh |
|
|
I get very strange output. With a period length of eight, the cards in the second column appear in the first column. |
|
|
|
|
Peter87 wrote: |
---|
Why wouldn't they? You shuffle all cards except for the first seven and then you print the eighth and ninth card. There is nothing that prevents the eighth card from ending up as the ninth card at a later time after you have shuffled the deck again. |
tpb wrote: |
---|
You're forgetting the nature of seeding the generator. Just like srand, it should only be done once in the run of the program. #include <iostream> #include <random> #include <vector> #include <algorithm> int main() { std::vector<int> deck(52); std::iota(deck.begin(), deck.end(), 0); std::mt19937_64 rng(std::random_device{}()); std::shuffle(deck.begin(), deck.end(), rng); for (int n: deck) std::cout << "A23456789TJQK"[n%13] << "CDHS"[n/13] << ' '; std::cout << '\n'; } |