The Best Way To Play Memory (Card Game) According To Math

graceacupuncture - 21/04/2022 - STRATEGY - 284 Views

The card game memory, aka concentration, is a children’s game that tests visual recall ability.The Best Way To Play Memory (Card Game) According To Math

There are n pairs of cards face down. The first player flips over 2 cards to make a pair. If a match is made, the player keeps the cards, gets 1 point, and goes again. If not, the player flips the cards over and the next player goes, playing by the same rules. The game ends when all pairs are made and the person with the most points wins. (In this version, the goal is to maximize the point total).

In 1993 the best strategy for the game was solved, assuming players have perfect memory (they remember every card that was flipped) and play a zero sum game to maximize the expected number of matches (+1 means match for you and -1 means match for opponent).

It turns out there are some surprising moves: sometimes you will want to sacrifice your turn by intentionally not making a match! The reason is it can be strategically smart not to flip over new cards in some situations to prevent your opponent from gaining information.

I made a video that explains the best strategy and whether you want to go first or second.

Best Way To Play Memory (Card Game) According To Math

I summarize some of the points below.. .

"All will be well if you use your mind for your decisions, and mind only your decisions." Since 2007, I have devoted my life to sharing the joy of game theory and mathematics. MindYourDecisions now has over 1,000 free articles with no ads thanks to community support! Help out and get early access to posts with a pledge on Patreon.

. .Types of moves

In a turn you flip over 2 cards. The moves are characterized by the maximum number of unknown cards you will flip.

The way most people play the game is by using “2-moves.” You flip over an unknown card and try to match it with one you have seen. If you cannot make a match, you then flip over a 2nd unknown card searching for a match.

Sometimes it is smarter to make a “1-move.” You flip over an unknown card and try to match it with one you have seen. If you cannot make a match, you flip over a known card that is not a match. In other words, a 1-move has a maximum of 1 unknown card turned up.

There is also the “0-move,” where you flip over 2 known cards that do not match! That is, you flip over 0 unknown cards. This amounts to passing on your turn. There are positions of the game where both players prefer a 0-move to avoid making a mistake and revealing a card location to the opposing player. The game essentially ends in a draw since no player wants to flip over an unknown card.

Example: 3 pairs of cards, 1 known

I show this in the video better, but let me try to explain it in text.

Suppose you have 3 pairs cards A, A, B, B, C, C shuffled on a table. You know the first card is an A. You flip over the second card as B. What is your best move?

Most of us would search the remaining 4 cards to find a match for B. This is a 2-move. What is the conditional expected value of completing a 2-move? There are 3 cases to consider.

–In 2/4 cases you get a C card and lose your turn. Now your opponent knows the location of A, B, and C, and each of the remaining cards will match. So your opponent will easily run the table and make 3 pairs. This is a disaster for you. Your expected value is -3.

–In 1/4 cases you get a B, so you get 1 point for sure. Then you are left with 4 cards, of which you know the location of one A. The value to the game will be X.

–In 1/4 cases you get the other A. You lose your turn, and you have guaranteed your opponent pairs the A cards (-1 to you). Then your opponent has 4 cards, of which he knows the location of one B. The value to the game will be -X since this is the mirror situation of the last case, but your opponent is playing.

The second and third cases have opposite expected values so they net to 0.

The expected value of a 2-move is therefore (2/4)(-3) = -1.5.

This is not good: you are expected to make 1.5 fewer pairs than your opponent.

What if you did a 1-move instead? You give up your turn by flipping over the A. Now your opponent has 6 cards and knows the location of one A and one B.

What’s the conditional expected value?

–In 2/4 cases your opponent matches either the A or the B, so it’s a -1 to you. Then the game has 4 cards, of which one is still known. I will skip the details, but there is a 2/3 chance your opponent makes both of these (-2), and then a 1/3 chance they mess up so you make these (+2).

–In 2/4 cases your opponent gets a C. If the opponent uses a 1-move, then you will run the table and get all 3. So instead the opponent will use a 2-move and hope to find the other C card. There is a conditional 1/3 chance of that, and then the opponent runs the table (-3). There is also a conditional 2/3 chance of messing up, in which case you run the table (+3).

The expected value is therefore:

(2/4)[-1 + (2/3)(-2) + (1/3)(+2)] + (2/4)[(1/3)(-3) + (2/3)(3)] = -1/3 = -0.333…

A 1-move is actually better! Your loss is -0.333 versus that of a 2-move which is -1.5.

Optimal strategy

