Thread Rating:

7up
7up
  • Threads: 3
  • Posts: 39
Joined: May 22, 2010
May 22nd, 2010 at 2:59:02 AM permalink
How 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.
miplet
miplet
  • Threads: 5
  • Posts: 2187
Joined: Dec 1, 2009
May 22nd, 2010 at 7:55:32 AM permalink
Quote: 7up

How 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?
“Man Babes” #AxelFabulous
JB
Administrator
JB
  • Threads: 334
  • Posts: 2089
Joined: Oct 14, 2009
May 22nd, 2010 at 8:30:58 AM permalink
I 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.
7up
7up
  • Threads: 3
  • Posts: 39
Joined: May 22, 2010
May 22nd, 2010 at 10:15:07 AM permalink
Quote: miplet

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: JB

I 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.
JB
Administrator
JB
  • Threads: 334
  • Posts: 2089
Joined: Oct 14, 2009
May 22nd, 2010 at 11:43:45 AM permalink
Quote: 7up

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.



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?
7up
7up
  • Threads: 3
  • Posts: 39
Joined: May 22, 2010
May 22nd, 2010 at 1:16:11 PM permalink
Quote: JB

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?


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
***
7up
7up
  • Threads: 3
  • Posts: 39
Joined: May 22, 2010
May 22nd, 2010 at 1:19:32 PM permalink
Oops! All the tabs gone.
JB
Administrator
JB
  • Threads: 334
  • Posts: 2089
Joined: Oct 14, 2009
May 22nd, 2010 at 1:21:57 PM permalink
Quote: 7up

Oops! 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.
7up
7up
  • Threads: 3
  • Posts: 39
Joined: May 22, 2010
May 22nd, 2010 at 2:08:15 PM permalink
Thank you so much, JB!
Have to take some time to digest it and try on it.
7up
7up
  • Threads: 3
  • Posts: 39
Joined: May 22, 2010
May 23rd, 2010 at 5:08:11 AM permalink
Now the time drops to 0.31 seconds.
Thanks again!
maglex96
maglex96
  • Threads: 0
  • Posts: 2
Joined: Apr 26, 2017
April 26th, 2017 at 3:13:26 AM permalink
Dear 7UP

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
gordonm888
Administrator
gordonm888
  • Threads: 68
  • Posts: 5997
Joined: Feb 18, 2015
Thanked by
LuckyPhowMission146
April 26th, 2017 at 9:16:35 AM permalink
Not 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.
So many better men, a few of them friends, are dead. And a thousand thousand slimy things live on, and so do I.
QFIT
QFIT
  • Threads: 1
  • Posts: 315
Joined: Feb 12, 2010
April 26th, 2017 at 2:26:24 PM permalink
I threw together a variation using as many of your variables as I could in Basic that runs in one-thousandth of a second on my PC. It's in floating point and should be faster in integer.


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
"It is impossible to begin to learn that which one thinks one already knows." -Epictetus
QFIT
QFIT
  • Threads: 1
  • Posts: 315
Joined: Feb 12, 2010
April 27th, 2017 at 8:50:23 AM permalink
Cut another 40% off. Now 0.0006 second. I love speed.


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"
Last edited by: QFIT on Apr 27, 2017
"It is impossible to begin to learn that which one thinks one already knows." -Epictetus
QFIT
QFIT
  • Threads: 1
  • Posts: 315
Joined: Feb 12, 2010
April 27th, 2017 at 9:52:01 AM permalink
Cut it another 70% to 0.00017 second. Edited above code.
"It is impossible to begin to learn that which one thinks one already knows." -Epictetus
QFIT
QFIT
  • Threads: 1
  • Posts: 315
Joined: Feb 12, 2010
April 28th, 2017 at 9:44:51 AM permalink
Cut it to under one ten-thousandth of a second (0.000092 second). That fast enough.:) Can't edit my old post, so code added here:


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"
"It is impossible to begin to learn that which one thinks one already knows." -Epictetus
Mission146
Mission146
  • Threads: 142
  • Posts: 16832
Joined: May 15, 2012
April 29th, 2017 at 9:13:03 AM permalink
Quote: gordonm888

Not 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!
https://wizardofvegas.com/forum/off-topic/gripes/11182-pet-peeves/120/#post815219
maglex96
maglex96
  • Threads: 0
  • Posts: 2
Joined: Apr 26, 2017
October 13th, 2020 at 9:07:13 AM permalink
I am trying to implement your algorithm in pascal /delphi. I am also trying to do it for each draw in the shoe not just the initial start as you have done. Looking at your iterations there are a few variables that you derive that are unknown to me.

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
USpapergames
USpapergames
  • Threads: 18
  • Posts: 807
Joined: Jun 23, 2020
November 30th, 2020 at 6:31:49 AM permalink
Quote: 7up

How 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.
Math is the only true form of knowledge
Wizard
Administrator
Wizard
  • Threads: 1542
  • Posts: 28054
