work in progress blackjack side bet analysis tool

sagefr0g

Well-Known Member
#21
nightspirit said:
Sonny, thanks for the great posts! And thanks Blazin for sharing the code!



Hey Fr0g, maybe the short programs of T-Hopper are something for you: http://www.bjmath.com/bin-cgi/bjcomputer.pl?noframes;read=1042 (Archive copy) Python is open source and free available here. Save the code in .py file and run it. But change the expression "whrandom" to "random" before you do so. Pay attention to the white space, that's VERY import in Python! ;) There are a lot more versions of T-Hopper's PyBJ. Use Google and search for:
Code:
site:www.bjmath.com PyBJ t-hopper
very interesting nightspirit, thanks much.
python probably a steep learning curve for me, lol, but just seeing the code is cool.
 

sagefr0g

Well-Known Member
#22
Sonny said:
Here’s a slow but intuitive way to do pair splits:

Code:
if (hand is soft) {
   // Split to a new hand here (split cards and add another bet)
   do {
      // Look at the hit card
      if (hit card is another ace && allowed to re-split)
         // Re-split to another hand
      else {
         // Hit the current hand once
         // Move to next hand
   } while (currentHand <= totalHands)
} else {
   if (BS says to split) {
      // Split to a new hand
      do {
         // Look at the hit card
         if (hit card is the same rank && still allowed to split)
            // Re-split to another hand
         else {
            // Hit the current hand once
            // Move to next hand
      } while (currentHand <= totalHands)
   }
   // Handle double downs
   // Handle hits
}

// Do payouts
The code assumes that you will always split aces and that any hand you split will also be re-split, although that could easily be changed. The majority of the code will depend on the variables and structures that your program uses so all I can really give is a basic framework for the routines. I’m sure there are much better ways to do it, but that’s all I got for you.

-Sonny-
well, i decided to try and create a simulator. :eek::rolleyes::laugh:
this is gonna be helpful for me once i get to splits.

i have my program working ok for hard hands.
do you have similar logic for how to treat aces?
i mean, the logic as far as how aces are valued at either one or eleven?
basic framework sort of thing like you had above is fine.
 

rrwoods

Well-Known Member
#23
sagefr0g said:
very interesting nightspirit, thanks much.
python probably a steep learning curve for me, lol, but just seeing the code is cool.
Python rocks :) It's probably my second-favorite programming language. The whitespace dependence may or may not have anything to do with that... *whistles*
 

nightspirit

Well-Known Member
#24
rrwoods said:
Python rocks :) It's probably my second-favorite programming language. The whitespace dependence may or may not have anything to do with that... *whistles*
Yeah Python is a fine language. ;) And there are so many good tutorials all over the web. I tried it after reading Eric S. Raymond's article "Why Python?"

I would also like to mention that Steven S. Lott wrote a few good (and free) Python books with a emphasis in casino games: Building Skills Books (Archive copy)
 

Sonny

Well-Known Member
#25
sagefr0g said:
do you have similar logic for how to treat aces?
i mean, the logic as far as how aces are valued at either one or eleven?
There are a few different ways to handle aces. One way is to count them as 11 from the beginning, then permanently subtract 10 points if the player busts. Another way is to count them as 1, then temporarily add 10 points unless the total is greater than 21. Those are two of the most intuitive ways to do it.

-Sonny-
 

sagefr0g

Well-Known Member
#26
Sonny said:
There are a few different ways to handle aces. One way is to count them as 11 from the beginning, then permanently subtract 10 points if the player busts. Another way is to count them as 1, then temporarily add 10 points unless the total is greater than 21. Those are two of the most intuitive ways to do it.

-Sonny-
thanks, that might help me figure it out. like below i had to comment out the else part that makes an ace =1, otherwise the program gives the player cards valued at one in almost every field, lmao.
gotta find a way around that, lol.
Sub checkplayerace()
'
' checkplayerace Macro
'
'
Range("AA21").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-25]:RC[-1])"
If Range("B21") = "A" And Range("AA21").Value + 11 <= 21 Then
Range("B21").Value = 11
'Else: Range("B21").Value = 1
End If
If Range("C21") = "A" And Range("AA21").Value + 11 <= 21 Then
Range("C21").Value = 11
'Else: Range("C21").Value = 1
End If
If Range("D21") = "A" And Range("AA21").Value + 11 <= 21 Then
Range("D21").Value = 11
'Else: Range("D21").Value = 1
End If
If Range("E21") = "A" And Range("AA21").Value + 11 <= 21 Then
Range("E21").Value = 11
'Else: Range("E21").Value = 1
End If
If Range("F21") = "A" And Range("AA21").Value + 11 <= 21 Then
Range("F21").Value = 11
'Else: Range("F21").Value = 1
End If
If Range("G21") = "A" And Range("AA21").Value + 11 <= 21 Then
Range("G21").Value = 11
'Else: Range("G21").Value = 1
End If
If Range("H21") = "A" And Range("AA21").Value + 11 <= 21 Then
Range("H21").Value = 11
'Else: Range("H21").Value = 1
............................. .............
 

