Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The idea of the game is that the deck is dealt entirely to the two players. Then, without looking at their hand, both players play


The idea of the game is that the deck is dealt entirely to the two players. Then, without looking at their \"hand\", both players play the top card, and the highest card wins. (Normally, if there's a tie, then you'd get a \"battle\", but we'll ignore that for now. You can discard those cards or put them on a separate list.)

Create a function called SKIRMISH that takes 2 hands of cards. Print the cards that each player has at the beginning of the game. Using the LOOP command, run the game as described above. Print out the card that was played by each player, and who won that round. Do not add \"won\" cards back into the hand, but assemble lists of the cards that both players have won. (Note: the winning cardandthe losing card both go to the winner.) At the end (when the players don't have any cards left), return a list of the two lists.

Note:You will definitely want to make some helper functions here. For one thing, you need to compare the values of cards. That's easy if the values are both numbers. But if when you work with the face cards (ACE, KING, etc).Hint:There's a clever hack you can do using the MEMBER function twice and the (presumably sorted) originalvalueslist.

As a (contrived) example, with small hands (!):

> (SKIRMISH '((ACE HEARTS) (KING HEARTS) (QUEEN HEARTS) (JACK HEARTS) (10 HEARTS)) '((4 HEARTS) (3 HEARTS) (2 HEARTS) (ACE DIAMONDS) (KING DIAMONDS)))P1 won: (ACE HEARTS) (4 HEARTS)P1 won: (KING HEARTS) (3 HEARTS)P1 won: (QUEEN HEARTS) (2 HEARTS)P2 won: (JACK HEARTS) (ACE DIAMONDS)P2 won: (10 HEARTS) (KING DIAMONDS);;; Returns(((2 HEARTS) (QUEEN HEARTS) (3 HEARTS) (KING HEARTS) (4 HEARTS) (ACE HEARTS)) ; P1 cards ((KING DIAMONDS) (10 HEARTS) (ACE DIAMONDS) (JACK HEARTS)) ; P2 cards NIL) ; draw (tied) cards




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

Entrepreneurship

Authors: Andrew Zacharakis, William D Bygrave

5th Edition

1119563097, 9781119563099

More Books

Students also viewed these Programming questions

Question

a sin(2x) x Let f(x)=2x+1 In(be)

Answered: 1 week ago

Question

4 Discuss six factors that make business communication unique

Answered: 1 week ago