The game has been solved by computer (Zwick and Paterson 1993). The optimal strategy is defined in terms of the pairs of cards n and the number of known cards k. Here is how to decide which move to make.

Play a 2-move if k = 0 (there is no other choice) or if n + k is odd. There is one special case exception: for n = 6 and k = 1 you should do a 1-move.

Play a 1-move if k1 and n + k is even. Also do a 1-move for n = 6 and k = 1.

Play a 0-move if n + k is odd and k2(n + 1)/3. This happens when the number of known cards is relatively large to the number of pairs. The intuition is you don’t want to risk flipping a card since you might make a mistake and your opponent will then make many pairs. An example is if you have 5 pairs and there are 4 known cards.

Playing first or second?

The paper also analyzed the expected value to the game.

If n is 1, 6, or an odd number 7 or larger, it is best to go first. The expected value to the first player is about 1/(4n + 2).

Otherwise, it is best to go second. If n is 2, 3, 4, 5, or an even number 8 or larger, it is best to go first. The expected value to second player is about 1/(4n – 2).

This is a zero sum game, so the expected value to the other player is the negative value.

Note the expected value is roughly 1/(4n). A fair game has a value of 0 to both players, so the game of memory is almost fair with a slight edge to one of the players.

Now you know the best way to play and whether you should go first or second, so go out and dominate some people in the game of memory!The Best Way To Play Memory (Card Game) According To Math


U. Zwick and M. S. Paterson, The memory game. Theoretical Computer Science, 110 (1993):169-196

SPECIAL THANKS TO Possibly Wrong! Check out this excellent post that provides details and references to other papers on this topic as well:

I read about the 3 pairs, 1 known example from the chapter on Memory in the book “Luck, Logic, and White Lies: The Mathematics of Games” by Jorg Bewersdorff.

If you purchase through these links, I may be compensated for purchases made on Amazon. As an Amazon Associate I earn from qualifying purchases. This does not affect the price you pay.

Book ratings are from June 2021.

(US and worldwide links)

Mind Your Decisions is a compilation of 5 books:


The Joy of Game Theory: An Introduction to Strategic Thinking


40 Paradoxes in Logic, Probability, and Game Theory


The Irrationality Illusion: How To Make Smart Decisions And Overcome Bias


The Best Mental Math Tricks


Multiply Numbers By Drawing Lines

The Joy of Game Theory shows how you can use math to out-think your competition. (rated 4.2/5 stars on 200 reviews)

40 Paradoxes in Logic, Probability, and Game Theory contains thought-provoking and counter-intuitive results. (rated 4.1/5 stars on 30 reviews)

The Irrationality Illusion: How To Make Smart Decisions And Overcome Bias is a handbook that explains the many ways we are biased about decision-making and offers techniques to make smart decisions. (rated 4/5 stars on 17 reviews)

The Best Mental Math Tricks teaches how you can look like a math genius by solving problems in your head (rated 4.2/5 stars on 57 reviews)

Multiply Numbers By Drawing Lines This book is a reference guide for my video that has over 1 million views on a geometric method to multiply numbers. (rated 4.1/5 stars on 23 reviews)

Mind Your Puzzles is a collection of the three "Math Puzzles" books, volumes 1, 2, and 3. The puzzles topics include the mathematical subjects including geometry, probability, logic, and game theory.

Math Puzzles Volume 1 features classic brain teasers and riddles with complete solutions for problems in counting, geometry, probability, and game theory. Volume 1 is rated 4.4/5 stars on 75 reviews.

Math Puzzles Volume 2 is a sequel book with more great problems. (rated 4.3/5 stars on 21 reviews)

Math Puzzles Volume 3 is the third in the series. (rated 4.3/5 stars on 17 reviews)

Teachers and students around the world often email me about the books. Since education can have such a huge impact, I try to make the ebooks available as widely as possible at as low a price as possible.

Currently you can read most of my ebooks through Amazon's "Kindle Unlimited" program. Included in the subscription you will get access to millions of ebooks. You don't need a Kindle device: you can install the Kindle app on any smartphone/tablet/computer/etc. I have compiled links to programs in some countries below. Please check your local Amazon website for availability and program terms.



list of my books (US)UK


list of my books (UK)Canada


book results (CA)Germany


list of my books (DE)France


list of my books (FR)India


list of my books (IN)Australia


book results (AU)Italy


list of my books (IT)Spain


list of my books (ES)Japan


list of my books (JP)Brazil


book results (BR)Mexico


book results (MX)

Grab a mug, tshirt, and more at the official site for merchandise: Mind Your Decisions at Teespring.