# Counting Cards – I

Standard

You would have seen the bad consequences of “counting cards” in blackjack game in casinos in movies like Rain Man and 21. This method allows the player to play a perfect game so that the odds are in the player’s favour to win.

In this post, let’s first understand what is blackjack. Most parts have been shamelessly copied from http://www.bicyclecards.com/how-to-play/blackjack/ . You can consider this post to be a tl;dr. If not happy, consider SMMRY.

In the casino version, the house is the dealer. The dealer remains standing and the players are seated. The dealer is in charge of running all aspects of the game, from shuffling and dealing the cards to handling all bets. Between one and eight standard 52-card decks are shuffled together and the cards are dealt from a shoe (a box that allows the dealer to remove cards one at a time, face down, without actually holding one or more packs).  Each card has some value assigned to it. It is up to each individual player if an ace is worth 1 or 11. Face cards are 10 and any other card is its pip value.   A hand’s value is the sum of the card values. Each participant attempts to beat the dealer by getting a count as close to 21 as possible, without going over 21.

When all the players have placed their bets, the dealer gives one card face up to each player in rotation clockwise, and then one card face up to himself. Another round of cards is then dealt face up to each player, but the dealer takes his second card face down. Thus, each player except the dealer receives two cards face up, and the dealer receives one card face up and one card face down. If a player’s first two cards are an ace and a “ten-card” (a picture card or 10), giving him a count of 21 in two cards, this is a natural or “blackjack.”  If the dealer’s face-up card is a ten-card or an ace, he/she looks at his face-down card to see if the two cards make a natural. If the face-up card is not a ten-card or an ace, he/she does not look at the face-down card until it is the dealer’s turn to play.

The player to the left of the dealer goes first and must decide whether to “stand” (not ask for another card) or “hit” (ask for another card in an attempt to get closer to a count of 21, or even hit 21 exactly). Thus, a player may stand on the two cards originally dealt him, or he/she may ask the dealer for additional cards, one at a time until he/she either decides to stand on the total (if it is 21 or under) or goes “bust” (if it is over 21).  The dealer then turns to the next player to his left and serves him in the same manner.

When the dealer has served every player, his face-down card is turned up. If the total is 17 or more, he/she must stand. If the total is 16 or under, he/she must take a card. He/she must continue to take cards until the total is 17 or more, at which point the dealer must stand. If the dealer has an ace, and counting it as 11 would bring his total to 17 or more (but not over 21), he/she must count the ace as 11 and stand.

There are three special moves called splitting pairs, doubling down and insurance.

• Splitting pairs is possible if a player’s first two cards are of the same denomination, such as two jacks or two sixes. The player may choose to treat them as two separate hands when his/her turn comes around. The amount of his/her original bet then goes on one of the cards, and an equal amount must be placed as a bet on the other card.
• Doubling down is possible when the original two cards dealt total 9, 10, or 11. When the player’s turn comes, he/she places a bet equal to the original bet, i.e. doubling his/her bet, and the dealer gives him/her just one card, which is placed face down and is not turned up until the bets are settled at the end of the hand.
• Insurance is possible when the dealer’s face-up card is an ace.  Any of the players may make a side bet of up to half the original bet that the dealer’s face-down card is a ten-card, and thus a blackjack for the house.  Insurance is invariably not a good proposition for the player unless he/she is quite sure that there are an unusually high number of ten-cards still left undealt.

# Nim

Standard

Nim is a very old game with precise mathematical theory, and one player can always force a win.

The game is Nim is played as follows: Any number of matches/pebbles are arranged in heaps, the number of heaps and the number matches/pebbles in each heap, being arbitrary.  There are two players, A and B. The first player A takes any number of matches/pebbles from a heap, he/she may take only one or any number up to the whole of the heap, but he/she must touch one heap only. B then makes a move conditioned similarly, and the players continue to take alternate turns of picking matches/pebbles. The player who takes the last match/pebble wins the game.

We define a winning position as a position such that if one player P (A or B) can secure it by his/her move, leaving his/her opponent Q (B or A) to move next, then, whatever Q may do, P can play so as to win the game. Any other position we call a losing position.

Next, we express the number of matches in each heap in the binary scale and form a figure by writing down one under the other. Then we add up the columns. For example, consider the following position:

Then, (1,3,5,7) position gives the following figure:

001
011
101
111

224

If the sum of each column is even (which is the case above), then the position is correct. An incorrect position is one which is not correct, thus (1,3,4) is incorrect.

Then we have the following result:

A position in Nim is a winning position if and only if it is correct.

For the proof/discussion/variations of rules, see § 9.8, of G. H. Hardy and E. M. Wright’s An Introduction to the Theory of Numbers.

But designing an elaborate winning strategy, i.e. ensuring that you always stay in winning position, is not so easy (though we know it exists!). For example, watch this video by Matt Parker: