Monday, February 16, 2015

Simulating a One-Armed Bandit

Posted by Jason Lillywhite

If you ever run into GoldSim employees in Las Vegas, you will never see them sitting in front of a slot machine. Dealing with probabilities on a daily basis gives us a feel for our odds when dealing with uncertainty. But what if we built a model that only simulates the one-armed bandit? This is the question I asked myself the other day when Rick mentioned the dice-rolling model. What I thought would end up to be a mere exercise in probabilities ended up in a little game that is almost as addicting as solitaire!

A slot machine is all about risk and this little model will give you a good idea of what I mean. A typical modern machine might have 256 virtual "stops" or images on 3 different reels that spin randomly each time you pull the lever. This gives the machine over 16 million (256^3) image combinations! Knowing that we might win the jackpot only after pulling the slot lever 16 million times is enough to discourage us.

While it might be a bad investment to play the slot machine in Vegas, it is never a bad investment to build a model of one. The other day, I built a simple model that simulates an old-style 3-reel jackpot machine and in doing so, learned a lot about using a dashboard to represent rapidly changing images. You can see the model in action in the short video clip below.



The point of this model is to try to win more money than you bet. You insert a coin by pressing the "Insert Coin" button and upon doing so, the "Spent" display updates to show you how much you've spent so far. Then you click on the "Pull" button to make the 3 reels turn independently and at random rotational speed. The images on the reels change as they spin. If you slow the reel speed down, you can see the reels start spinning fast and slow down over time until they finally stop and the light above the machine will show red or green depending on whether you win. A jackpot occurs when you get 3 of the same image and the light will display green and you will be notified that you won the jackpot! 



I split up the winnings into categories matching the different images as shown at the bottom of the machine. Winnings are as follows:
  • Cloudy: $1
  • Stop Sign: $5
  • Light Bulb: $30
  • Checkered Flag: $150
  • Blue Cylinder: $300 
With a 4% chance of getting one of the above images on all 3 reels, it only costs $6.25 on average to win something. I calculated the chance of winning by taking the number of images and setting that to the power of the number reels: 5^3 to determine the number of combinations of images. The inverse of this is the chance of getting 3 in a row of one type of image. Since I provide 5 different winning combinations, then the chance is 5 / (5^3) or 4%.

Yeah, you might only win $1 but on the other hand, maybe you will be one of the lucky ones to win the $300 jackpot! To take a chance and play the game, download the Player model from our library, here: http://www.goldsim.com/Library/ModelLibrary/Applications/RiskFailure/OneArmedBanditModel/. You can also download the GSM file to customize it to your liking. Good luck and happy gambling!

No comments:

Post a Comment