1. PF Contest - Win "Conquering the Physics GRE" book! Click Here to Enter
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran program to calculate texas hold em odds

  1. Jul 22, 2010 #1
    The instructions are to calculate the odds of winning if you are dealt King and 9 of clubs, what are the odds of winning? I am finding myself spending more time trying to figure out texas hold em (never played before) than writing the program. So far I found a list on wiki that breaks down the winning hands by tiers. I am thinking to store the winning hands into the 8 tiers and based upon where it falls the program will count the number of hands below and divide to give the odds. I am thinking to set up the tiers into arrays? Does this sound like a solid start? I have spent too much time on the game and not enough on the program and am running out of time.
  2. jcsd
  3. Jul 23, 2010 #2
    There are many different Texas hold 'ems, different rules for what beats what, split pot or do you judge on colour? Can you form a straight ace high with A+2+3+4+5, does this win or lose from the top straight? Is there a small straight? All these things naturally affect the chance.

    Also, what is the dependent value? I mean, I take this is at least the number of players playing, if this is also fixed, then you don't really have a program, you have a constant number that doesn't change. For it to be a program the idea is that it depends on some input.

    Another thing that doesn't make sense to me about this question is the fact that people can fault, it's perfectly possible that some one who had a hand that beats yours faults, so you need some chance of people randomly folding, to which psychology comes into play?

    So I take it you're supposed to assume that all players play until the end for this experiment and there is no human intervention basically.

    So more formally your problem can be expressed (probably) as:

    - There are 52 cards
    - each player receives 2 of those at random | you get king and 9 of clubs
    - of the remaining cards, 5 of those end up randomly in the river so that each player has 7 cards, of which it shares those five with other players
    - on those combinations is a total order


    - what is the chance that the combination starting with 9 and king of clubs is the largest element of the set of all the combination the players make under that order.

    If you look at it this way, there is with some probability theory an ability to just construct a function which takes the numbers of players as input, and the chance as a rational number as output. All you need to do is formulate that formula into an expression and you're done. This is hardly a problem of programming, rather it is of probability theory.

    But, the question you pose here is vague, I had to do a lot of interpretation as I noted, so I'm not sure my formalism of the problem is the problem you intuitively described.

    Edit: For strategy, I would start with the total order and define it, an orderning function that takes in two sets of seven cards and determines which is higher.
  4. Jul 23, 2010 #3
    Sorry I probably should have just posted the question. Here it is,
    (3) Time to win at Texas Hold-em. You are getting two cards. It could be a pair (5.9% chance), it could be suited (23.5%, good for flush prospects), it could be unsuited and unpaired (70.6%). At this stage, before ‘the flop’:
    • Pair beats other cards unless both cards better (overcards) to the pair.
    • Suited beats non-pair unless one of the other cards is an overcard
    • Unpaired & unsuited beats same if it has the overcard, otherwise tie.
    You’re dealt {K,9} of clubs “the black dog”. The opponent has one of 50x49=1,225 hands. Use a program with the rules above to estimate outcomes for each hand. Divide winning situations by losing situations (ignore ties). What are the ‘odds’ of you winning?
  5. Jul 23, 2010 #4
    Well, from that story, it can be implied that you have only one opponent and this is fixed.

    Therefore, the chance of you winning in that story has no dependent variable any more, it's a constant.

    Your program will look similar to


    (as you can see I don't know Fortran)

    This isn't really a programming question as I said, this is probability theory.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook