A Simple Winning Strategy for the Card Game War

War is a classic kids card game. I spent many an hour wiling away the time playing war growing up. Enough so that I actually developed a strategy for the game. A strategy for the game of war? That's crazy talk.

For those who've never encounter the game of war here are the rules. A standard deck of 52 cards is shuffled and split between two equal stacks which are then given to the two players. The players then turn over the top card of their stacks and the player with the higher rank card "wins" and gets to take the two cards and place them at the bottom of their stack. If the cards end up being the same rank, then a "war" occurs. The players each deal two cards face down (it doesn't really matter that they are face down. Variants of the game include dealing one card face down instead of two.) They then each deal a face up card and the player with the higher rank of these cards wins. If the ranks are the same, then another war ensues. If at any time during a war, a player runs out of cards, then the last card they can play is used as the face up card for the war (this could even be the card which started the war.) The goal, of course, is to be the person who ends up with all the cards (this is war, after all.)

So how in the world could there be a strategy for war? Well it all comes from the fact that when you win, you get to place cards at the bottom of the deck in an order which you get to choose. Of course if both players randomly place the winning bounty of cards onto the bottom of their deck, the game is symmetric and no one has an advantage. But what if you are playing against someone who randomly places cards at the bottom of the deck. Is there then a strategy which can give you an advantage?

When I was a kid I came up with just such a simple strategy for winning the game of war. My idea was that wars were very important in the game of war (whoda thunk?) and in particular it was important to try to setup your cards in such a was as to win as many wars as possible. The strategy thus worked by attempting to make the cards as close as possible to the template high, low, low, high, low, low, high, etc. One can do this by keeping track of where you are in such a template and then everytime you win ordering your cards so as to best match this template. There is some arbitrariness in this idea: for example if you win and get two cards which should be low, low in the sequence, which one do you put first? One could arbitrarily break ties for this problem or one could use a fixed strategy there as well. Yeah, all good and such, but does this strategy really provide any advantage?

Well, the question is, does my childhood strategy actually provide any advantage against a player that is randomizing the cards they put at the bottom of their deck? Today after many years of procrastination I cranked out a little python code to test this. The code implemented the strategy in a manner such that for any given sequence of high/lows that it was trying to match, the cards were sorted in such a way that the high's were sorted in descending order and the lows in descending order. Thus if you win the cards 1,5,10,7,8,9,6,12 and were trying to match high, low, low, high, low, low, high, low the order would be 12,1,5,10,6,7,9,8.

And what are the results? Well it turns out that indeed this strategy does give you an advantage. After one million games of war, the player implementing this strategy won 548330 times. Okay, not a huge advantage, but not insignificant either.

But this got me thinking, what about other simple strategies? Suppose you follow a repeated template of high,low, for example? Or high,high,low? Note that because of the way I coded up the program there is sorting going on. Thus a high, high, template causes you to order your cards in increasing order and a low, low template causes you to order your cards in decreasing order. Here are the results of simulations of 100000 games:

Template Wins Notes
[high] 51336 decreasing sort
[low] 40632 increasing sort
[high,low] 42102
[hi,lo,lo] 54854
[high,high,low] 58190
[low,low,low,high] 40653
[low,low,high,high] 46947
[low,high,high,high] 50196
Wins for the player using the strategy given in the template.

An interesting high performing strategy on this list is the high,high,low strategy. It's not obvious to me why this strategy performs so well, but it gives you a pretty significant edge against a random ordering player.

So that's my basic strategy for winning the card game of war. So go out and defeat the average uninformed war player! Fame and fortune will certainly surely then be yours.

David Lightman: What is the primary goal?

Joshua: You should know, Professor. You programmed me.

David Lightman: C'mon. What is the primary goal?

Joshua: To win the game.


More like this

This is a post about the World Series of Poker, but there are no spoilers in it Today began one of the most interesting events at the World Series of Poker, the HORSE event. One of the complaints about the growth of the WSOP over the last few years is that the main event, with so many players…
There are two features of games that have always appealed to me. First, the good ones put you in a place where you are explicitly thinking out different ways the future could play out -- the possibilities that are more or less likely given what you know (and what you don't know). Second, many of…
As promised, I'm sharing the rules for the card game that my extended family played all through my youth. The idea here is that a set of rules for a bunch of favorite card games, a deck or two of cards, and a promise to play some of these games could make for an inexpensive -- and personalized --…
Baseball's World Series is played over the best of seven games. The first two games are played at the home field of one team (we will call this one team A), the next three at the home field of team B, and the last two at the home field of team A. Given that teams are more…

What if your opponent isn't doing something as elaborate as this, but isn't putting the cards underneath truly randomly either?

By Ben_Wraith (not verified) on 12 Sep 2008 #permalink

Depends on what they are doing. I've run a few to see what happens but haven't looked at a matrix of differing strategies.

The reason for high-high-low to be better may simply be that it increases the chance for you to get in phase in the case of a war; as far as I can see, it doubles it.

Any winning strategies for a variant of War that includes:
1) 6 decks
2) Wars using numbers of face-down cards equal to the value of the cards that started the war
3) Doubling the war value if they're the same suit?

The shuffles get a bit unwieldy, I admit.... :)

By G Barnett (not verified) on 15 Sep 2008 #permalink

When I was a kid, I found that dealing seconds and a good base deal made my job easier.

That was also about the time that I learned to never, ever play cards with a magician.