# The Effects of Card Counting on a Simple Card Game

Difficulty | |

Time Required | Short (2-5 days) |

Prerequisites | Some very basic computer programming experience |

Material Availability | Readily Available |

Cost | Very Low (under $20) |

Safety | No issues |

## Abstract

Do you like to play cards? Here's a project that will get you thinking about strategy in card games and help you become a better card player.## Objective

The objective of this project is to prove the best strategy for playing Hi-Lo using basic probability. Using computer simulations, you can verify that a particular strategy is correct and show what happens to the odds of winning when "counting cards."

## Credits

Edited by Andrew Olson, Ph.D., Science Buddies

## Cite This Page

### MLA Style

*Science Buddies*. Science Buddies, 30 June 2014. Web. 30 Sep. 2014 <http://www.sciencebuddies.org/science-fair-projects/project_ideas/Math_p044.shtml>

### APA Style

*The Effects of Card Counting on a Simple Card Game.*Retrieved September 30, 2014 from http://www.sciencebuddies.org/science-fair-projects/project_ideas/Math_p044.shtml

## Share your story with Science Buddies!

I Did This Project! Please log in and let us know how things went.Last edit date: 2014-06-30

## Introduction

Hi-Lo is a very simple card game. A dealer ("the house") starts with a deck of cards and turns over the top card. The player then guesses whether the next card in the deck will be higher or lower than that card. If the guess is correct, the player wins that round. If the guess is wrong, the house wins that round. If the two cards are equal, it's a tie: neither side wins or loses.

This process of turning over a card and guessing high or low continues through the rest of the deck. The best strategy allows the player to guess correctly more than 70% of the time. How do you go about finding that strategy?

This is where the math comes in! Probability theory is the branch of mathematics that deals with figuring out the likelihood of outcomes. With a simple card game like Hi-Lo, it is pretty easy to calculate probabilities. For example, let's say that the first card turned over was the two of spades (for the purposes of this project, our rule will be that aces are the lowest cards in the deck and kings are the highest cards). It's pretty obvious that our best guess would be that the next card would be higher, right? Probability theory gives us a way to measure just how good that guess is. In order to calculate the probability that our guess is correct, we need to figure out what the possible outcomes are.

A complete deck has 52 cards. We've turned over one card, so that leaves 51 more. Of these remaining cards, 7 (four aces and the other three 2's) are lower than or equal to a 2. That means that 44 (51−7) of the remaining cards are higher than a 2. So the probability of winning this round is 44/51 = 0.86. So our guess should be right 86% of the time in this situation. Another way to say this is that if we played a large number of games, then our guess would be correct 86% of the time (and wrong 14% of the time). From the example above, you can see how to calculate the probabilities for other situations in Hi-Lo. You should also be able to calculate the overall probability of guessing correctly, by averaging the probabilities for each possible first card.

Now let's take the example a little further. Suppose that we're halfway through the deck. If the deck was randomly shuffled at the beginning of the game, the odds should be the same at any point in the game, right? On the other hand, we've already seen the first 26 cards, so shouldn't that give us an advantage to increase our odds of guessing right? The trouble is, it's hard to remember all of the cards we've seen and recalculate the probabilities on the fly. Do you think there is a way to "count" the cards that have already been shown in order to increase the odds of guessing Hi-Lo correctly?

Your goal in this project is to write a computer program that will allow you simulate the game of Hi-Lo in order to test different guessing strategies. You'll compare a strategy that does not make use of information about previously shown cards (i.e., no "card counting") to one or more strategies that do make use of information about previously shown cards (i.e., one or more "card counting" strategies). Before getting started, you should do some background research on probability theory and card counting. Then you can decide on what strategies you would like to compare when you write your test program.

## Terms and Concepts

To do this project, you should do research that enables you to understand the following terms and concepts:

- Probability theory
- Card counting
- The law of large numbers
- QBASIC programming language

Questions

- How would you calculate the probability that a guess of "higher" would be correct if the first card showing is an ace? a three? a four?

## Bibliography

