Thread: Deck Shuffle

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Many people change compilers, or re-use code on different projects that use different compilers. When you try to use that code on another compiler that doesn't support non-constant array sizes, it won't work. Also, when you post it on a website like this, only people with g++ will be able to run and test your code without making changes.

    The gcc compiler allows it for a reason, so if you know you are only going to use g++ and you don't plan on using this code much elsewhere, then it is perfectly acceptable to take advantage of the feature. Besides, it might even be added to the C++ standard in the future.

    A vector is better than a C style dynamic array because it encapsulates the memory management and provides a safer interface than plain arrays.

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    450
    I find the it interesting that you want to simulate the shuffle of a real dealer.
    But conjoining a split deck rarely ever is a linear one to one swap of cards.
    Usually you get say 0-4 from one side maybe and 0-4 from one side.
    So I just wanted to say it would be interesting if you allowed for this varience in your code.
    What would be really intersting is to create a greater or lesser variance based on the skill level of your bot dealer.

    (me hides for being lazy)

  3. #3
    Registered User
    Join Date
    Jan 2006
    Location
    Boston, Massachusetts
    Posts
    23
    I do allow for the variance in my code. Look at my explination of what I wanted it to do when i first posted. Then look at the code. I use rand() to get a number between 1-4, then use that number as the variance. The only thing that isnt real is that the variance is always the sameeach time the deck is shuffled.

    Also, the dealer skill is an interesting idea. But, I want to shuffle the deck as best as possible.

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    450
    My bad, I guess if I wasn't lazy I would have analyzed the code deeper and seen this.
    kudos to you

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