0

Here is what I am working with. I have a Card class that contains information about the card, I have a deck class that sets up the 52 card deck, I have a Shoe class, that sets up a vector of decks. The issue is shuffling. The std::random_shuffle works great, but I cannot accomplish what I am looking for.

I can shuffle the Deck and I can shuffle the vector of decks, but it will still stack the decks on top of each other. I am looking for a way to shuffle the decks together. Any help would be greatly appreciated. ;).

Chivos
  • 83
  • 1
  • 6
  • 1
    Combine the vectors and then shuffle them. http://stackoverflow.com/questions/3177241/best-way-to-concatenate-two-vectors – Robert Harvey Apr 07 '13 at 22:34
  • Alright, i'll give that a shot ;) – Chivos Apr 07 '13 at 22:36
  • 1
    It might be easier to give the `Shoe` class a vector of cards, and an `AddDeck()` method. The method of course adds 52 cards to the vector of cards. It seems the `Deck` class doesn't add much value, you're only using it in one place for one purpose. – MSalters Apr 07 '13 at 22:55
  • A fundamental data representation error. A shoe is not a collection of decks. A shoe is a collection of cards, just like a deck is, it's just bigger. You need to use the same structure for both, except that the shoe has to allow for duplicates. Also, if you're making a serious industrial-strength game simulation, standard library random number generators are rarely adequate. My public domain OneJoker library, for example, uses the JKISS algorithm plus Fisher-Yates shuffle for cards. It's 160 lines of C code, available [here](https://github.com/lcrocker/OneJoker/blob/master/src/lib/prng.c). – Lee Daniel Crocker Apr 08 '13 at 00:56
  • Thank you MSalters and Lee Crocker, That is what I did. The deck class is putting together a shoe by using a method to add decks. It works perfectly ;) – Chivos Apr 08 '13 at 01:13

1 Answers1

2

Within the Shoe class, you could create another vector of cards and use the insert method to concatenate all of the Deck vectors together, and then shuffle the resultant vector (Assuming you are just wanting a massive mixed up Shoe full of cards).