CPSC-115 Fall 2008
Project 1
Due: Beginning of class Tuesday September 16, 2008
25 points
Professor Heidi Ellis
Goal: To understand how to create an algorithm
In this project, you are responsible for writing an algorithm to solve a common card game, the game of war. You must represent the algorithm in both outline and flowchart form.
Pairs:
This project is to be completed in the pairs specified below. Both members of the pair will receive the same grade for the project. One of the goals of the course is to understand that software development is a team effort so points will be deducted for projects that are clearly completed by only a single member of the pair.
Pairs
Kristen Anderson, Chelsea Bainbridge-Donner
Catherine Doyle, Jeffrey Young
Jake Elder, Ryan Ersland
Nick Dragu, Corazon Irizarry
Jin Feng Liu, Jesse Vazquez
Greg Vaughan
Zain Khan, John Wilsterman
Problem:
You must write an algorithm for playing the game of war. Start from the point where two users are handed a new deck of cards.
Problem details:
Each player has a name
Assume a standard deck of 52 cards
Cards rank from high to low: A K Q J T 9 8 7 6 5 4 3 2
Suits are ignored when comparing cards
The objective of the game is for one player (the winner) to get all of the cards
Each player is dealt half of the deck which they store in a pile face-down
Dealing involves giving each player a card in turn from the top of the deck
A turn occurs when each player turns the top card on their pile face up
Whichever player has the card with the higher value wins the turn and puts the two cards just played at the bottom of their pile. Once the winner has collected and stored the cards, the turn is over
A war occurs if the two players both turn up cards with the same value. The tied cards stay on the playing space and both players play the next three cards of their pile face down and then another card face-up. Whoever has the higher of the new face-up cards wins the war and adds all eight of the cards played to the bottom of their pile
If the new face-up cards are equal as well, the war continues by repeating the war
If there is a war and one or both players have an insufficient number of cards to put three more down and one up, then the number of cards minus one of the player that has the smallest number of cards remaining are played face down and the last remaining card is played face up
At the end of the game, the winner of the game is displayed
Helps:
Wikipedia has a good description of the flowchart symbols. Only worry about the start and end ovals, arrows, rectangles which represent processing steps, parallelograms which represent input and output, and conditionals, represented by diamonds.
You will be graded on the correctness and completeness of your algorithm. You should walk through your algorithm several times with your partner to ensure that you have included all aspects of the problem. You may find it helpful to play a game by following each form of your algorithm. This will help you identify any missing areas.
Hand in via hard copy or email the following by 11:20 a.m. Tuesday September 16, 2008: