Based in Maryland, Mathwizurd.com is REVOLUTIONIZINg the world, one post at a time. With topics ranging from Biology to Multivariable Calculus, this website covers the entire academic spectrum.

Jul 21 The Problem with War

Unlike any other "random" game, like Rock-Paper Scissors, or Poker, where there is a psychological element to winning the game, War (card game) is purely a game of luck.

Here are some basic rules: There are two players, and they each have half a deck. They both put down a card, and if you have a higher card you take both cards. If the cards tie, you put down three more cards, and the third card decides who keeps ALL eight of the cards. You finish the game when one person loses all of their cards.

I decided to simulate War games and I noticed some interesting things.

The function was called cards, which returned the put_in, and whether "a" gets the pot. Essentially, the pot is a[:put_in] + b[:put_in], so put_in is basically how many cards each person would put into the pot. When the card is different, put_in increases by one, because both players have to put in a new card. If it's tied, put_in increases by up to three (could be two, or even one if one person doesn't have enough cards). If add happens to be zero, that means one person has one card left and it's a tie, so the person with one card loses.

First, giver is the number of cards each person puts in, in addition to who keeps it. The order matters, so b is on top if they win, and a is on top if they win. Now, the first cards are taken off each pile, and the queue is added to the winner of the previous hand.

The while loop will run until one of the two decks are empty. If moves exceeded 3000, it would stop, and the reason behind this is an interesting occurrence that happens in War.

Major Problem

While testing this simulation, an interesting phenomenon was present. Sometimes, games would go on forever, and the game would arrive at a deadlock at 26-26. Originally, I thought this was my mistake, but after looking deeper into it, it occurs whenever each deck alternates with a win and a loss, and it happens surprisingly often.

Example:

Here's a simple example, [2,9], and [9,2]. Since they alternate wins and losses, the game will never finish, once the first person loses they'll have a 9 and the other person will have the 2, and it'll keep iterating.

Analysis

After simulating 200,000 games, interesting trends were shown. First of all, 11.565% of games never finished. It was assumed that exceeding 3000 moves meant that the game would last forever, however it could have been possible that the game could've ended later. The average of those that finish are 247.096 moves. If you assume that each move takes five seconds, the average game takes about 20 minutes and 35 seconds. The longest game (in that simulation) took 2554 moves, or 3:32:50. The longest game ever seen in a simulation was 2836 moves, or 3:56:20.

Frequency of Game Lengths

Number of moves, in hundreds, is a range of a hundred numbers, beginning in the number above (e.g. 3 equals 300-399)

Note: Numbers above that were not shown, because the numbers were very small, and they wouldn't be able to be seen on the graph.

Conclusion

War is not a good game qua game; it requires no skill, and almost 12% of the time, it will never finish. If you do end up having a game that can finish, it'll take an average of twenty minutes to win, and you might have to play for four hours until you can finish. In short, this game is equivalent to flipping a coin over and over- it's pure chance, and it shouldn't be considered a game.