Wars are all over the place. Please forget about Syria, Libya, and Afghanistan for a couple of minutes. These are serious and tragic wars with many lives lost. But kids play wars, too, like in the card game. Let's do this.
Almost every kid plays war of some kind. Aside from the usual cowboy and other war games, rainy afternoons were often the time to get out a deck of cards and play the card game War. As many times as I played this game as a kid, I can hardly ever remember finishing a game. What I can remember mostly is making a "tactical" agreement to quit and do something else.
The other day, I thought to play war again --- but on a computer. For a game of pure chance, there is a remarkable amount of mathematics involved. If your mathematical toolkit includes course in probability, then you can appreciate just how complex this simple kids game is. Just determining the expected outcome after playing the first round after dealing is complex enough, let alone subsequent rounds --- when the players have unequal numbers of cards. The game is amazingly complex even when one restricts the size of the deck in almost any way. For example, suppose there are just hearts and diamonds numbered two to three. This game, with just eight cards, is very complicated, and way too complicated for a theoretical analysis. What we want to do here is simulate the play on a computer. The results will not be mathematical theorems but rather a collection of averages percentages based on assorted contingencies.
For example, do you always win if you begin with four aces? Do you always win when you begin with four aces and four kings? Answer to both: no. Well, then how often do you win? How many "wars" per game can you expect to play? And very important: how long does take to play a game? Answer: not forever. These are some of the questions we'll consider. The results will be averages based on simulations. For our simulations, we will play over a million games of war, more than the average kid, even an avid war buff.
So we played games on the computer. Here are the results.
The game. With the deck well shuffled, we deal the cards and play the game. Programming the game is relatively straight forward. It is just of loop of compare statements with a subroutine for a "war." Lets look at the results. First, we played many, very many, games. One feature of the program is that the user can enter the number of games to be played in a set. For example, you could request it to play 100 games, or 1000, or even one million games. Call this a set. The output is a collection of statistics about the play. We selected sets of 100, 500, 1000, 2500, 5000, 10,000, 50,000, 100,000, 1,000,000 and even 15,000,000 games. Depending on how many games are in a set, there were a number of interesting features. Below we list features more or less common to most of the sets.
Results.
∙ Each player won approximately, in fact, very nearly, half the games. Indeed, for the longest set of games, player A (who begins) won 7,498,859 games and Player B won 7,501,141 games.
∙ The average length of a game was 296 plays, with a war counting as one play. However, the standard deviation was 218. This indicates quite a wide spread in the number of plays per game. In games played with 2 down cards for a war, the average length was about 225 plays with a standard deviation of 171 plays.
∙ The average number of "wars" per game was about twenty --- and about fifteen for games played with two down cards.
∙ Approximately 25% of all games ended in default. That is, during a "war", the opponent did not have enough cards to complete the play - scored as a loss. Thus, about 75% of all games ended with one player's last card being captured. These percentages change to 40% and 60%, respectively, when a war is played with two down cards.
∙ The longest game of a set naturally increased as the number of games in the set increased. For example, in a set of 100 games, the longest games was 1428 plays. In the set we played of fifteen million games, the longest game was 4511 plays. To predict the expected duration of longest game in a set of say N games is a rather complicated mathematical problem, and requires considerable information about the probabilistic nature of the game itself. By the way, the shortest game played in the set of fifteen million was just 39 plays, a short game indeed. (Question. Using our definition of a play, what is the shortest possible game? Answer: one play. How?)
∙ This game, in probability expert circles, is often considered a deterministic game. The randomness is all in the shuffle. This means, once the deck is shuffled the outcome is completely determined. This does not imply one can make a function from the shuffle to the outcome. After all, there are 52!≐8.08×10⁶⁷shuffles, a huge number greater than the estimated number of atoms in our galaxy! Accounting for the hierarchy, an ace is an ace independent of suit etc, we should note there are in this game 52!/(4!)¹³= 92024 242230271 040357108 320801872 044844750 000000000 9 ≐ 2024×10⁴⁹ actual shuffles, still a mighty big number.
Aces and Kings. For winning with aces and kings here is a table of percentages from the simulations.
Even beginning with each four aces and kings, you can still lose. Winning is only about 96.2% probable. Beginning with two each of aces and kings is about 50% probable. These values are simply impossible to achieve, or even estimate, mathematically.
Timings. How fast did the computer play a games? This again depended on the number of games to a set and the computer. On a typical PC, a Dell, the run time for 15,000,000 games was just over 3917 seconds, or about 65.3 minutes. Translated to smaller numbers the computer played about 3829 games per second! Much of that time, was spent shuffling the pseudo-deck.
Oh well, what else can you do on a rainy Saturday afternoon. Football? :)
For your review, here are the rules for the card game of war.
1.Shuffle the deck and deal an equal number of cards to each player. Players are not permitted to select specific cards for play.
2.Each player plays a card from the top of the deck; the winner of the play is the player with the higher face value; he takes both cards and places them at the bottom of his deck.
3.In the event both players play a card of the same face value, a "war" is declared. In this case both players play a new card face down and a second card face up. The winner of the "war" is the player with the higher face value for the second card. The winner takes all six cards (and places them at the bottom of the deck). If the second cards have the same face value, a new "war" is declared. The above process is repeated, and repeated again until one player has a higher second card. The winner collects all cards.
4.When one player's cards are depleted, the other player is the winner. If one player runs out of cards during a war, the other player declared the winner. If both players simultaneously run out of cards, the game is considered a draw. This is the only condition for a draw. In our simulations not a single draw occurred.
5.One game variation is to play wars with two down cards. Another variation is to play three down cards and the player selects one of them as the up card.
Want to play roulette? http://used-ideas.blogspot.com/2012/06/lets-play-roulette-just-for-fun.html
Almost every kid plays war of some kind. Aside from the usual cowboy and other war games, rainy afternoons were often the time to get out a deck of cards and play the card game War. As many times as I played this game as a kid, I can hardly ever remember finishing a game. What I can remember mostly is making a "tactical" agreement to quit and do something else.
The other day, I thought to play war again --- but on a computer. For a game of pure chance, there is a remarkable amount of mathematics involved. If your mathematical toolkit includes course in probability, then you can appreciate just how complex this simple kids game is. Just determining the expected outcome after playing the first round after dealing is complex enough, let alone subsequent rounds --- when the players have unequal numbers of cards. The game is amazingly complex even when one restricts the size of the deck in almost any way. For example, suppose there are just hearts and diamonds numbered two to three. This game, with just eight cards, is very complicated, and way too complicated for a theoretical analysis. What we want to do here is simulate the play on a computer. The results will not be mathematical theorems but rather a collection of averages percentages based on assorted contingencies.
For example, do you always win if you begin with four aces? Do you always win when you begin with four aces and four kings? Answer to both: no. Well, then how often do you win? How many "wars" per game can you expect to play? And very important: how long does take to play a game? Answer: not forever. These are some of the questions we'll consider. The results will be averages based on simulations. For our simulations, we will play over a million games of war, more than the average kid, even an avid war buff.
So we played games on the computer. Here are the results.
The game. With the deck well shuffled, we deal the cards and play the game. Programming the game is relatively straight forward. It is just of loop of compare statements with a subroutine for a "war." Lets look at the results. First, we played many, very many, games. One feature of the program is that the user can enter the number of games to be played in a set. For example, you could request it to play 100 games, or 1000, or even one million games. Call this a set. The output is a collection of statistics about the play. We selected sets of 100, 500, 1000, 2500, 5000, 10,000, 50,000, 100,000, 1,000,000 and even 15,000,000 games. Depending on how many games are in a set, there were a number of interesting features. Below we list features more or less common to most of the sets.
Results.
∙ Each player won approximately, in fact, very nearly, half the games. Indeed, for the longest set of games, player A (who begins) won 7,498,859 games and Player B won 7,501,141 games.
∙ The average length of a game was 296 plays, with a war counting as one play. However, the standard deviation was 218. This indicates quite a wide spread in the number of plays per game. In games played with 2 down cards for a war, the average length was about 225 plays with a standard deviation of 171 plays.
∙ The average number of "wars" per game was about twenty --- and about fifteen for games played with two down cards.
∙ Approximately 25% of all games ended in default. That is, during a "war", the opponent did not have enough cards to complete the play - scored as a loss. Thus, about 75% of all games ended with one player's last card being captured. These percentages change to 40% and 60%, respectively, when a war is played with two down cards.
∙ The longest game of a set naturally increased as the number of games in the set increased. For example, in a set of 100 games, the longest games was 1428 plays. In the set we played of fifteen million games, the longest game was 4511 plays. To predict the expected duration of longest game in a set of say N games is a rather complicated mathematical problem, and requires considerable information about the probabilistic nature of the game itself. By the way, the shortest game played in the set of fifteen million was just 39 plays, a short game indeed. (Question. Using our definition of a play, what is the shortest possible game? Answer: one play. How?)
∙ This game, in probability expert circles, is often considered a deterministic game. The randomness is all in the shuffle. This means, once the deck is shuffled the outcome is completely determined. This does not imply one can make a function from the shuffle to the outcome. After all, there are 52!≐8.08×10⁶⁷shuffles, a huge number greater than the estimated number of atoms in our galaxy! Accounting for the hierarchy, an ace is an ace independent of suit etc, we should note there are in this game 52!/(4!)¹³= 92024 242230271 040357108 320801872 044844750 000000000 9 ≐ 2024×10⁴⁹ actual shuffles, still a mighty big number.
Aces and Kings. For winning with aces and kings here is a table of percentages from the simulations.
Even beginning with each four aces and kings, you can still lose. Winning is only about 96.2% probable. Beginning with two each of aces and kings is about 50% probable. These values are simply impossible to achieve, or even estimate, mathematically.
Timings. How fast did the computer play a games? This again depended on the number of games to a set and the computer. On a typical PC, a Dell, the run time for 15,000,000 games was just over 3917 seconds, or about 65.3 minutes. Translated to smaller numbers the computer played about 3829 games per second! Much of that time, was spent shuffling the pseudo-deck.
Oh well, what else can you do on a rainy Saturday afternoon. Football? :)
For your review, here are the rules for the card game of war.
1.Shuffle the deck and deal an equal number of cards to each player. Players are not permitted to select specific cards for play.
2.Each player plays a card from the top of the deck; the winner of the play is the player with the higher face value; he takes both cards and places them at the bottom of his deck.
3.In the event both players play a card of the same face value, a "war" is declared. In this case both players play a new card face down and a second card face up. The winner of the "war" is the player with the higher face value for the second card. The winner takes all six cards (and places them at the bottom of the deck). If the second cards have the same face value, a new "war" is declared. The above process is repeated, and repeated again until one player has a higher second card. The winner collects all cards.
4.When one player's cards are depleted, the other player is the winner. If one player runs out of cards during a war, the other player declared the winner. If both players simultaneously run out of cards, the game is considered a draw. This is the only condition for a draw. In our simulations not a single draw occurred.
5.One game variation is to play wars with two down cards. Another variation is to play three down cards and the player selects one of them as the up card.
Want to play roulette? http://used-ideas.blogspot.com/2012/06/lets-play-roulette-just-for-fun.html
Comments
Post a Comment
Please Comment.