Archive for the ‘experiment’ Category
Statistics: The card game “war”
I wrote a Perl script that simulates a game of war. As I remember playing it, the game goes like this: Both players receive 26 cards randomly. Both players play a card off of the top of their deck at the same time. The highest card wins and takes all of the cards. I say all of the cards because if both players play the same card (suit is irrelevant) at the same time, then they go into WAR. Each player player discards three cards and then each play a card. From there the players each play a card and there is either a winner or another WAR continues. Thus it is possible to have many cards won in one round.
When playing this game as a kid, I realized that it had the possibility of going on and on and on for many turns. But how many turn? Yay numbers! The Perl script that I used is at the end of this article (I know it’s *sniff verbose).
More interesting to me is the distribution of the length of the game (I measured it in number of won rounds).
Here is a graph from excel. There are 1000 samples. The numbers on the x-axis represent the duration of a simulation in number of rounds. The y-axis represents frequency. Thus there are more games of war that end in 100-150 rounds than any other interval in this graph.
