poker hands

This is a discussion on poker hands within the C++ Programming forums, part of the General Programming Boards category; How would I go about printing every possible 5 card poker hand. I know I need a few for loops ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    27

    poker hands

    How would I go about printing every possible 5 card poker hand. I know I need a few for loops but I don't understand how I would go about doing it. Thanks in advance!

  2. #2
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    you realise that there are 2598960 dealable hands in poker?
    I guess you might make a numerical assignment to every card
    and store that list (so that eases dealing with suits) as a start.
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    27
    OK what if I didn't want to print them out but I just wanted to go through every possible hand and then do something with it later.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    If you really want to do it you can try something like this:

    1) assign a unique value to each card in the deck ranging from 0 to 51.

    2) declare a series of nested loops, one loop for each card in a hand---5 cards per hand means 5 nested loops, 7 cards per hand means 7 nested loops. Lets say there are 5 cards per hand.

    3) Then the outer most loop ranges for 0 to 47 and is called a. The next loop ranges from a + 1 to 48 and is called b. The next loop ranges from b + 1 to 49 and is called c. And so on.

    4) The value of card[0] in any given hand will be a,
    the value of card[1] in any given hand will be b,
    the value of card[2] in any given hand will be c,
    etc.

    5) Use the value of any given card to refer back to its face and suit value if you want instead to display that information instead of the numerical value.

    6) Do what you will with any given hand

    7) Generate the next hand until all hands have be generated.

    Other than the academics of giggling all the variable values to generate all the permutations this seems relatively pointless though.
    Last edited by elad; 05-19-2006 at 02:59 PM.
    You're only born perfect.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Designing a program to deal out seven card stud poker hands
    By killsthehorse in forum C++ Programming
    Replies: 29
    Last Post: 12-08-2008, 04:03 PM
  2. Help!For poker game simulation
    By tx1988 in forum C++ Programming
    Replies: 24
    Last Post: 05-25-2007, 10:59 PM
  3. Poker bad beats
    By PJYelton in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 01-15-2005, 11:42 PM
  4. Gamecube Controllers >> Sweaty Hands
    By LordVirusXXP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 12-27-2002, 06:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21