Backyard Brains Logo

Neuroscience for Everyone!

+1 (855) GET-SPIKES (855-438-7745)

items ()

Building a Poker Bot You Can’t Bluff: TinyML Gets All In!

poker bot you can't bluff
Skin galvanic sensor setup. Edit: you CAN play poker with these on!

—Written by Sachin Pillai—

This summer at Backyard Brains, I’m developing a Poker Bot trained via machine learning that can detect when players bluff and predict how risky a player’s hand is based on internal physiological reactions during the game.

A full month into the fellowship, I’ve already had substantial progress with my project! The first week of the program consisted of learning foundational theory and skills from experts in fields of neuroscience and computer science, and here’s a peek into everything I got from it:

  • Lessons that not only brought me up to speed on all the progress in these fields but were applicable later as I ran into challenges and began developing my project
  • I gained valuable insight into how to convert my ideas into actionable plans (this is MORE important than it sounds!)
  • I learned about soldering techniques, collecting my own EKG/EEG/EMG data, using Edge Impulse (software that records galvanic skin response) and SpikerBox (a tool I suspect you’re already familiar with).

The second week brought more focus on computer science, most importantly Python. Although I was somewhat fluent in several programming languages, I hadn’t used Python very much. The workshops led by BYB colleagues allowed me to hit the ground running and begin translating my ideas into action.

It was also at this time that I started becoming very comfortable with Edge Impulse and started having a lot of fun with smaller side projects just playing around with different AI models and finding ways to improve their accuracy.

Then I got to spend dedicated time in and out of the lab working on my project.

My first approach was to harness EEG (brain wave) data to allow the classification of bluff versus non-bluffing situations. It took me a few days to realize that not only was I unable to detect significant changes between bluff and non-bluff scenarios through brain waves, but that the signals themselves were difficult to work with and even collecting clean signals without noise proved to be a difficult task. Our brain has this neat way of bluffing its way out of EEG!

Inspired by what we are learning about Tiny ML, I decided to pack it up and move onto “smaller and better” things: the galvanic skin response. It’s an indirect method of measuring/inferencing stress levels in a patient. In moments of high-stress, the theory has it, our body will react with certain expected physiological patterns.

galvanic skin response screenshot from edge impulse
Edge Impulse data: galvanic skin response for a player who is bluffing during a round of poker. There is a rapid increase in stress followed by an even sharper decline!

One of these detectable patterns involve the release of sweat from sweat glands within the skin. With a greater presence of sweat on the epidermis, the skin’s surface becomes more conductive to electricity. These conductivity changes can be detected by electrodes placed on the skin. 

galvanic skin response explanation
Background/theory of the galvanic skin response and the parts of the skin it involves (image source: iMotions)

Research in the past has determined that the greatest variability in skin conductance to stress occurs on the fingers so I consequently decided to collect GSR data from the undersides of fingers using wearable electrodes. With galvanic skin response (GSR) data, I essentially hoped that increasing stress levels associated with bluffing would lead to fast and detectable changes in your skin’s electrical conductivity that would be detected by sensors.

Within a couple days of choosing to pursue the GSR data collection route, I was able to collect enough preliminary data that an Edge Impulse model was able to differentiate between bluffing and not bluffing with over 80% accuracy. Of course, since the data was only collected from myself and only 20 trials were used, there needs to be much more work completed to be confident in these results.

Another layer of complexity I am looking to add to this project is heart rate detection. I believe EKG data in conjunction with the GSR will provide increased accuracy in determining the presence of a bluff and providing an assessment of risk levels during a player’s current hand. Thus, I am also in the process of creating a mathematical model that essentially collects heart rate and skin response patterns and quantifies the data into a risk assessment scale.

In theory, the end goal of this project is to construct a portable device capable of detecting heart rate and reading the galvanic skin response in order to detect when a poker player is bluffing, and inform the player of when the body’s physiological signals indicate a higher level of risky play.

I’ll keep you posted on how my project is unraveling. More poker for me over the remaining 6 weeks!

online poker game with fake money
I play poker via PokerStars (and collect data while at it). Just so you know, the money here is FAKE.

About Me

A pre-medicine student studying Neuroscience with a minor in Artificial Intelligence and a Masters in Public Health, I’ve just completed my first year at Case Western Reserve University. I heard about the BYB Fellowship through one of my Neuroscience academic advisors and I’m so humbled to have a chance to explore my passions for biology, neuroscience, and computer science all at once.

But did I just wake up one morning and decide to build a poker bluff detector? 

Yes – and no! My passion for neuroscience is relatively newfound. All throughout middle school and high school, I was enamored with the human body and the mechanisms through which it functions. Studying the macro and micro levels of human biology gave me a certain sense of satisfaction as it made me feel more whole and garner a true appreciation for the complexity of my living, breathing self. This personal quest of attempting to understand how human beings work has led me to conduct wet-lab research in an Alzheimer’s and glaucoma laboratory at my school. It’s something I really enjoy and spend a lot of my time consumed in. Apart from academics, I’m a huge soccer buff, love playing the piano, and try my best to start Netflix shows without quitting halfway.

It’s already been four weeks in Ann Arbor and I couldn’t be more comfortable! I currently live in Portland, OR but I was born in Omaha, NE so it’s quite nice to be back in the Midwest after such a while. State Street has turned out to be one of the most lively yet relaxing places to be and I look forward to the weekends when cars are blocked off from entering and it feels like I’m walking around an amusement park.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.