Joined: Oct 14, 2009
November 30th, 2020 at 6:44:56 AM permalink
Welcome back USPG! Hope to see you in the easy math puzzle thread.
"My life is spent in one long effort to escape from the commonplace of existence. These little problems help me to do so." -- Sherlock Holmes
USpapergames
USpapergames
  • Threads: 18
  • Posts: 807
Joined: Jun 23, 2020
December 1st, 2020 at 9:55:33 AM permalink
Quote: Wizard

Welcome 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?
Math is the only true form of knowledge
ssho88
ssho88
  • Threads: 59
  • Posts: 698
Joined: Oct 16, 2011
February 25th, 2026 at 3:25:13 AM permalink
Quote: USpapergames

Quote: 7up

How 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?
gordonm888
Administrator
gordonm888
  • Threads: 68
  • Posts: 5997
Joined: Feb 18, 2015
February 25th, 2026 at 5:25:38 AM permalink
Quote: ssho88

Quote: USpapergames

Quote: 7up

How 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.
So many better men, a few of them friends, are dead. And a thousand thousand slimy things live on, and so do I.
aceside
aceside
  • Threads: 2
  • Posts: 965
Joined: May 14, 2021
February 25th, 2026 at 8:32:40 PM permalink
I’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.
ThatDonGuy
ThatDonGuy
  • Threads: 136
  • Posts: 7683
Joined: Jun 22, 2011
Thanked by
aceside
February 26th, 2026 at 6:52:39 AM permalink
Quote: aceside

I’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.
aceside
aceside
  • Threads: 2
  • Posts: 965
Joined: May 14, 2021
February 26th, 2026 at 4:52:28 PM permalink
I 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?
ThatDonGuy
ThatDonGuy
  • Threads: 136
  • Posts: 7683
Joined: Jun 22, 2011
February 26th, 2026 at 6:26:34 PM permalink
Quote: aceside

I 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.
aceside
aceside
  • Threads: 2
  • Posts: 965
Joined: May 14, 2021
February 26th, 2026 at 8:19:08 PM permalink
I'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.
gordonm888
Administrator
gordonm888
  • Threads: 68
  • Posts: 5997
Joined: Feb 18, 2015
February 27th, 2026 at 5:37:18 AM permalink
Folding suits is a way to further reduce the number of combinations.

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
So many better men, a few of them friends, are dead. And a thousand thousand slimy things live on, and so do I.
ssho88
ssho88
  • Threads: 59
  • Posts: 698
Joined: Oct 16, 2011
February 27th, 2026 at 6:05:26 AM permalink
I thought there are only 7,462 distinct 5-card hands ?
charliepatrick
charliepatrick
  • Threads: 39
  • Posts: 3143
Joined: Jun 17, 2011
February 27th, 2026 at 6:21:40 AM permalink
^ Yes if you ignore the side-effects of which suit(s) were used to form the hand.
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.
ThatDonGuy
ThatDonGuy
  • Threads: 136
  • Posts: 7683
Joined: Jun 22, 2011
February 27th, 2026 at 6:38:53 AM permalink
Quote: aceside

I'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: ssho88

I 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.
aceside
aceside
  • Threads: 2
  • Posts: 965
Joined: May 14, 2021
February 27th, 2026 at 9:12:43 AM permalink
Quote: ThatDonGuy

Quote: aceside

I'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.
charliepatrick
charliepatrick
  • Threads: 39
  • Posts: 3143
Joined: Jun 17, 2011
February 27th, 2026 at 9:52:13 AM permalink
^ 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!
ThatDonGuy
ThatDonGuy
  • Threads: 136
  • Posts: 7683
Joined: Jun 22, 2011
February 27th, 2026 at 10:08:56 AM permalink
Quote: aceside

Quote: ThatDonGuy

Quote: aceside

I'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?
ThatDonGuy
ThatDonGuy
  • Threads: 136
  • Posts: 7683
Joined: Jun 22, 2011
February 27th, 2026 at 10:11:50 AM permalink
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.
AutomaticMonkey
AutomaticMonkey
  • Threads: 21
  • Posts: 1564
Joined: Sep 30, 2024
February 27th, 2026 at 10:38:35 AM permalink
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.
ssho88
ssho88
  • Threads: 59
  • Posts: 698
Joined: Oct 16, 2011
February 27th, 2026 at 5:26:15 PM permalink
Quote: AutomaticMonkey

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.
link to original post



This is what I did in the poker game simulation.
gordonm888
Administrator
gordonm888
  • Threads: 68
  • Posts: 5997
Joined: Feb 18, 2015
February 28th, 2026 at 5:31:57 AM permalink
What I meant was that you can develop algorithms for this kind of calculation:

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.
So many better men, a few of them friends, are dead. And a thousand thousand slimy things live on, and so do I.
aceside
aceside
  • Threads: 2
  • Posts: 965
Joined: May 14, 2021
February 28th, 2026 at 6:22:32 AM permalink
I’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.
gordonm888
Administrator
gordonm888
  • Threads: 68
  • Posts: 5997
Joined: Feb 18, 2015
February 28th, 2026 at 7:18:56 AM permalink
Quote: aceside

I’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.
So many better men, a few of them friends, are dead. And a thousand thousand slimy things live on, and so do I.
  • Jump to: