The card game “War” is played by the following rules (you may have learned different rules. Use these): - Each player gets half of the deck of cards (in our case, a set of random integers with value 1-13) - The game itself is played in a series of “rounds”. In each round: o Both players draw a card, putting it into the “reward pile” (and removing it from their hand). o If one player’s card is higher than another, they gain all cards in the reward pile (and add it to their hand) o If there is a tie, both players add an additional card to the reward pile (which is not compared - I call this a “penalty card” in my sample run below), and then we begin a new round with a larger reward pile. The next round’s winner will win the entire reward pile (though it is possible to have multiple consecutive ties, leading to a much larger reward pile) - The game ends when a player needs to draw a card and cannot. That player loses. Your task is to implement this game with the player’s hands and the reward pile as bags of integers. You should allow the user to specify the size of the initial hands (I used 5 card hands to test my program, since half of an official card deck is 26 cards, and simulating 26 card decks runs for a long time). Each round, you should display: - The current round - The values of each player’s hands (by outputting the values of the bag’s to_vector function) - The cads drawn in the current round, and who won. Of course, you will have to finish the Bag lab to be able to do this. Your main program should only use Bags to manage the cards. (So no vectors, strings, or anything like that). You should implement the game using the Bag member functions. My only exception was that I used the “to_vector” Bag function to get the cards in a hand so I could write a Print_Vector function. But generally: - Cards go into the hand and reward pile using insert - Specific cards leave the hand and reward pile using remove - The card that gets played from the hand gets selected using (the random version of) choose

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

The card game “War” is played by the following rules (you may have learned different rules. Use these):

- Each player gets half of the deck of cards (in our case, a set of random integers with value 1-13)

- The game itself is played in a series of “rounds”. In each round: o Both players draw a card, putting it into the “reward pile” (and removing it from their hand). o If one player’s card is higher than another, they gain all cards in the reward pile (and add it to their hand) o If there is a tie, both players add an additional card to the reward pile (which is not compared

- I call this a “penalty card” in my sample run below), and then we begin a new round with a larger reward pile. The next round’s winner will win the entire reward pile (though it is possible to have multiple consecutive ties, leading to a much larger reward pile)

- The game ends when a player needs to draw a card and cannot. That player loses.

Your task is to implement this game with the player’s hands and the reward pile as bags of integers. You should allow the user to specify the size of the initial hands (I used 5 card hands to test my program, since half of an official card deck is 26 cards, and simulating 26 card decks runs for a long time).

Each round, you should display: - The current round - The values of each player’s hands (by outputting the values of the bag’s to_vector function)

- The cads drawn in the current round, and who won. Of course, you will have to finish the Bag lab to be able to do this. Your main program should only use Bags to manage the cards. (So no vectors, strings, or anything like that). You should implement the game using the Bag member functions. My only exception was that I used the “to_vector” Bag function to get the cards in a hand so I could write a Print_Vector function. But generally:

- Cards go into the hand and reward pile using insert

- Specific cards leave the hand and reward pile using remove

- The card that gets played from the hand gets selected using (the random version of) choose

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education