Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

This is a problem to code a very simple game played by children called War. You need two decks of cards that have been shuffled (randomized in order). Each player has one deck. Each player draws the...

1 answer below »

This is a problem to code a very simple game played by children called War.

You need two decks of cards that have been shuffled (randomized in order).

Each player has one deck.

Each player draws the top card from their deck of cards and shows it.

  • If P1 has the higher card, P1 wins both cards.
  • If P2 has the higher card P2 wins both cards.
  • Crazy Crazy rule -- Before the game begins, a random card is picked and that card beats any FACE card but otherwise only beats lower value cards. So, say a three, then a three beats a King, but does not beat a 4.
  • If the two cards are equal(war):
  • Each player draws three cards. The sum of the three cards is the score (Pictures and Aces are all 10). High wins all these cards.
  • If another tie occurs, draw three more and keep going until the tie is broken.
  • If there are not three cards left and a war starts. The player with the most points left wins all the remaining cards.

Honestly, feel free to mod the rules to any version of this you know or prefer. Develop a program which will simulate on the screen, the war game and keep up with the running score for the round as well as the match score. A match is the best of three games.

Biggest tips here:

Be careful about the ties, that is the hardest thing to code.

Ensure you reseed the randoms if you are allowing repeated play.

Answered 1 days After Dec 03, 2021

Solution

Sathishkumar answered on Dec 05 2021
112 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here