SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2006
    0 Post(s)
    0 Thread(s)

    probability calculations (holdem poker straights)

    I have a script which has inputs of standard cards, 2 for the player, and 0, 3,4 or 5 for the community.

    I have already created a working function that tells me what the possible and best hand is out of the cards given (5+ only), and working out for quads/trips/flush/pairs etc is pretty easy

    But I am struggling to come up with a way of calculating which hands are still possible (providing 1 or 2 more cards to come). I was thinking of storing my hand as a string, with ace = 1, 2-9, 10 =t , 11 = j, 12=q, 13=k, ordered asc as order does not matter.
    eg. 1457k, 45678, 9tjqk, 1tjqk

    and then trying to do some sort of pattern matching to see how close to a straight I have.

    Is there a better way of trying to calculate this?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Christchurch, New Zealand
    104 Post(s)
    4 Thread(s)
    You could loop through the groups of numbers for each straight, and count how many cards are missing to achieve a straight.

    So with 1457k it would count from 1 up to 5, and record that two numbers are required. The loop that has the least number of missing cards is the best one for a straight.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts