Question: Exercise: MiniWarGame. In this exercise, we will implement a mini version of the card game War. There are 2 players, each having a deck

Exercise: MiniWarGame. In this exercise, we will implement a mini version of the card game "War". There are 2 players, each having a deckwith 6 "cards": There are two cards with value 1, two cardswith value 2, and two cards with value 3. In every roundeach player pulls the top card from the deck - the player

Exercise: MiniWarGame. In this exercise, we will implement a mini version of the card game "War". There are 2 players, each having a deck with 6 "cards": There are two cards with value 1, two cards with value 2, and two cards with value 3. In every round each player pulls the top card from the deck - the player that has the highest number, will take both cards and add them at the rear of his deck (his original card first, then the opponent's card). If both players pull the same number - we flip a coin and the winner will take both cards. The game ends when one of the players has won all cards and the other player has an empty deck. We initialize the game by (randomly) setting a deck for each player. Then, as long as no deck is empty, we play the rounds. At the end we announce the winner. At the beginning of each round, print out the decks. If a coin was flipped, print out the player that won that round. At the end, print the decks and announce the winner. Alice starts with deck: 3 2 3 1 2 1 bob starts with deck: 3 1 3 2 2 1 Round: 1 ********** Alice: 3 2 3 1 21 bob: 3 1 3 2 2 1 flipped coin! bob won Round: 2 ****: ***** Alice: 2 3 1 2 1 bob: 1 3 2 2 1 3 3 Round: 3 ***** **** Alice: 3 1 2 1 2 1 bob: 3 2 2 1 3 3 flipped coin! bob won Round: 4 ********** Alice: 1 2 1 2 1 bob: 2 2 1 3 3 3 3 Round: 5 ********** Alice: 2 1 2 1 bob: 2 1 3 3 3 3 2 1 flipped coin! Alice won Round: 6 ********** Alice: 1 2 1 2 2 bob: 1 3 3 3 3 2 1 flipped coin! Alice won Round: 7 ********** Alice: 2 1 2 2 11 bob: 3 3 3 3 2 1 Round: 8 ********** Alice: 1 2 2 11 bob: 3 3 3 2 1 3 2 Round: 9 ********** Alice: 2 2 1 1 bob: 3 3 2 1 3 2 3 1 Round: 10 ********** Alice: 2 1 1 bob: 3 2 1 3 2 3 1 32 Round: 11 ****: *** Alice: 1 1 bob: 2 1 3 2 3 1 3 232 Round: 12 ********** Alice: 1 bob: 1 3 2 3 1 3 2 3 2 2 1 flipped coin! bob won bob won!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import random class MiniWarGame def initself selfplayer1deck 1 1 2 2 3 3 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!