RAIN MAN 2.0 Uses Machine Learning to Count Cards in Blackjack

Counting cards is a method for calculating the odds of specific cards being drawn, and is most often used in games of blackjack played…

Counting cards is a method for calculating the odds of specific cards being drawn, and is most often used in games of blackjack played with a finite number of standard decks. The idea is that you keep track of the cards that have already been drawn and use that information to determine which cards are left in the deck. But that’s incredibly difficult to do mentally during a real game of blackjack, even if you’re only playing with a single deck of cards. That’s why YouTuber Edje Electronics has a built a machine learning system for counting cards, called RAIN MAN 2.0.

RAIN MAN 2.0 is, of course, named after the iconic 1988 film Rain Man starring Tom Cruise and Dustin Hoffman. In the movie, Hoffman plays an autistic savant named Raymond, AKA “Rain Man” who is able to count anything with remarkable accuracy — including cards. Naturally, his brother Charlie, portrayed by Cruise, takes advantage of that to count blackjack cards in Las Vegas for profit. RAIN MAN 2.0 is essentially doing the same thing, but with computer vision and machine learning.

To identify which cards have be placed on the table, RAIN MAN 2.0 uses the YOLO v3 machine learning detection model. That was trained on 50,000 images that were synthetically-generated from pictures Edje Electronics took of cards from many different angles and lighting conditions. After identifying cards, it’s a simple matter to have a Python script keep track of them and to deduce which cards are left in the deck. Right now, RAIN MAN 2.0 only works with a single deck of cards. But it would certainly be possible to rewrite the Python script to make it work with multiple decks. It is, however, running on a beefy desktop computer, so it’d be pretty difficult to bring it into a casino without anyone noticing.

Cameron Coward
Writer for Hackster News. Proud husband and dog dad. Maker and serial hobbyist. Check out my YouTube channel: Serial Hobbyism
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles