Return to the home page for Patrick Kellogg

If you haven't seen the Java applet yet, please check out http://www.patrickkellogg.com/school/old/war/WarApplet.htm first before reading this paper.

Introduction

For a class in statistics (Applied Math APPM 4570), Patrick Kellogg and Peter Smith investigated the statistical behavior of the card game "War". War is a easy game, in fact almost embarrassingly simple, so we thought that analysis would be a breeze. We wrote a Monte Carlo simulation in Java, and ran some large-scale simulations to generate data. Overall, this was a fun project, and the game demonstrated some interesting statistics.

This paper will never win any awards (though it did get an "A"), but it was a good introductory project. If you have any questions or comments, feel free to email the authors:

Patrick Kellogg (kellogg@dimensional.com)
Peter Smith (email unknown)

The Rules of War (from Hoyle's Book of Card Games)

Primarily a two-player game, preferably for juveniles, with a fifty-two-card pack ranking A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2 with suits disregarded. Each is dealt twenty-six cards face down, and each turns his top card face up. The higher value takes the lower and the cards are placed face down beneath the winner's packet. This continues indefinitely, until one player has won all the other's cards. If two cards happen to be tied - as two tens - they are laid aside and go to the winner of the next turnup. The player who gathers in all the cards wins the game.

As an added rule, after a tie, each player lays a card face down before turning up another; and these cards also go to the winner of the next turnup. This may enable a player to capture an opposing ace when he has none of his own. The game can be played with three of more players, each on his own utilizing a double pack if desired. If two are tied for high, any player turning up a lower card is included in the in the tie and has a chance of winning them all with the next turnup. A player drops out when his cards are gone, and others continue until one player wins. This game is also called Everlasting, due to its duration.

Questions

  1. First, how many games can player one expect to win over player two if they both play the game a certain number of times?
    Our hypothesis was that player one and player two should win approximately the same number of games, since the game is symmetric. That is, we expected a player has a 50% chance of winning over the other. To a statistician, this suggests a binomial distribution. Here is a more mathematical way of representing the situation:
    Allow n games of War be played where X denotes the number of times that player one wins a certain hand and Y denotes the number of times player two wins instead. Then X + Y = n. In theory, X will have a binomial distribution with a mean value of 0.5, expected value of np, and a variance of np (1 - p). The theory is that p = 0.5.
  2. Can you always win a game by having one or more of a certain high card?
    In order to tackle this question, we chose to use the King as the card to watch for, because the it has the highest point value of all the cards in the deck. We thought that if you have more Kings than your opponent, then you will fair better in the end.

  3. What if, by luck, you were dealt a poor hand, a hand with a low total point value. Are you assured of losing?
    Likewise, will you win with a hand that has a high total point value?

Data

The data was collected by running our War simulator many times. Running it once simulates one hand played. We then looped it so 50 games were played, which constituted a "trial". Then we ran the program through 50 and 1,000 trials, and sent the results to a file. In addition, the deck is randomly shuffled before each game is played. The Java random number generator is unique from other generators in that it always generates a different number, and does not need to be seeded. These files were then read into MATLAB in order to analyze the data.

When the game was running, the output for one game the screen looked like this:

However, we only wanted the salient data to be sent to a file for processing. In this case, we were interested in who won and who lost. An example of a data file follows:

For the second part of our experiment, we needed to keep track of not only which player won, but how many kings that player had in their hand. So, our data had two columns which were sorted in Unix before being processed by MATLAB.

This file had to be modified a little bit by hand so that MATLAB could parse it correctly and come up with values for the probability of winning with 0 kings, or 1 king, and so on.

The final piece of data is how many points are in player one's hand at the beginning of the hand, and which player won the hand. The file looked like this

Analysis

We ran 1000 separate trials to get 1000 different values of X bar. Ideally, this value should have a normal distribution. Excel calculated an expected X bar value E(X bar) of 0.49924 with a V(X bar) = 0.00469 and a standard deviation of X bar of 0.06849. This is close to the E(X) of 0.5 that we were expecting.

Mean 0.49924
Standard Error 0.00217
Median 0.50000
Standard Deviation 0.06849
Sample Variance 0.00469
Confidence Level (95%) 0.00425

The histogram, entitled "X bar vs Number of Trials" was created by adding up the number of games won by player 1 in a trial and dividing that by 50 games per trial. This gives 1000 values for X bar. The histogram shows the number of times that a particular X bar appeared. The graph obviously has a normal distribution, peaking at around .5, just as we predicted. So we can conclude at a player has a approximately 50% chance of winning.

The second part of the report examined cases where the number of kings = [0 1 2 3 4]. We achieved the following results:

Data is described by the line: y = 0.1496 + 0.1732 x

The error sum of squares SSE is quite low, so we would conclude that the line fit is accurate. The validity of the line is strengthened by the high R2 value of 0.9898. The graph backs up our hypothesis that the more kings you have, the better chance you have of winning the hand. It shows that with four kings, a player has a 70% chance of winning the hand. This percentage should decrease as you look at smaller valued cards (like having four queens compared to four kings), though we didn't test that theory. Here is a line fit from the data obtained by running 1000 trials of 50 games.

Our third question looked at the total number of points in a players hand, and tried to decide whether the player was more likely to win or lose. As in the previous experiments, we looked at 1000 trials of 50 games each. The resulting graph shows that as your hand total increases, so does your chances of winning the game. The minimum point value possible is 98, and the maximum is 266. However, since the hands were shuffled randomly, it was nearly impossible to ever generated that hand. This is a flaw we should fix in the future.

The value for R2 on the graph is 0.9329. Since R2 is relatively close to 1, it is safe to say that the percentage of winning has a linear relationship with the total number of points in a hand.

Conclusion

Based on the data collected above, we would conclude that our guess that each player wins 50% of the time is correct. This also means that the Java code seems to be working.

Our correlation of the probability of winning vs. the number of kings you have in your hand is a bit more problematic. First of all, there were a lot more games played where each player had 2 kings than those where one player had them all. So, the error bars for the 0 and 4 king cases are going to be much larger, since they have a much smaller n. Nevertheless, the results show that our hypothesis was correct, and that you have a better chance of winning if you have more kings in your hand.

Not only does having kings in your hand seem to better your chances for winning, but also having a larger point total than your opponent to begin each game seems to bring more victories. Which of the two starting conditions (# of kings vs. total points) is a better measure of success? Both have very good linear fits based on their R2 values, so it is a difficult choice. The kings had a slightly better fit, but counting the total number of points intuitively contains more information about the hand. Our only conclusion is that it is all random. Even if you have a high point total hand, the way the deck was shuffled has an large impact on the outcome of the game. We can predict a winner, but only with a low probability.