Counting cards Practice

Ruby Quiz
October 14, 2016 – 02:29 am
Adorable Christmas tree

Counting Cards (#152)

Learning to count cards is much easier than Hollywood or the casinos would have us believe. Some systems only require you to track a single running total in your head.

One such system, called the Knock-out system of card counting, is extra easy. You start your count at 4 - (4 x number_of_decks). That gives us an initial running count of 0, -4, -20, or -28 for the common casino shoe sizes of 1, 2, 6, or 8 decks. From there, you add one each time you see a 2, 3, 4, 5, 6 or 7 and subtract one when you see a 10, jack, queen, king, or ace. The 8 and 9 cards do not affect the count. Once you learn to track the running count, you can make strategy decisions and vary your bets based on the times when the count is in your favor.

That's not a lot to remember, but it does take practice to get fast. You really need to get to where you can count a deck in 20 to 30 seconds if you are going to keep up with those fast moving casinos dealers.

This week's Ruby Quiz is to build a training program for helping you learn to count cards.

The program needs to show you one or more cards at a time, running through a Blackjack shoe. As it goes, the program should track the running count. Have it pause at random intervals, ask you the count, and notify you if you are right or wrong.

Both the time to go through the deck and the number of cards displayed at a time should be configurable. It's important to practice with seeing multiple cards at once because you learn to cancel out pairs of high and low cards. It might even be nice to provide a mixed mode, which varies the number of cards shown at a time.

You can show cards as simple Strings, ASCII art, or full graphics as you prefer. You may wish to make cards fully disappear after their display time though, to make the conditions more like they would be in a casino.

Quiz Summary

Denis Hennessy put it very well when explained that there are two challenges to this quiz. The first was to implement a card counter. That's the easy bit.

Here's the library Denis submitted for counting cards:

ruby CARDS = %w{A K Q J T 9 8 7 6 5 4 3 2}
SUITS = %w{c s h d}

class Counter
def initialize(decks)
@count = 4 - 4*decks
@shoe =
decks.times do
CARDS.each do |c|
SUITS.each do |s|
@shoe < c.to_s + s.to_s
size = 52*decks
size.times do |i|
j = rand(size)
@shoe[i], @shoe[j] = @shoe[j], @shoe[i]

def deal
card = @shoe.pop
@count += 1 if "234567".include? card[0, 1].to_s
@count -= 1 if "TJQKA".include? card[0, 1].to_s

def count

def size

This code is very easy to follow. You construct a Counter from a number of decks and it will determine the starting count, load a shoe full of cards, and shuffle those cards (the code is just a longhand form of @shoe.sort_by { rand }).

The deal method is the only other one that does any work. It pulls cards from the shoe, but before returning them it makes sure to update the count. Our counting system is easy, so it breaks down into the two simple conditional checks we see here.

Interesting facts

Mike Aponte also known as MIT Mike is a professional blackjack player and a former member of the MIT Blackjack Team. Aponte was one of the leaders of a team of MIT students that legally won millions at blackjack tables around the world by counting cards. He is one of the main characters, "Jason Fisher," in the best selling book, Bringing Down...

You might also like
Blackjack Card Counting Practice #12
Blackjack Card Counting Practice #12
Blackjack Card Counting Practice #10
Blackjack Card Counting Practice #10
stormshop 3000g/0.1 Mini Electronic Digital Balance Scale
Kitchen (stormshop)
  • New Product
  • Big scale and high precision, it is a product with good cost performance
Popular Q&A
Can you count cards at online blackjack? | Yahoo Answers

NO, in almost every online blackjack game there are no card to count, each card is ramdomly "created" at the begining of each hand, then destroyed when the hand is over, and then new ones are created for the next hand.
For card counting to work, you keep track of cards dealt to know what cards remain undealt.
~SOME~ online casinos use a simulated shoes games with horrible penetration making card counting hypothetically possible if you used a bet spread of maybe 1000:1, you could also hypothetically backcount in a game liek that but since its online, there wouldnt be other players si…

Related Posts