Brain Candy #94 - A Penny Here, A Penny There

Brain Candy #94 - A Penny Here, A Penny There

I mentioned in the last column that Catherine and I had just returned from a short trip to Las Vegas - our first. I saw something there that was new to me, and it sparked my imagination. Here's what it was - a video poker machine, but with a twist.

I've had some experience with both poker and video poker. Catherine and I have visited casinos other than Las Vegas. I've played a fair amount of video poker and had pretty much given it up as boring. The difference is this machine supports multi-play, which is multiple independent draws to the initial hand. Like a normal draw poker machine, you are dealt five cards and you then decide what to discard. On multi-play machines, rather than drawing against a single instance of your hand, you draw once against three, five, ten, fifty or one hundred instances of that hand, depending on the machine. Playing on a standard video poker machine, if you drew four cards to a royal flush, the most valuable hand in non-wildcard poker, you would throw away the junk card and draw one more, hoping to hit the fifth card and a big payoff. On the average, one time in forty-seven, you would succeed. On a one hundred play machine, you would get one hundred separate draws of one card to fill each hand. Chances are pretty good you would fill the royal flush once or twice, and maybe more. This would result in a big payout, since on the best paying machines, that hand pays off 800-to-1. Of course, if your initial five cards were junk, you would get 100 separate draws to improve your one-hundred junk hands. In single-play video poker, in this case, you would usually fail to get a paying hand and lose your entire bet. The one hundred play machine would give you some winners, and typically pay back around 35% of your initial bet. There is of course a catch. One hundred hands requires at least one hundred coins and typical machines only pay out that critical 800-to-1 bonus for a royal flush if you play five coins per hand. On a penny machine at five coins per hand, this amounts to $5 per hand. A frugal player would want to think things through a bit before sitting down and starting to feed one of these machines.

I intended to go back and give one of these machines a try, but when I went to look for one, I couldn't find one - they didn't seem to be very common. Not knowing exactly what payouts were reasonable, it was probably best that I didn't find one. When I got back to Akron, I decided I want to look into a simulator. I could buy one, but where's the fun in that? I can program, after all, and being easily amused when it comes to programs that use random numbers, I decided I would write my own. I made an unusual choice when I decided what language to use - I chose to use Visual Basic for Applications (VBA), specifically for Microsoft Excel.

There wasn't anything automatic, or even reasonable, about this choice. I know better languages for the task, but I've been looking for novel programming projects for Excel both to build my skills and to condense what I know into some good demonstrations. When I use Excel for work, most of the macros I write aren't very big and do specialized tasks that most people don't need to do. There were some possible problems with choosing Excel, too. The resulting simulation might be too slow, it might be inflexible and not very useful, or it might be hard to write. None of these turned out to be true.

I won't go into too much detail about the process. I decided after some reading that VBA's built-in random number generator was probably not too flawed to use, but I picked up an add-in from the Numerical Technologies homepage at www.numtech.com that implements one of the finest pseudo-random number generators available, the Mersenne Twister, for Excel. Besides being far superior to VBA's built-in generator, it is faster, too.

The initial drafts of the program were very fast. After adding bells and whistles, like actual card symbols for the suits to each card in each hand, detailed hand scoring, and the like, the speed dropped somewhat, but the simulator still cranks out two hundred hands per second on a recent version of Excel running on a six-month-old PC. In other words, for a one hundred hand version of the game, it takes an insignificant time to generate and score all the hands and update the totals - well under a second.

As far as I know, casino machines have one hundred hands as an upper limit for multiplay. My Excel simulator isn't so limited, and to investigate the statistics of various situations, I can, by changing one number in the program, play more hands. I've often run it set to 50,000 hands. It takes about five minutes to resolve, but I get a more accurate estimate of the probabilities. To play such a machine, if it existed, at five cents per draw, would cost $2,500 per hand.

I've actually found that by setting the simulator to one thousand hands multiplay, and running a situation three to five times, I get a quicker estimate of what happens in a given situation. I take some notes and compare future results with what I've observed to get rough probability tables. For those situations that require it, I can run the larger simulation, as many times as I need to.

None of the strategy or probabilities in multi-play draw poker actually change from single hand draw poker. You're just playing a condensed version, where the luck of the draw is evened out somewhat, due to the large number of hands played. What doesn't change is how lucky you are in drawing your initial five cards - a run of bad luck on initial draws lets this variant empty your wallet pretty quickly.

With a bit more tinkering, I may release this code someday on my personal web site. I find myself still changing it a lot, adding new features, optimizing and improving. If I ever get it done and do release it, I'll let you all know.

More Brain Candy | Back to Brain Candy Central | Return to the CATBAR Main Page.

CATBAR - Brain Candy #94 - A Penny Here, A Penny There / Brian Rock / Aug 18 2005