Thread Rating:
To calculate baccarat combinations, if listing all six cards from 0 to 9, there are 1000000 steps.
Cutting down some repeating first two cards, there are still 302500 steps in my program.
Any way to simplify the process? Any formula?
Thanks in advance.
Quote: 7upHow to do combinational analysis faster
To calculate baccarat combinations, if listing all six cards from 0 to 9, there are 1000000 steps.
Cutting down some repeating first two cards, there are still 302500 steps in my program.
Any way to simplify the process? Any formula?
Thanks in advance.
What info do you need in your combo analyzer? Just ways for banker, player and tie to win ? Or more detail, like given the first card is a two, what outcomes are posible? Do you need the exact final score? How many cards are used?
Quote: mipletWhat info do you need in your combo analyzer? Just ways for banker, player and tie to win ? Or more detail, like given the first card is a two, what outcomes are posible? Do you need the exact final score? How many cards are used?
Quote: JBI think the 10^6 = 1,000,000 shortcut (using weight factors) is the fastest method. It takes less than a second to analyze on a typical computer.
I'vd got all those results, just wonder if there is any better way to do the cal faster.
It takes me 0.5 seconds to go through the 1 million steps for some simple addings for my computer, but it takes 6.8 seconds to find out banker/player/tie to win for those 1 milion steps. For the 302500 steps method, it still takes 2.3 seconds.
So I think there shoud be some better programming techniques.
Quote: 7upI'vd got all those results, just wonder if there is any better way to do the cal faster.
It takes me 0.5 seconds to go through the 1 million steps for some simple addings for my computer, but it takes 6.8 seconds to find out banker/player/tie to win for those 1 milion steps. For the 302500 steps method, it still takes 2.3 seconds.
So I think there shoud be some better programming techniques.
The bottleneck must be in your code which determines the outcome. If you post your code, I can help you speed it up. What language is it in?
Quote: JBThe bottleneck must be in your code which determines the outcome. If you post your code, I can help you speed it up. What language is it in?
I use the ancient FoxPro 2.6, not too hard to read them.
CLEAR
DIMENSION face(10)
STORE 0 TO bwin,pwin,twin
sec0=SECONDS()
*8 decks each mask 32 cards
FOR i=1 TO 9
face(i)=32
ENDFOR
face(10)=32*4
*all combinations
FOR a=1 TO 10
p1=face(a)
face(a)=face(a)-1
FOR c=1 TO 10
p2=face(c)
face(c)=face(c)-1
FOR b=1 TO 10
b1=face(b)
face(b)=face(b)-1
FOR d=1 TO 10
b2=face(d)
face(d)=face(d)-1
FOR e=1 TO 10
h5=face(e)
face(e)=face(e)-1
FOR f=1 TO 10
h6=face(f)
DO whowin300 &&find out banker/player/tie win
NEXT
face(e)=face(e)+1
NEXT
face(d)=face(d)+1
NEXT
face(b)=face(b)+1
NEXT
face(c)=face(c)+1
NEXT
face(a)=face(a)+1
NEXT
*display results
? STR(bwin/(bwin+pwin+twin),10,7),'Banker win'
? STR(pwin/(bwin+pwin+twin),10,7),'Player win'
? STR(twin/(bwin+pwin+twin),10,7),'Tie win'
?
? bwin,'Banker win'
? pwin,'Player win'
? twin,'Tie win'
? SECONDS()-sec0,'seconds'
RETURN && end of program
******
PROCEDURE whowin300 &&find out banker/player/tie win
phand12=MOD(a+c,10) &&-total of player's first 2 cards
bhand12=MOD(b+d,10) &&-total of banker's first 2 cards
*whether hit the fifth or sixth card
DO CASE
CASE phand12>7 OR bhand12>7
*anyhit='22'
phand123=MOD(a+c,10) &&_two card for player, two card for banker
bhand123=MOD(b+d,10)
CASE BETWEEN(phand12,6,7) AND BETWEEN(bhand12,6,7)
*anyhit='22'
phand123=MOD(a+c,10)
bhand123=MOD(b+d,10)
CASE BETWEEN(phand12,6,7) AND bhand12<6
*anyhit='23'
phand123=MOD(a+c,10)
bhand123=MOD(b+d+f,10)
CASE phand12<6 AND bhand12<3
*anyhit='33'
phand123=MOD(a+c+e,10)
bhand123=MOD(b+d+f,10)
CASE phand12<6 AND bhand12=3 AND e#8
*anyhit='33'
phand123=MOD(a+c+e,10)
bhand123=MOD(b+d+f,10)
CASE phand12<6 AND bhand12=4 AND BETWEEN(e,2,7)
*anyhit='33'
phand123=MOD(a+c+e,10)
bhand123=MOD(b+d+f,10)
CASE phand12<6 AND bhand12=5 AND BETWEEN(e,4,7)
*anyhit='33'
phand123=MOD(a+c+e,10)
bhand123=MOD(b+d+f,10)
CASE phand12<6 AND bhand12=6 AND BETWEEN(e,6,7)
*anyhit='33'
phand123=MOD(a+c+e,10)
bhand123=MOD(b+d+f,10)
OTHERWISE
*anyhit='32'
phand123=MOD(a+c+e,10)
bhand123=MOD(b+d,10)
ENDCASE
*add up to banker/player/tie
DO CASE
CASE bhand123>phand123
bwin=bwin+p1*p2*b1*b2*h5*h6
CASE phand123>bhand123
pwin=pwin+p1*p2*b1*b2*h5*h6
CASE phand123=bhand123
twin=twin+p1*p2*b1*b2*h5*h6
ENDCASE
RETURN
***
Quote: 7upOops! All the tabs gone.
You can surround it with [code] and [/code] tags to preserve formatting. I inserted the tags into your post.
Okay, my first suggestion is to use an array for determining whether or not the banker should hit. Make it a 2-dimensional boolean array, where one dimension is the banker's total, and the other is the player's third card. Populate this array before entering any loops. Then, when you are in the loop and need to determine whether the banker should hit, just retrieve the boolean value from the appropriate location in the array.
All of the calls to the function are going to hinder performance too. I don't think you even need a function to determine the outcome. Just total the player's hand as soon as his first 2 cards are known, and do the same with the banker. Then determine whether the player takes an extra card or not. If he does, start the fifth loop and recompute his total; and inside that loop, use the array to determine whether the banker takes a third card too, and if so, deal each possible card to him and recompute his total.
You should be able to avoid running several unnecessary loops by not dealing a third card to the player and/or banker if either or both of them are supposed to stand. When dealing with multiple loops like that, you want try to do whatever you can soon as it is possible to do so. That is, don't deal the third card to each and then later decide whether or not they needed it; decide first and deal the cards only when necessary.
Have to take some time to digest it and try on it.
Thanks again!
Did you post your revised code that dropped the calculation time down to 0.31. If not could you post it so I could try and use it.
Thanks
Dim j, btt, ptt As Double, face(10) As Double, p1 As Double, p2 As Double, b1 As Double, b2 As Double, h5 As Double, h6 As Double, a, b, c, d, e, f, bwin As Double, twin As Double, pwin As Double, sec0 As Single, i, pt, bt, xx
sec0 = Timer
bwin = 0: twin = 0: pwin = 0
For i = 1 To 9
face(i) = 32
Next
face(0) = 32 * 4
For a = 0 To 9
p1 = face(a)
face(a) = face(a) - 1
For c = 0 To 9
p2 = face(c)
face(c) = face(c) - 1
For b = 0 To 9
b1 = face(b)
face(b) = face(b) - 1
For d = 0 To 9
b2 = face(d)
face(d) = face(d) - 1
ptt = p1 * p2 * b1 * b2
pt = a + c
bt = b + d
If pt > 9 Then pt = pt - 10
If bt > 9 Then bt = bt - 10
btt = bt
If pt > 7 Or bt > 7 Then
If bt > pt Then
bwin = bwin + ptt * 169332
ElseIf pt > bt Then
pwin = pwin + ptt * 169332
Else
twin = twin + ptt * 169332
End If
Else
If pt < 6 Then
pt = a + c
If pt > 9 Then pt = pt - 10
For e = 0 To 9
h5 = face(e)
face(e) = face(e) - 1
If pt > 9 Then pt = pt - 10
If e < 2 Then
xx = 4
ElseIf e < 4 Then
xx = 5
ElseIf e < 6 Then
xx = 6
ElseIf e < 8 Then
xx = 7
ElseIf e = 8 Then
xx = 3
Else
xx = 4
End If
If bt >= xx Then
If bt > pt Then
bwin = bwin + ptt * h5 * 411
ElseIf pt > bt Then
pwin = pwin + ptt * h5 * 411
Else
twin = twin + ptt * h5 * 411
End If
Else
For f = 0 To 9
h6 = face(f)
bt = b + d + f
If bt > 9 Then bt = bt - 10
If bt > 9 Then bt = bt - 10
If bt > pt Then
bwin = bwin + ptt * h5 * h6
ElseIf pt > bt Then
pwin = pwin + ptt * h5 * h6
Else
twin = twin + ptt * h5 * h6
End If
Next
bt = btt
End If
face(e) = face(e) + 1
pt = pt + 1
Next
Else
If bt > 5 Then
If bt > pt Then
bwin = bwin + ptt * 169332
ElseIf pt > bt Then
pwin = pwin + ptt * 169332
Else
twin = twin + ptt * 169332
End If
Else
For f = 0 To 9
h6 = face(f)
bt = b + d + f
If bt > 9 Then bt = bt - 10
If bt > 9 Then bt = bt - 10
If bt > pt Then
bwin = bwin + ptt * 411 * h6
ElseIf pt > bt Then
pwin = pwin + ptt * 411 * h6
Else
twin = twin + ptt * 411 * h6
End If
Next
End If
End If
End If
face(d) = face(d) + 1
Next
face(b) = face(b) + 1
Next
face(c) = face(c) + 1
Next
face(a) = face(a) + 1
Next
Debug.Print bwin / (bwin + pwin + twin)
Debug.Print pwin / (bwin + pwin + twin)
Debug.Print twin / (bwin + pwin + twin)
Debug.Print
Debug.Print bwin, "Banker win"
Debug.Print pwin, "Player win"
Debug.Print twin, "Tie win"
Debug.Print bwin + pwin + twin
Dim ptt2 As Double, j, btt, ptt As Double, face(10) As Double, p1 As Double, p2 As Double, b1 As Double, b2 As Double, h5 As Double, h6 As Double, a, b, c, d, e, f, bwin As Double, twin As Double, pwin As Double, sec0 As Single, i, pt, bt, xx
Dim earray(9), pttmp As Double, TotalPerm As Double, decks, ptth5 As Double, ptt411 As Double, ptt169332 As Double, pc1 As Double, pc2 As Double
sec0 = Timer
bwin = 0: twin = 0: pwin = 0
decks = 8
Select Case decks
Case 6: TotalPerm = 878869206895680# '(decks*52)!/(decks*52-6)!
Case 8: TotalPerm = 4.99839827550336E+15 '(decks*52)!/(decks*52-6)!
End Select
pc1 = decks * 52 - 5
pc2 = (decks * 52 - 4) * (decks * 52 - 5)
earray(0) = 4
earray(1) = 4
earray(2) = 5
earray(3) = 5
earray(4) = 6
earray(5) = 6
earray(6) = 7
earray(7) = 7
earray(8) = 3
earray(9) = 4
For i = 1 To 9
face(i) = decks * 4
Next
face(0) = decks * 4 * 4
For a = 0 To 9
p1 = face(a)
face(a) = face(a) - 1
For c = a To 9
p2 = face(c)
face(c) = face(c) - 1
For b = 0 To 9
b1 = face(b)
face(b) = face(b) - 1
ptt2 = p1 * p2 * b1
If a <> c Then ptt2 = 2 * ptt2
For d = b To 9
b2 = face(d)
ptt = ptt2 * b2
If b <> d Then ptt = 2 * ptt
ptt411 = ptt * pc1
ptt169332 = ptt * pc2
face(d) = face(d) - 1
pt = a + c
bt = b + d
If pt > 9 Then pt = pt - 10
If bt > 9 Then bt = bt - 10
btt = bt
If pt > 7 Or bt > 7 Then
If pt > bt Then
pwin = pwin + ptt169332
ElseIf pt = bt Then
twin = twin + ptt169332
End If
Else
If pt < 6 Then
pt = a + c
If pt > 9 Then pt = pt - 10
For e = 0 To 9
h5 = face(e)
face(e) = face(e) - 1
If pt > 9 Then pt = pt - 10
If bt >= earray(e) Then
If pt > bt Then
pwin = pwin + ptt411 * h5
ElseIf pt = bt Then
twin = twin + ptt411 * h5
End If
Else
ptth5 = ptt * h5
For f = 0 To 9
If bt > 9 Then bt = bt - 10
If pt > bt Then
pwin = pwin + ptth5 * face(f)
ElseIf pt = bt Then
twin = twin + ptth5 * face(f)
End If
bt = bt + 1
Next
bt = btt
End If
face(e) = face(e) + 1
pt = pt + 1
Next
Else
If bt > 5 Then
If pt > bt Then
pwin = pwin + ptt169332
ElseIf pt = bt Then
twin = twin + ptt169332
End If
Else
bt = b + d
For f = 0 To 9
h6 = face(f)
If bt > 9 Then bt = bt - 10
If pt > bt Then
pwin = pwin + ptt411 * h6
Else
If pt = bt Then twin = twin + ptt411 * h6
End If
bt = bt + 1
Next
End If
End If
End If
face(d) = face(d) + 1
Next
face(b) = face(b) + 1
Next
face(c) = face(c) + 1
Next
face(a) = face(a) + 1
Next
bwin = TotalPerm - pwin - twin
Debug.Print bwin / (bwin + pwin + twin)
Debug.Print pwin / (bwin + pwin + twin)
Debug.Print twin / (bwin + pwin + twin)
Debug.Print
Debug.Print bwin, "Banker win"
Debug.Print pwin, "Player win"
Debug.Print twin, "Tie win"
Dim ptt2 As Double, j, btt, ptt As Double, face(10) As Double, p1 As Double, p2 As Double, b1 As Double, b2 As Double, h5 As Double, h6 As Double, a, b, c, d, e, f, bwin As Double, twin As Double, pwin As Double, sec0 As Single, i, pt, bt, xx
Dim earray(9), pttmp As Double, TotalPerm As Double, decks, ptth5 As Double, ptt411 As Double, ptt169332 As Double, pc1 As Double, pc2 As Double
Dim ee, ff, ft As Double
sec0 = Timer
bwin = 0: twin = 0: pwin = 0
decks = 8
Select Case decks
Case 6: TotalPerm = 878869206895680# '(decks*52)!/(decks*52-6)!
Case 8: TotalPerm = 4.99839827550336E+15 '(decks*52)!/(decks*52-6)!
End Select
pc1 = decks * 52 - 5
pc2 = (decks * 52 - 4) * (decks * 52 - 5)
earray(0) = 4
earray(1) = 4
earray(2) = 5
earray(3) = 5
earray(4) = 6
earray(5) = 6
earray(6) = 7
earray(7) = 7
earray(8) = 3
earray(9) = 4
For i = 1 To 9
face(i) = decks * 4
Next
face(0) = decks * 4 * 4
For a = 0 To 9
p1 = face(a)
face(a) = face(a) - 1
For c = a To 9
p2 = face(c)
face(c) = face(c) - 1
For b = 0 To 9
b1 = face(b)
face(b) = face(b) - 1
ptt2 = p1 * p2 * b1
If a <> c Then ptt2 = ptt2 + ptt2
For d = b To 9
b2 = face(d)
ptt = ptt2 * b2
If b <> d Then ptt = ptt + ptt
ptt411 = ptt * pc1
ptt169332 = ptt * pc2
face(d) = face(d) - 1
pt = a + c
bt = b + d
If pt > 9 Then pt = pt - 10
If bt > 9 Then bt = bt - 10
btt = bt
If pt > 7 Or bt > 7 Then
If pt > bt Then
pwin = pwin + ptt169332
ElseIf pt = bt Then
twin = twin + ptt169332
End If
Else
If pt < 6 Then
pt = a + c
If pt > 9 Then pt = pt - 10
For e = 0 To 9
h5 = face(e)
face(e) = face(e) - 1
If pt > 9 Then pt = pt - 10
If bt >= earray(e) Then
If pt > bt Then
pwin = pwin + ptt411 * h5
ElseIf pt = bt Then
twin = twin + ptt411 * h5
End If
Else
ff = 10 - bt
ee = ff + pt - 1
If ee > 9 Then ee = 9
ft = 0
For i = ff To ee
ft = ft + face(i)
Next
For i = 0 To ff + pt - 11
ft = ft + face(i)
Next
pwin = pwin + ptt * h5 * ft
ff = pt - bt
If ff < 0 Then
twin = twin + ptt * h5 * face(ff + 10)
Else
twin = twin + ptt * h5 * face(ff)
End If
End If
face(e) = face(e) + 1
pt = pt + 1
Next
Else
If bt > 5 Then
If pt > bt Then
pwin = pwin + ptt169332
ElseIf pt = bt Then
twin = twin + ptt169332
End If
Else
bt = b + d
For f = 0 To 9
h6 = face(f)
If bt > 9 Then bt = bt - 10
If pt > bt Then
pwin = pwin + ptt411 * h6
Else
If pt = bt Then twin = twin + ptt411 * h6
End If
bt = bt + 1
Next
End If
End If
End If
face(d) = face(d) + 1
Next
face(b) = face(b) + 1
Next
face(c) = face(c) + 1
Next
face(a) = face(a) + 1
Next
bwin = TotalPerm - pwin - twin
Debug.Print bwin / (bwin + pwin + twin)
Debug.Print pwin / (bwin + pwin + twin)
Debug.Print twin / (bwin + pwin + twin)
Debug.Print
Debug.Print bwin, "Banker win"
Debug.Print pwin, "Player win"
Debug.Print twin, "Tie win"
Quote: gordonm888Not only is there a lot of specialized expertise among the WOV forum crowd, but I'm beginning to appreciate how knowledgeable the admins are as well (specifically Babs, Mission and JB in addition to Wiz). Its actually damn impressive.
Thanks for the compliment!
In the first iteration you have the constants 169332 and 411. what do these represents and how are they altered as more cards are drawn from the shoe. However in the second and third iterations you define variables ptt411 = ptt * pc1 and ptt169332 = ptt * pc2 in place of the constants introduced in iteration 1 but you also introduce two new variables pc1 and pc2 which are defined as pc1 = decks * 52 - 5
pc2 = (decks * 52 - 4) * (decks * 52 - 5). Again what do these variables represent and how to they change during play. Or is the case that your algorithm is a one time algorithm and only works for a new game before any cards are drawn.
Thanks
Quote: 7upHow to do combinational analysis faster
To calculate baccarat combinations, if listing all six cards from 0 to 9, there are 1000000 steps.
Cutting down some repeating first two cards, there are still 302500 steps in my program.
Any way to simplify the process? Any formula?
Thanks in advance.
I could help you but I'm choosing not to only because I'm trying to publish my research so it can be nominated for an able prize. I am not joking when I say I have all the knowledge your seeking (and more) but you're going to have to wait till it's published first. I have 3 two hour YouTube videos (currently unlisted) using a theorem that's not currently known to anyone but myself and the very small people that I've shared my research with (like Prof. Hillel Furstenberg). This theorem of mine does exactly what your asking for, an easy way to simplify & subdivide large combinatorial groups so that solving probabilities for these massive amounts of data becomes easy.
Quote: WizardWelcome back USPG! Hope to see you in the easy math puzzle thread.
Thank you, surely you don't want me to post all the answers to easy puzzles. Did you want me to post some easy math puzzles to solve?
Quote: USpapergamesQuote: 7upHow to do combinational analysis faster
To calculate baccarat combinations, if listing all six cards from 0 to 9, there are 1000000 steps.
Cutting down some repeating first two cards, there are still 302500 steps in my program.
Any way to simplify the process? Any formula?
Thanks in advance.
I could help you but I'm choosing not to only because I'm trying to publish my research so it can be nominated for an able prize. I am not joking when I say I have all the knowledge your seeking (and more) but you're going to have to wait till it's published first. I have 3 two hour YouTube videos (currently unlisted) using a theorem that's not currently known to anyone but myself and the very small people that I've shared my research with (like Prof. Hillel Furstenberg). This theorem of mine does exactly what your asking for, an easy way to simplify & subdivide large combinatorial groups so that solving probabilities for these massive amounts of data becomes easy.
link to original post
Have you published your research findings?
Quote: ssho88Quote: USpapergamesQuote: 7upHow to do combinational analysis faster
To calculate baccarat combinations, if listing all six cards from 0 to 9, there are 1000000 steps.
Cutting down some repeating first two cards, there are still 302500 steps in my program.
Any way to simplify the process? Any formula?
Thanks in advance.
I could help you but I'm choosing not to only because I'm trying to publish my research so it can be nominated for an able prize. I am not joking when I say I have all the knowledge your seeking (and more) but you're going to have to wait till it's published first. I have 3 two hour YouTube videos (currently unlisted) using a theorem that's not currently known to anyone but myself and the very small people that I've shared my research with (like Prof. Hillel Furstenberg). This theorem of mine does exactly what your asking for, an easy way to simplify & subdivide large combinatorial groups so that solving probabilities for these massive amounts of data becomes easy.
link to original post
Have you published your research findings?
link to original post
USpapergames was banned from this forum years ago.
Quote: acesideI’ve read through this thread but still haven’t figured out what the OP wanted to achieve. I guess I need to learn Basic programming languages first.
link to original post
The OP wanted a faster way of calculating the number of what was called "combinations" (I think permutations, or tuples, is more accurate) of something.
For example, in a Video Poker analyzer, there are 2,598,960 ways to create a 5-card hand if order does not matter, but these can be reduced to 134,459 "groups" of 4, 12, or 24 hands each.
Quote: acesideI would like to have a VBA program that lists all these134,459 distinct hands in one Excel column and the corresponding probability numbers in another column. Could you please consider this?
link to original post
Unfortunately, I don't have Excel - I use LibreOffice for my spreadsheets, and I don't think it is compatible with VBA.
However, here is a CSV of the 134,459 hands that you can download.
In each row, the first 5 numbers are cards (0-12, 13-25, 26-38, and 39-51 are the 13 cards in each suit), and the sixth is the number of times it appears in the 2,598,960 possible hands.
If you are listing 7 card hands and five card flushes are the minimum length you are interested in then you can write algorithms for the number of combinations and their probability for A8532 hands that have
- no flushes
- 5 card flushes
-6 card flushes
-7 card flushes
Quads - 156
F H - 156
Trips - 858
2 P - 858
P - 2860
Flush - 1287 (some may be straights as well)
Non-Fl = 1287 (some may be straights)
Sometimes, perhaps when playing against the Dealer, perhaps needing to know whether they qualify, you need to know the suits used. This is probably where the larger figures come from. For instance the Full House, it makes little difference - unless you're considering Dealer's upcard(s) - which suit is missing from the Trips part, but rather whether both suits of the pair match one of the trips, or only one. In this case AsAhAdKsKc is different from AsAhAdKsKh as the latter could be up against a Royal Flush in Clubs, whereas in the former, all oposing AKQJT are just straights.
Quote: acesideI've saved this CSV as an Excel file, but I'm still not clear which card number in 0-12 represents an Ace. is it 0 or 12? I want to convert it into a hand representation like this: Ac8d5h3s2c. Thank you.
link to original post
I use Ace = 0, Two = 1, ..., Queen = 11, King = 12, but you can actually use any of the 13! permutations of the ranks (for example, { 2, 5, 9, 3, Q, 7, 10, A, J, 4, K, 8, 6 }), provided you use the same permutation for each suit.
Quote: ssho88I thought there are only 7,462 distinct 5-card hands ?
link to original post
To follow up on what charliepatrick said, the suits of the cards that don't make up the value of the hand can be important.
For example, one of the "pair hands" is Ace, King, Queen, Queen, Jack - but one where the Ace, King, Jack, and one of the Queens are all the same suit, so you have 4 to a Royal Flush, is played differently than one that is, say, Ace of spades, King of hearts, Queen of clubs, Queen of diamonds, and Jack of hearts.
Quote: ThatDonGuyQuote: acesideI've saved this CSV as an Excel file, but I'm still not clear which card number in 0-12 represents an Ace. is it 0 or 12? I want to convert it into a hand representation like this: Ac8d5h3s2c. Thank you.
link to original post
I use Ace = 0, Two = 1, ..., Queen = 11, King = 12, but you can actually use any of the 13! permutations of the ranks (for example, { 2, 5, 9, 3, Q, 7, 10, A, J, 4, K, 8, 6 }), provided you use the same permutation for each suit.
link to original post
I’m not so sure about this part because the card Ace is so special in poker, as in a straight, an Ace can be used as either the highest rank or the lowest rank.
Quote: acesideQuote: ThatDonGuyQuote: acesideI've saved this CSV as an Excel file, but I'm still not clear which card number in 0-12 represents an Ace. is it 0 or 12? I want to convert it into a hand representation like this: Ac8d5h3s2c. Thank you.
link to original post
I use Ace = 0, Two = 1, ..., Queen = 11, King = 12, but you can actually use any of the 13! permutations of the ranks (for example, { 2, 5, 9, 3, Q, 7, 10, A, J, 4, K, 8, 6 }), provided you use the same permutation for each suit.
link to original post
I’m not so sure about this part because the card Ace is so special in poker, as in a straight, an Ace can be used as either the highest rank or the lowest rank.
link to original post
This works even with deuces wild. It is the hands that are unique; what each one is worth is up to the software to figure out.
For example, the hand "four deuces and a 3" occurs 4 times (once for each 3) in the deck, but the hand is:
* Jacks or Better: four of a kind
* Bonus Poker: four 2s-4s
* Double Bonus: four 2s-4s and an Ace-4 kicker
* Deuces Wild: four deuces
Think of it this way: arrange the 13 cards of a suit. Does it matter if the Ace is the second or the 10th card in the order?
Quote: charliepatrick^ You probably need the cards in order just in case you need to find straights, identify specific cards (e.g. Pair Aces+ sidebets) or compare hands with the Dealer. I know checking for A2345 (or similar) is a pain!
link to original post
While it helps to find straights if the cards are in order, they don't "need to be" in order.
You do need the Aces, for example, to be in the same position within each of the four suits - at least, you do in the way I was taught to construct the 134,459 hands.
Quote: charliepatrick^ You probably need the cards in order just in case you need to find straights, identify specific cards (e.g. Pair Aces+ sidebets) or compare hands with the Dealer. I know checking for A2345 (or similar) is a pain!
link to original post
There's an easy way! Assign a prime, assign a prime, assign a prime (hey it rhymes!) to each rank. Then calculate the product of the primes for all 10 straights (assuming a 5 card hand) and if the product of the primes for your 5 cards matches any of those, you have a straight. You can use that to determine the rank of the straight too.
Hey, that might be a good way to compare hands in all single deck poker type games. You assign a prime to all 52 cards, then write an auxiliary program to calculate the product of primes for all 5 (or 4, or 3) card poker hands and rank them. So the 4 royals would all be ranked 1, the Dog straight flushes would all be ranked 2, Q8 straight flushes would be ranked 3, four aces would be ranked 11, etc. A lot of work but you only have to run that once, then comparing hands without doing any rearranging of cards can be done in a one-liner of a procedure.
Quote: AutomaticMonkeyQuote: charliepatrick^ You probably need the cards in order just in case you need to find straights, identify specific cards (e.g. Pair Aces+ sidebets) or compare hands with the Dealer. I know checking for A2345 (or similar) is a pain!
link to original post
There's an easy way! Assign a prime, assign a prime, assign a prime (hey it rhymes!) to each rank. Then calculate the product of the primes for all 10 straights (assuming a 5 card hand) and if the product of the primes for your 5 cards matches any of those, you have a straight. You can use that to determine the rank of the straight too.
Hey, that might be a good way to compare hands in all single deck poker type games. You assign a prime to all 52 cards, then write an auxiliary program to calculate the product of primes for all 5 (or 4, or 3) card poker hands and rank them. So the 4 royals would all be ranked 1, the Dog straight flushes would all be ranked 2, Q8 straight flushes would be ranked 3, four aces would be ranked 11, etc. A lot of work but you only have to run that once, then comparing hands without doing any rearranging of cards can be done in a one-liner of a procedure.
link to original post
This is what I did in the poker game simulation.
You have either a fresh deck or a deck with some cards removed.
Five cards are dealt that will make a five card poker hand.
For each combination of five distinct ranks (AKQJT ... Q9753...... 65432) you can calculate the probability that those 5 ranks are suited (a five card flush) or unsuited. That reduces 1,317,888 distinct hands to 1,287*2 hands to evaluate.
Obviously for a hand with paired ranks such as AA-982 or 5544-Q, they cannot form a flush, so the exact suits of the cards are irrelevant. So you may ignore all the variations in suits.
This is called "suit folding". It reduces the number of combinations you need to deal with in a spreadsheet or a program by a factor of several hundred.
Quote: acesideI’v read a little about the techniques for distinguishing these distinct 5-card poker hands. It seems like they use a canonical ID to mark each poker hand. A different ID means a unique hand, so computer will do the calculation for you.
Yes, that's one way to do the calculations, with computer software and a brute force approach of millions of distinct hands. Nothing wrong with that. I'm just pointing out that using combination theory there are ways to greatly reduce the number of hands into "lumped categories" dependent on what you wish to learn from the analysis.

