|
-
Feb 7th, 2006, 06:59 AM
#1
Thread Starter
Hyperactive Member
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:
handScore = FindBestHandScore(pHand, pCommunity)
For i = 1 To pPack.Count - 1
For j = i + 1 To pPack.Count
fOpponent.Clear
fOpponent.Add pPack(i).suit, pPack(i).facevalue
fOpponent.Add pPack(j).suit, pPack(j).facevalue
opponentScore = FindBestHandScore(fOpponent, pCommunity)
CalculateChance.Total = CalculateChance.Total + 1
Select Case Sgn(opponentScore - handScore)
Case 1
CalculateChance.Loses = CalculateChance.Loses + 1
Case 0
CalculateChance.Splits = CalculateChance.Splits + 1
Case -1
CalculateChance.Wins = CalculateChance.Wins + 1
End Select
Next j
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|