Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6.34 The two-player card game War is played with a standard deck of 52 cards. A shuffled deck is evenly split among the two players

6.34

The two-player card game War is played with a standard deck of 52 cards. A shuffled deck is evenly split among the two players who keep their decks face-down. The game consists of battles until one of the players runs out of cards. In a battle, each player reveals the card on top of their deck; the player with the higher card takes both cards and adds them face-down to the bottom of her stack. If both cards have the same value, a war occurs. In a war, each player lays, face-down, their top three cards and picks one of them. The player who picks the higher valued card adds all eight cards to the bottom of her deck. In

case of another tie, wars are repeated until a player wins and collects all cards on the table. If

a player runs out of cards before laying down three cards in a war, he is allowed to complete

the war, using his last card as his pick. In War, the value of a number card is its rank, and the values of cards with rank A, K, Q, and J are 14, 13, 12, and 11, respectively.

Hint: While you do need to consider that you have 4 of each rank (Heart, Spade, Diamond, Club), do NOT worry about card suit just rank (1 14). Be sure to put the card deck creation in two loops.

Write a function war() that simulates one game of war and returns a tuple containing

the number of battles, wars, and two-round wars in the game. Note: When adding

cards to the bottom of a players deck, make sure to shuffle the cards first to add

additional randomness to the simulation.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago