War Card Game Python

5 min read2017/06/24War

Have you ever played War? have you ever wondered When will this be over!?

Well I have, and after a weekend of being forced to play with my little cousin, I decided enough is enough. Lets do some simulation and some data analysis to answer some basic questions:

USE PYTHON PROGRAMING, do not use 'def' functions for this assignemt. Introduction Come on admit it. Somewhere along the line as a kid (at least those of you who grew up in the US) you played the card game called War.

War Card Game Help Python. Ask Question Asked 7 years, 6 months ago. Active 1 year, 4 months ago. Viewed 8k times -1. So im trying to figure out how to play the. I've made a little card game - 'War', i guess most of you have heard about it. I'm a begginer and i would appresiate if you can take a look at my code and give me some advises? Python cards.py and if it prints nothing, you probably didn't break anything with that change. Generally the suit-ranks should be club, diamond, heart, spade.

  • How long does the average game take?
  • How does the initial hand affect your winning percentage?
    • How often will I win if I have all the aces?
    • How often will I win depending on the average hand strength?
  • How does the ante size affect game duration?

Setup

Since I am not too used to dealing with numerical simulations of card games, I’m going to set up some classes in python. Once the simulations are done I’ll import the data into R to do some analysis.

Here are the two classes I set up:

Setup

First lets load up packages and set up the data from python

Analysis

Lets take a look at the data:

For normal games, the war ante is 2, so lets analyze that first:

Now lets get to the questions:### How long does the average game takeLets use a histogram to look at the distribution of games

The number of turns seems to have a very large right sided tail, and is not normally distributed. Since I’m interested in knowing the number of turns in terms of order of magnitude, lets log the data. Logging the data will also make the distribution resemble the normal distribution.

So it looks like 80% of regular games of war last between 85 and 657 turns, with a mean of ~320 turns.

War Card Game Python

How does the initial hand affect your winning percentage?

How often will I win if I have all the aces?

It seems that with 4 aces, a player will win 82% of the time. with 3 aces they will win 67% of the time, and will have about even chances if each player has 2 aces.

How often will I win depending on the average hand strength?

How does the ante size affect game duration?

War Card Game Using Python

It seems that the larger the war_ante, the faster the game will be over! So if you’re playing your cousin and want the average game over in about 100 turns, changing the rules to have an ante of 6 cards during a “war” is the way to go!