See the top rated post in this thread. Click here

Results 1 to 13 of 13

Thread: Simulation Code in Python

  1. #1


    Did you find this post helpful? Yes | No

    Simulation Code in Python

    I have a software simulator for playing blackjack that allows me to test not only basic strategy, but card counting strategies as well, playing tens of millions of hands in a few hours, and allows me to play multiple hands. It also allows for interactive simulation (which I put in to debug it, originally). It allows however many decks you want, and the shoe to be reshuffled when down tow a user-specified percentage. The output is of the sort like:

    Here we have BasicStrategyFourOrMoreDecks() with the following, Vegas parameters:

    twohands = False #you can play one hand or two at the table
    decks = 6
    dealsbettoplay = 10000000 # if noninteractive, how many deals that are bet upon to play till stopping - under some counting strategies, bet size can be 0 thus hand wont count towards stopping
    reshuffle_percent_left = .6 #60% should be the minimum and 66% is more the average in Vegas.
    dealerstandson = 17 #dealer stands on soft
    youmaydoubleaftersplit = True #most casinos throughout the world do not allow a double after a split, but Vegas does


    Wins, player = 5080405.000000 dealer = 5014934.000000 edge = 0.006485 hands played = 10000000 hands bet = 10000000 deals bet = 10000000 deals = 10000000
    WinPcnt = 0.483131 Avg.Amt = 1.183331 LosePcnt = 0.516869 Avg.Amt = -1.091760
    Expectation = 0.007407

    As you can see, from above, my numbers on these simulations are a tad too optimistic -- which makes a world of difference. I need the software for an academic paper I am writing on multiple-simultaneous wagering (where there is a positive expectation) but I need to discern where, in the rules of blackjack, this tiny advantage is creeping in.

    Would anyone be interested in this software (it's the python source code, version >= 3.2 which is on most linux machines and freely installable on most other machines). I dont know where the small advantage is creeping in on. The software allows on to program in and run simulations on various counting strategies, etc. Right now I have basi strategy in it and Rever Plus Minus, but it is quite simple to put in other strategies, insurance decisions, etc.

    If interested, please email me off-list rvince99 at hotmail dot com. I'm hoping someone can run this in simulatoin mode and see where the rules are messed up and causing this slight advantage. Thanks. Ralph

  2. #2
    Random number herder Norm's Avatar
    Join Date
    Dec 2011
    Location
    The mote in God's eye
    Posts
    12,461
    Blog Entries
    59


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No
    Quote Originally Posted by rvince View Post
    playing tens of millions of hands in a few hours
    CVData can run thirty million rounds in one second.
    "I don't think outside the box; I think of what I can do with the box." - Henri Matisse

  3. #3


    Did you find this post helpful? Yes | No
    Quote Originally Posted by rvince View Post
    I have a software simulator for playing blackjack that allows me to test not only basic strategy, but card counting strategies as well, playing tens of millions of hands in a few hours, and allows me to play multiple hands. It also allows for interactive simulation (which I put in to debug it, originally). It allows however many decks you want, and the shoe to be reshuffled when down tow a user-specified percentage. The output is of the sort like:

    Here we have BasicStrategyFourOrMoreDecks() with the following, Vegas parameters:

    twohands = False #you can play one hand or two at the table
    decks = 6
    dealsbettoplay = 10000000 # if noninteractive, how many deals that are bet upon to play till stopping - under some counting strategies, bet size can be 0 thus hand wont count towards stopping
    reshuffle_percent_left = .6 #60% should be the minimum and 66% is more the average in Vegas.
    dealerstandson = 17 #dealer stands on soft
    youmaydoubleaftersplit = True #most casinos throughout the world do not allow a double after a split, but Vegas does


    Wins, player = 5080405.000000 dealer = 5014934.000000 edge = 0.006485 hands played = 10000000 hands bet = 10000000 deals bet = 10000000 deals = 10000000
    WinPcnt = 0.483131 Avg.Amt = 1.183331 LosePcnt = 0.516869 Avg.Amt = -1.091760
    Expectation = 0.007407

    As you can see, from above, my numbers on these simulations are a tad too optimistic -- which makes a world of difference. I need the software for an academic paper I am writing on multiple-simultaneous wagering (where there is a positive expectation) but I need to discern where, in the rules of blackjack, this tiny advantage is creeping in.

    Would anyone be interested in this software (it's the python source code, version >= 3.2 which is on most linux machines and freely installable on most other machines). I dont know where the small advantage is creeping in on. The software allows on to program in and run simulations on various counting strategies, etc. Right now I have basi strategy in it and Rever Plus Minus, but it is quite simple to put in other strategies, insurance decisions, etc.

    If interested, please email me off-list rvince99 at hotmail dot com. I'm hoping someone can run this in simulatoin mode and see where the rules are messed up and causing this slight advantage. Thanks. Ralph
    I am not sure why you are using Python for simulating blackjack games, it was never designed for such purposes
    Chance favors the prepared mind

  4. #4


    Did you find this post helpful? Yes | No
    Quote Originally Posted by Norm View Post
    CVData can run thirty million rounds in one second.
    Norm,

    Yes, but I wanted to duplicate playing two hands at the same table (with a publicly available count strategy, so as to obtain a positve expectation on both hands that was realistic for Vegas rules, assuming a perfect card counter), and the existent software didn't seem to allow that.

  5. #5
    Random number herder Norm's Avatar
    Join Date
    Dec 2011
    Location
    The mote in God's eye
    Posts
    12,461
    Blog Entries
    59


    Did you find this post helpful? Yes | No
    Of course current software handles that.
    "I don't think outside the box; I think of what I can do with the box." - Henri Matisse

  6. #6


    Did you find this post helpful? Yes | No
    Quote Originally Posted by iCountNTrack View Post
    I am not sure why you are using Python for simulating blackjack games, it was never designed for such purposes
    Was wondering the same thing. Simulating is a very CPU-intensive exercise, and I would think an interpreted language like Python wouldn't be an ideal choice. I think Norm developed the CV products on Visual Basic, which is of course then compiled into assembly.
    Of course, if youre like me and like to do this kind of thing for ****s & giggles, go for it! All it takes is a Python interpreter and about 4 days free computing time
    "I put a dollar in, I won a car. I put a dollar in, I won a car.
    I put a dollar in, I won a car. I put a dollar in, I won a car."
    Nick Pappageorgio

  7. #7


    Did you find this post helpful? Yes | No

    Norm developed the CV products on Visual Basic ?

    Norm, are you really developed the CV products on Visual Basic ?

  8. #8
    Random number herder Norm's Avatar
    Join Date
    Dec 2011
    Location
    The mote in God's eye
    Posts
    12,461
    Blog Entries
    59


    Did you find this post helpful? Yes | No
    Yes, CV products were developed in VB.
    "I don't think outside the box; I think of what I can do with the box." - Henri Matisse

  9. #9


    Did you find this post helpful? Yes | No
    What RNG are you using in the simulation code ? mersenne twister ? How the source code look like ?

  10. #10
    Random number herder Norm's Avatar
    Join Date
    Dec 2011
    Location
    The mote in God's eye
    Posts
    12,461
    Blog Entries
    59


    Did you find this post helpful? Yes | No
    MarZam II. The RNG source code is posted somewhere in the AP.COM archives.
    "I don't think outside the box; I think of what I can do with the box." - Henri Matisse

  11. #11


    Did you find this post helpful? Yes | No
    MarZam II can be used in VB ?

  12. #12
    Random number herder Norm's Avatar
    Join Date
    Dec 2011
    Location
    The mote in God's eye
    Posts
    12,461
    Blog Entries
    59


    Did you find this post helpful? Yes | No
    Why not? VB can do most anything.
    "I don't think outside the box; I think of what I can do with the box." - Henri Matisse

  13. #13


    Did you find this post helpful? Yes | No
    Quote Originally Posted by rvince View Post
    I have a software simulator for playing blackjack that allows me to test not only basic strategy, but card counting strategies as well, playing tens of millions of hands in a few hours, and allows me to play multiple hands. It also allows for interactive simulation (which I put in to debug it, originally). It allows however many decks you want, and the shoe to be reshuffled when down tow a user-specified percentage. The output is of the sort like:

    Here we have BasicStrategyFourOrMoreDecks() with the following, Vegas parameters:

    twohands = False #you can play one hand or two at the table
    decks = 6
    dealsbettoplay = 10000000 # if noninteractive, how many deals that are bet upon to play till stopping - under some counting strategies, bet size can be 0 thus hand wont count towards stopping
    reshuffle_percent_left = .6 #60% should be the minimum and 66% is more the average in Vegas.
    dealerstandson = 17 #dealer stands on soft
    youmaydoubleaftersplit = True #most casinos throughout the world do not allow a double after a split, but Vegas does


    Wins, player = 5080405.000000 dealer = 5014934.000000 edge = 0.006485 hands played = 10000000 hands bet = 10000000 deals bet = 10000000 deals = 10000000
    WinPcnt = 0.483131 Avg.Amt = 1.183331 LosePcnt = 0.516869 Avg.Amt = -1.091760
    Expectation = 0.007407

    As you can see, from above, my numbers on these simulations are a tad too optimistic -- which makes a world of difference. I need the software for an academic paper I am writing on multiple-simultaneous wagering (where there is a positive expectation) but I need to discern where, in the rules of blackjack, this tiny advantage is creeping in.

    Would anyone be interested in this software (it's the python source code, version >= 3.2 which is on most linux machines and freely installable on most other machines). I dont know where the small advantage is creeping in on. The software allows on to program in and run simulations on various counting strategies, etc. Right now I have basi strategy in it and Rever Plus Minus, but it is quite simple to put in other strategies, insurance decisions, etc.

    If interested, please email me off-list rvince99 at hotmail dot com. I'm hoping someone can run this in simulatoin mode and see where the rules are messed up and causing this slight advantage. Thanks. Ralph
    I review the code you wrote above. I remember the first time I've used Python was for CNC Machine and 3D printing. Python it has G code and N codes not the code you listed above. I am not a programmer.

Similar Threads

  1. Could someone run a simulation for me please?
    By BigJer in forum General Blackjack Forum
    Replies: 4
    Last Post: 05-31-2013, 07:55 PM
  2. Replies: 2
    Last Post: 12-27-2004, 07:14 AM
  3. Damon: BlackJack Code
    By Damon in forum Blackjack Main
    Replies: 2
    Last Post: 09-30-2001, 12:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

About Blackjack: The Forum

BJTF is an advantage player site based on the principles of comity. That is, civil and considerate behavior for the mutual benefit of all involved. The goal of advantage play is the legal extraction of funds from gaming establishments by gaining a mathematic advantage and developing the skills required to use that advantage. To maximize our success, it is important to understand that we are all on the same side. Personal conflicts simply get in the way of our goals.