By using listi.net you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes
listi.net
Odds of Dealer Busting based on Up Card
Intro
Run Once
Sub test_dealers_up_card()
gameover = False
Range("E:F") = ""
'a = Array(1, 3, 1, 2, 1)
duc = 0
'Range("B15") = Range("B15") + 1
Do Until gameover
i = i + 1
c = [randbetween(1,13)]
'c = a(i - 1)
If duc = 0 Then
duc = c 'Dealers Up Card
Range("dealer_up_card") = IIf(duc = 1, "A", IIf(duc = 11, "J", IIf(duc = 12, "Q", IIf(duc = 13, "K", duc))))
Cells(c + 1, 3) = Cells(c + 1, 3) + 1
End If
If c > 10 Then c = 10
Cells(i + 1, 5) = c
Total = Total + c
If c = 1 Then
alttotal = alttotal + c + 10
If alttotal > 21 Then
alttotal = alttotal - 10
End If
Else
alttotal = alttotal + c
End If
Range("F1") = alttotal
Range("E1") = Total
If (alttotal > 17 And alttotal < 22) Or Total > 16 Then
If alttotal > Total Then Total = alttotal
gameover = True
If Total > 21 Then
Cells(duc + 1, 2) = Cells(duc + 1, 2) + 1
End If
Else
If Total < 17 And alttotal < 18 Then
Else
alttotal = Total
Range("F1") = alttotal
End If
End If
Loop
End Sub
Run Many
Sub test_dealers_up_card_many()
Application.ScreenUpdating = False
i = [c15]
Do Until Range("I1") <> ""
i = i + 1
test_dealers_up_card
' 2 doevents below are needed for chart to refresh
'DoEvents
'DoEvents
If i = 100000 Then GoTo exit_here
If i Mod 1000 = 0 Then
Application.ScreenUpdating = True
DoEvents
DoEvents
Application.ScreenUpdating = False
End If
Loop
If [i1] <> "" Then
MsgBox "Stopped because cell I1 set to a value which stops the code"
End If
exit_here:
Application.ScreenUpdating = True
End Sub