Results 1 to 17 of 17

Thread: Poker - Calculating odds

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    Poker - Calculating odds

    Hello all,
    I am trying to make a poker game where you can play against the computer, however for the computer player to be any good it needs to know the chance of winning from its current hand (this is texas holdem poker so you know). I have been trying to make a chance calculator that gives the exact chance of winning, losing, and splitting the pot for any hand, however as there are so many combinations it takes a very long time to do it. I have looked at alternatives such as calculating the chance using the number of 'outs' but that only really gives an approximate chance.
    Here is the basic outline of what i have at the moment (this is executed at the stage when all 5 community cards are face up)

    Calculate the best hand for the player from the 7 cards avaliable
    Loop through each combination of cards for an opponent
    add one to the total count
    calculate the best hand from the 7 cards avaliable to the opponent
    compare the opponents hand with the players hand
    add one to either the win count, the lose count, or the split count
    (end of loop)
    chance of winning = win count / total count

    Here's the VB code to carry out this bit:

    VB Code:
    1. handScore = FindBestHandScore(pHand, pCommunity)
    2.     For i = 1 To pPack.Count - 1
    3.         For j = i + 1 To pPack.Count
    4.             fOpponent.Clear
    5.             fOpponent.Add pPack(i).suit, pPack(i).facevalue
    6.             fOpponent.Add pPack(j).suit, pPack(j).facevalue
    7.             opponentScore = FindBestHandScore(fOpponent, pCommunity)
    8.             CalculateChance.Total = CalculateChance.Total + 1
    9.             Select Case Sgn(opponentScore - handScore)
    10.             Case 1
    11.                 CalculateChance.Loses = CalculateChance.Loses + 1
    12.             Case 0
    13.                 CalculateChance.Splits = CalculateChance.Splits + 1
    14.             Case -1
    15.                 CalculateChance.Wins = CalculateChance.Wins + 1
    16.             End Select
    17.         Next j
    18.     Next i
    Last edited by Arachnid13; Feb 7th, 2006 at 07:17 AM.
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

Posting Permissions

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



Click Here to Expand Forum to Full Width