Homework 1, Florin Marches off to War

Short Description:

Write a series of programs to study the game of War.

This assignment is worth 100 points.

Goals

When you finish this homework, you should:

Formal Description

After your success with the Ministry of Foreign Information, the Florin Ministry of War has hired you. The Ministry of War is interested in studying the card game War to see if it might be an acceptable alternative for solving conflicts with Guilder. To accomplish this, the Ministry has asked you to produce the following programs. Please see the wikipedia War (card game) entry for the rules of this game. In order to better simulate human players, whenever a battle occurs, decide at random which cards are placed into the winning players hand first.

Algorithm for the winner:

Flip a coin
If the result is heads
   place your cards in your deck
   place your opponents cards in your deck
else
   place your opponents cards in your deck
   place your cards in your deck

War

Your program should provide an easy to read, detailed dialog describing the game. The following is the suggested output format. You may need to extend this format for situations not covered in this example.
Welcome to War.

Dealing the cards.

Battle 1
   Player 1 plays an Ace of Hearts 
   Player 2 plays a Queen of Spaces
       Player 1 wins 
       Player 1 places 
          the Queen of Spades 
	  then the Ace of hearts in their hand.

Battle 2
   Player 1 plays a Two of Clubs
   Player 2 plays a Two of Diamonds
   WAR!
      Player 1 puts a Queen of Clubs in the battle
      Player 1 puts a Five of Hearts in the battle
      Player 1 puts a Seven of Diamonds in the battle
      Player 2 puts a Four of Clubs in the battle
      Player 2 puts a Nine of Clubs in the battle
      Player 2 puts a Five of Diamonds in the battle
   Player 1 plays a Seven of Spades
   Player 2 plays a Four of Diamonds
      Player 1 wins.
      Player 1 places the Two of Clubs
         then the Queen of Clubs
         then the Five of Hearts
	 then the Seven of Diamonds
	 then the Seven of Spades 
         then  the Two of Diamonds
	 then the Four of Clubs
	 then the Nine of Clubs
	 then the Five of Diamonds
	 then the Four of Diamonds in their hand
...
Battle 483
    Player 1 plays a Two of Hearts
    Player 2 plays an Ace of Spades
       Player 2 wins
       Player 2 places the Ace of Spades 
          then the Two of Hearts in their hand.

Battle 484
    Player 1 is out of cards
    Player 2 wins.

WarStats

Your program should run 500 simulated battles. After each battle print a report
Battle 1, Player 2 wins in 483 battles.  12 Wars, 1 double War.
When the program is complete, print a summary of

Discussion

Files you need.

You will need a copy of my file deck.h. You might also want my Makefile and my example driver file.

Required Files

You should submit the following in a tar file: You should not submit

Submission

Please create a tar file containing the files described above. Email this file to danbennett360@gmail.com by class time of the due date.