Queues
This program is a simulation of the card game War.
The queues need to be implimented as a struct and functions to
complete the queue operations. Your cards may also be done as a
struct, but it is not required for this assignment.
Rules:
- The deck gets initialized and shuffled.
( standard 52 card deck, no jokers )
- Each player gets dealt half of the deck.
- Each player plays the first card in their hand (queue).
- If the cards are the same value, it is a tie,
and the cards are removed from play.
- otherwise the player with the higher value card
puts their both cards at the bottom of their deck
( back of the queue ).
- If a player has run out of cards they have lost.
NOTE: if player one wins, enqueue the winning and losing cards
consistently. This may prevent some really long, almost infinite runs.
I/O tricks
Your output needs to be formatted similar to mine. You will probably
want to build the card strings using snprintf. At the end of
the game make sure you tell me who won, how many hands it took, and the
number of tie hands.
Here is an example run of the program.
shuffle logic
For every item find a random item to swap with. Repeat this 7 times
( typically this value is a prime close to the square of
the number of items to shuffle ).
Reminder:
The structs you are creating should have its own files.
All prototypes and definitions must be in the header file.
the actual functions belong in a .c file, and needs to be
compiled seperately.
This program is due on September 28th 29th.
The Goals
- Write and use structs
- Solve a simple queue problem