Thread: Deck Shuffle

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2006
    Location
    Boston, Massachusetts
    Posts
    23
    Quote Originally Posted by Daved
    As long as you are using rand, a single call to random_shuffle will shuffle the deck as well as possible. Your version is just an interesting simulation of human shuffling, it is not more random (and is potentially less random, I'm not sure).
    Yeah I was thinking about going with random_shuffle when I found out about it, even tried to use it as you saw in my code(all the other code was commented out when I tried), but that seemed harder because I got that RandomAccessInteger error. But it's also hard for me to throw away that code seeing as I wrote it and tried to debug it for an hour or two maybe more before I posted here.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    As Daved already said:

    Quote Originally Posted by Daved
    >> But that didn't work because the array I pass isnt of type RandomAccessIterator or something.

    Sorry, it should be random_shuffle(d, d+52). If you just want to get a real shuffle, calling that once is all you have to do.
    Use that and it should work!
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. shuffle 2-dimensional array
    By patkhor in forum C Programming
    Replies: 5
    Last Post: 11-26-2008, 03:51 PM
  2. Question about engine design.
    By Shamino in forum Game Programming
    Replies: 9
    Last Post: 01-29-2008, 10:53 AM
  3. Blackjack
    By Tommo in forum C Programming
    Replies: 10
    Last Post: 06-20-2007, 08:07 PM
  4. Card shuffle and deal want to put on Stack
    By sugie in forum C++ Programming
    Replies: 4
    Last Post: 12-12-2005, 08:40 PM
  5. Replies: 2
    Last Post: 11-07-2003, 12:21 AM