- Drexel University, 2007. "Introduction to Probability," Ask Dr. Math [accessed September 11, 2007] http://mathforum.org/dr.math/faq/faq.prob.intro.html.
- Bogomolny, A., 2007. "Probability," Cut the Knot: Interactive Mathematics, Miscellany and Puzzles [accessed September 11, 2007] http://www.cut-the-knot.org/probability.shtml.
- Wikipedia contributors, 2007a. "Card Counting," Wikipedia, The Free Encyclopedia [accessed September 11, 2007] http://en.wikipedia.org/w/index.php?title=Card_counting&oldid=155951052.
- Wikipedia contributors, 2007b. "Law of Large Numbers," Wikipedia, The Free Encyclopedia [accessed September 12, 2007] http://en.wikipedia.org/w/index.php?title=Law_of_large_numbers&oldid=157329948.

## Materials and Equipment

To do this experiment you will need the following materials and equipment:

- Computer with programming software
- Deck of cards
- Calculator

## Share your story with Science Buddies!

I Did This Project! Please log in and let us know how things went.## Experimental Procedure

- Do your background research so that you are knowledgeable about the terms, concepts, and questions above.
- Play the game a bit by yourself. Develop your own strategy for playing the game.
- For example, if the card is greater than 7 you always guess lower, if the card is less than 7 you always guess higher.
- Test it out by taking a deck of cards and keeping track of how often you can correctly guess whether the next card is higher or lower than the one you turned over.
- If you can guess right more than 70% of the time, you've probably got the right strategy.

- Go through and calculate the probability of a successful guess for each of the thirteen different cards (assuming that it is the first card showing). The example in the Introduction shows how to do this.
- Calculate the average of the thirteen probabilities from step 3. This gives you the overall probability of guessing correctly.
- The next thing to do is to create a computer program that can play Hi-Lo so that you can test the effect of "card counting" strategies.
- Pick a programming language. If you've never programmed before, you should start with QBASIC, which is available for free at many internet sites, and is as close to English as any programming language. You'll write a computer simulation that will play thousands of hands of Hi-Lo for each test.
- Your simulation program needs two parts - the first is a shuffling routine to make sure the deck is random. The second is the actual game-playing strategy.
- You'll also have to write some data collection routines so you know how many times you've won or lost, and on which cards.

- Programming the strategy is the most involved part of this project, and can lead to a lot of results about how to play the game. Have fun with it!

## Share your story with Science Buddies!

I Did This Project! Please log in and let us know how things went.## Variations

- The game of Hi-Lo becomes more complex if the player can bet on his or her guesses. The player can use a simple strategy for setting the wager amount to increase his or her expected winnings by 50% compared to always betting the same amount. Can the player also "count cards" and pick up an even larger advantage?
- A more advanced project would examine different betting and card counting strategies to determine the optimal betting strategy in different circumstances. You can also determine how much "the house" should pay to a player who guesses correctly, how many decks "the house" should use to discourage card counting, and how far the dealer should deal into the decks before shuffling and starting over.
- For an even more advanced project, you could investigate how card counting strategies change the odds in a more complicated card game, like blackjack.

## Share your story with Science Buddies!

I Did This Project! Please log in and let us know how things went.## Ask an Expert

The Ask an Expert Forum is intended to be a place where students can go to find answers to science questions that they have been unable to find using other resources. If you have specific questions about your science fair project or science fair, our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.Ask an Expert

## Related Links

## If you like this project, you might enjoy exploring these related careers:

### Statistician

Statisticians use the power of math and probability theory to answer questions that affect the lives of millions of people. They tell educators which teaching method works best, tell policy-makers what levels of pesticides are acceptable in fresh fruit, tell doctors which treatment works best, and tell builders which type of paint is the most durable. They are employed in virtually every type of industry imaginable, from engineering, manufacturing, and medicine to animal science, food production, transportation, and education. Everybody needs a statistician! Read more### Actuary

Life is full of risks to both people and property. Actuaries predict the chances that future negative events will occur in a person's life, and then think of ways to reduce those chances, or reduce the impact of those negative events. Actuaries help bring peace of mind to both families and to businesses. Read more### Math Teacher

Math teachers love mathematics and understand it well, but much more than that, they enjoy sharing their enthusiasm for the language of numbers with students. They use a variety of tools and techniques to help students grasp abstract concepts and show them that math describes the world around them. By helping students conquer fears and anxieties about math, teachers can open up many science and technology career possibilities for students. Teachers make a difference that lasts a lifetime! Read more## Looking for more science fun?

Try one of our science activities for quick, anytime science explorations. The perfect thing to liven up a rainy day, school vacation, or moment of boredom.

Find an Activity