Blackjack or Roulette Simulator

Hello experts,

I am trying to find a freeware Blackjack or Roulette simulator that will double down losses (the "Martingale" theory).  I have been using the Sage Blackjack Simulator but the betting strategy is flat.  

My purpose is to simulate with different sized initial bankrolls and different sized inital bets to find the maximum bet ever made, the return, etc.

Any ideas?  I might just try to make my own in Excel, but I was hoping someone had already done this.

Who is Participating?
wytcomConnect With a Mentor Commented:
We could do this in VBA/Excel.  (I usually use AWK to create a command line program.  AWK is a precursor to Perl.  But I have been doing some VBA in Excel lately. )  The first step is to write a function to produce a binary win/loss outcome based on the "house edge".  

My understanding is that the probability, p, of a win for the player can be expressed in terms of the house edge h.

h = house edge = (hands played - hands won by player)/(hands played) - 1/2

So if player wins half the hands dealt then house edge is 0.

p = (hands won by player)/(hands played)

h = 1/2 - p

p = 1/2 - h

Given h, calculate p.  Then we need a function, getResultOfHand(p),  to return a win/loss or true/false based on probability p.  This can be built using the random number generator.  Say we generate a random number between 0 and 1.  If the value is less than or equal to p we return true, else false.

I can tinker with this some more tomorrow.  Perhaps you can see what you can come up with for the getResultOfHand(p) function in VBA.
I wrote a blackjack simulator that is used within the casino to train surveillance staff so they can detect card counters.  It deals 2 cards at random and then accepts the users choice of action.  The users choice is evaluated against a standard strategy.  This allows the surveillance staff to practice their ability to recognize play that is based on this standard strategy or not.

It sounds like you are looking to simulate a playing strategy and measure its characteristics.  Perhaps I will see what I can learn about the Martingale theory...
jesselavacaAuthor Commented:
That's correct.  I want to test a Martingale theory (every time you lose, you double your bet)...but I want to test in on thousands of hands in different playing styles to see the maximum bet that would be made over that period.  For example, with a $1000 bankroll and a $1 bet, how many hands on average would it take before you bet $1, 2, 4, 8, 16, 32, 64, 128, 256, 512, and then were wiped out of the bankroll.  

Supposedly, the only things limiting this betting strategy are guts/bankroll/casino table maximums.  I don't want to have to count cards, it's difficult and I prefer to play at a faster pace online.

As background information, I am finding reputable online casinos (an oxymoron?) that have huge incentives for players to sign up or come back (i.e. 200% initial deposit bonus).  I then use Martingale theory to play and use their bonuses/comps to help pad any losses.  I did this playing roulette in Vegas and did quite well, even getting asked to leave one casino unless I would change games or vary my style.


What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

could you tell me where to find these simulators, i was writing a program in matlab to compute some stats on blackjack, but have since gotten really busy and havne't had a chance to complete it.  thanks
jesselavacaAuthor Commented:
They have a freeware version that is somewhat limited...

After thinking about this, it turns out that you don't have to simulate the blackjack play to get the answers you want.  It really all depends just on the "house edge".  Based on the particular blackjack rules and the strategy chosen, a house edge value can be determined.  There are lots of places to find this kind of information.  I see that typical house edge values are about 0.50% (depending on the specifics of the rules and the playing strategy adopted.)

So what is needed is a simulation that provides a random sequence of win/loss outcomes by hand based on the house edge value.  This is pretty easy to do.  The input to the program would be the house edge in percent (say 0.50), and the number of games to play.  Then the output would be the overall winnings (based on a base bet of 1) and the max bet placed.

It would make sense to have the simulation always end on a winning hand too.  It wouldn't make much sense to end a session using the Martingale theory on a losing hand.

It would be better to have the simulation repeat the set of games many times and then produce the outputs as a distribution of values.  That way you could see how likely it is to reach a certain level of winnings and maximum bet.

I find this interesting and I think I will go ahead and code this.  It looks like about 4 hours of work total for me so I should have some results to report later this week.

Please let me know if this makes sense to you.
jesselavacaAuthor Commented:
That does make sense...quite a bit of sense.

What do you think you will code in?  VBA/Excel or something more along the lines of SAS?  I've done some basic simulations in Excel, and I might even be able to contribute something of my own here.

wytcomConnect With a Mentor Commented:
I did a quick program in awk tp produce some results.  I ran 100000 experiments with 100 hands dealt per experiment.  I used a house edge of 0.50 %

3 Columns.  
1st shows win amount and number of experiments with this result.
2nd shows max bet and number of experiments with this result.
3rd shows games played and number of experiments with this result.
(We play until have 1st win at 100 or more games.)

Win Loss            Max Bet         Games played
28 1         1048580 1          100 49787
29 1         2097150 1          101 24734
30 1               4 18         102 12606
31 5               8 2133       103 6396
32 14        8388610 1          104 3255
33 17             16 14242      105 1544
34 46             32 25257      106 848
35 67             64 23393      107 428
36 136           128 15575      108 191
37 292           256 9174       109 101
38 411           512 4921       110 48
39 709          1024 2529       111 28
40 1098         2048 1357       112 19
41 1567         4096 709        113 8
42 2193         8192 350        114 2
43 2919        16384 168        115 3
44 3832        32768 97         116 1
45 4867        65536 40         117 1
46 5812       131072 20
47 6697       262144 9
48 7458       524288 5
49 7696
50 8256
51 7852
52 7420
53 6533
54 5954
55 4774
56 3813
57 3003
58 2278
59 1579
60 1092
61 603
62 407
63 275
64 137
65 100
66 45
67 25
68 8
69 4
70 2
71 1
lidskyConnect With a Mentor Commented:
There is no such thing as a Martingale theory. What there is, is a Martingale system for losing money. :-)

I suggest you read this before pluncking your money on the table.
jesselavacaAuthor Commented:
I've been slammed at work and haven't had time to mess around in Excel/VBA, but I did get a chance to read the article.  It was a good read, thanks.


that was indeed a good article ....  

Perhaps I will go to Lost Wages Nevada to test the double-the-bet technique.

It is worthwhile to note that a statistical analysis is not a simulation....

It would be possible to write a good blackjack simulation  in VB6 ....
I think different casinos have some variation of the rules so a simulation
would apply based on a specific set of rules.

jesselavacaAuthor Commented:
Still busy at work...will look again at this later (this week?).  Thanks for the help...

Very interesting, Jess.  I'm considering the same thing.  I believe there are a couple of things you've missed in analyzing the problem.  What you have so far is correct, but...

You can't just quit after a win.  The max bet imposed by the casino stops this, and quitting after a win implies an unlimited

The house edge is closer to 5%, if you play straight.  If you use something, tables for instance, to 'improve' your play, you mess the Martingale system.  You can get the house edge down to .03%, apparently, but you have to use doubling down, insurance, and splitting to do it, and then you've messed the Martingale.

Perhaps you'd like to collaborate on this - I have the programming skills.  I am working on applying some futures trading methodologies to a similar theory.  You can reach me at cbarnett-AT-yahoo-DOT-com.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.