Attachments

k_c

Well-Known Member
#27
sagefr0g said:
thanks, that might help me figure it out. like below i had to comment out the else part that makes an ace =1, otherwise the program gives the player cards valued at one in almost every field, lmao.
gotta find a way around that, lol.
You could store the player's hand in an array. Player's hand could conceivably consist of 21 cards, so define playerHand array of 21 elements.

playerHand(1) will contain first card rank value, playerHand(2), will contain second card rank value, and so on.

'You could do this:
'Dim playerHand(21) As Integer 'defines static array of 22 elements
'but you might want to reset player hand so instead you might want to use
'a dynamic array as below

Code:
Dim n As Integer 'initialized to 0 in VBA
Dim playerHandVal As Integer 'initialized to 0 in VBA
Dim aceFlag As Boolean 'initialized to False in VBA
Dim playerHand() As Integer 'array; we'll set dimensions shortly

ReDim playerHand(21) 'sets/resets 22 array elements to 0 (elements 0 to 21)

'assume player hand is stored in elements 1 to 21 and element 0 is not used
'example: if hand consist of 4 cards, elements 1 to 4 will be non-zero
'and elements 0 and 5 to 21 will be 0
For n = 1 To 21
	playerHandVal = playerHandVal + playerHand(n)

	If playerHand(n) = 1 Then 'card is an ace
		aceFlag = True
	End If

	If playerHand(n) = 0 Then Exit For 'exit loop if no more cards in player hand
Next n

'if hand value is less than or equal to 11 and contains an ace, add 10 to the hand
If playerHandVal <= 11 Then
	If aceFlag Then
		playerHandVal = playerHandVal + 10
	End If
End If

'at this point playerHandVal will contain the value of player's hand
 

sagefr0g

Well-Known Member
#28
k_c said:
You could store the player's hand in an array. Player's hand could conceivably consist of 21 cards, so define playerHand array of 21 elements.

playerHand(1) will contain first card rank value, playerHand(2), will contain second card rank value, and so on.

'You could do this:
'Dim playerHand(21) As Integer 'defines static array of 22 elements
'but you might want to reset player hand so instead you might want to use
'a dynamic array as below

Code:
Dim n As Integer 'initialized to 0 in VBA
Dim playerHandVal As Integer 'initialized to 0 in VBA
Dim aceFlag As Boolean 'initialized to False in VBA
Dim playerHand() As Integer 'array; we'll set dimensions shortly

ReDim playerHand(21) 'sets/resets 22 array elements to 0 (elements 0 to 21)

'assume player hand is stored in elements 1 to 21 and element 0 is not used
'example: if hand consist of 4 cards, elements 1 to 4 will be non-zero
'and elements 0 and 5 to 21 will be 0
For n = 1 To 21
	playerHandVal = playerHandVal + playerHand(n)

	If playerHand(n) = 1 Then 'card is an ace
		aceFlag = True
	End If

	If playerHand(n) = 0 Then Exit For 'exit loop if no more cards in player hand
Next n

'if hand value is less than or equal to 11 and contains an ace, add 10 to the hand
If playerHandVal <= 11 Then
	If aceFlag Then
		playerHandVal = playerHandVal + 10
	End If
End If

'at this point playerHandVal will contain the value of player's hand
wow, ok that's like a whole other way of treating aces. i appreciate the information.
what ever i did, some how i got aces working for now, except for splitting them and splitting everything else. that's next, and from what Canceler was saying that's really gonna be fun. :eek::whip:
 

N&B

Well-Known Member
#29
One of my favorite shortcuts for shoe dealt BJ from back in the mid 80's using Basic was the old reliable: 7 cards unbusted wins :grin:
 

sagefr0g

Well-Known Member
#30
progress..... so far

so far the images below give an idea of how my simulator is shaping up.
the images don't show how slow it is or all the mistakes it makes that still have to be fixed, lol.
still haven't done splits or competed handling the dealer hands.:rolleyes::whip:

the bottom two screens is where the data would be handled. currently i've got cvbj data in there, lol.

the one part that records results is the part Canceler helped me with.
thanks Canceler. :)
 

Attachments

sagefr0g

Well-Known Member
#31
re-inventing the wheel.... progress report

ten days after reporting having just a few errors to clean up regarding dealing with aces, the simulator finally handles aces properly, lol.
so now i can start the really fun part, handling splits.:rolleyes::eek::whip:
guess i'll report back in, uhmm, i dunno, six months? lmao.
 
Top