Using Python 3.5.2 and IDLE Write the code for a modified game of the card game crazy eights (much like a game of UNO, where the card played is now on top of the deck and its number or face value is now what is playable for the next player). Write the code to be a 2 player game with any 8 card being able to input a new face value to play on the discard pile. Rules: Use a standard deck of cards, each player starts with 8 cards. To begin flip over the top card from the draw pile. To play a card it must match either the number or face (hearts, spades, diamonds, clubs). If an 8 card is played, that player may choose what to change the face value to. If a player does not have a playable card, they must draw a new card and lose their turn. The object is to run out of cards before the other player.
Python Code for UNO Game :
from random import randint
class StandardCards:
def __init__(self,c,n):
self.color = c
self.number = n
def __str__(self):
return self.color + " " + str(self.number)
__repr__ = __str__
class WildCard:
def __init__(self):
self.is_draw_4 = False
def __str__(self):
if self.is_draw_4 == False:
return "Wild"
else:
return "Wild Draw 4"
__repr__ = __str__
# never used card
class ReversCard:
def __init__(self,c):
self.color = c
def __str__(self):
return self.color + "Reverse"
__repr__ = __str__
class SkipCard:
def __init__(self,c):
self.color = c
def __str__(self):
return self.color + "Skip"
__repr__ = __str__
class DrawCard:
def __init__(self,c):
DrawCard.color = c
def __str__(self):
return self.color + " Draw 2 "
__repr__ = __str__
class Player:
def __init__(self,name,pid):
self.name = name
self.pid = pid
self.cards = []
def __str__(self):
return '%s: %s' % (self.name, ', '.join(str(card) for card in
self.cards))
__repr__ = __str__
def create_deck():
deck = []
for i in range(10):
for color in ['blue','green','red','yellow']:
if i == 0:
card = StandardCards(color,i)
deck.append(card)
else:
card = StandardCards(color,i)
deck.append(card)
card = StandardCards(color,i)
deck.append(card)
# makes the wild card
for i in range(4):
card = WildCard()
deck.append(card)
#makes wild card that is a draw 4
for i in range(4):
cards = WildCard() # never used
card.is_draw_4 = True
deck.append(card)
return deck
def deal_one_card(p,deck):
if len(deck)==0:
return
i = randint(0,len(deck)-1)
p.cards.append(deck[i])
deck.remove(deck[i])
def create_discard_pile(deck):
discard_pile = []
i = randint(0,len(deck)-1)
discard_pile.append(deck[i])
deck.remove(deck[i])
return discard_pile
def deal(p1,p2,deck):
for i in range(8):
deal_one_card(p1,deck)
deal_one_card(p2,deck)
if __name__ == '__main__':
p1 = Player("Jim",1)
p2 = Player("John",2)
deck = create_deck()
deal(p1,p2,deck)
discard_pile = create_discard_pile(deck)
print(p1)
print(p2)
print(discard_pile[-1])
Output :
sh-4.3$ python main.py
Jim: yellow 1, yellow 4, yellow 3, red 6, blue 4, green 6, green 1, red 9
John: green 2, blue 7, red 2, green 4, red 5, yellow 5, Wild, blue 8
yellow 8
Using Python 3.5.2 and IDLE Write the code for a modified game of the card game...
Program 4: C++ The Game of War The game of war is a card game played by children and budding computer scientists. From Wikipedia: The objective of the game is to win all cards [Source: Wikipedia]. There are different interpretations on how to play The Game of War, so we will specify our SMU rules below: 1) 52 cards are shuffled and split evenly amongst two players (26 each) a. The 26 cards are placed into a “to play” pile...
2 A Game of UNO You are to develop an interactive game of UNO between a number of players. The gameplay for UNO is described at https://www.unorules.com/. Your program should operate as follows. 2.1 Setup 1. UNO cards are represented as variables of the following type: typedef struct card_s { char suit[7]; int value; char action[15]; struct card_s *pt; } card; You are allowed to add attributes to this definition, but not to remove any. You can represent colors by...
The question is to make the game of war using Python. The information on how the cards will be represented and how the game will be played along with 2 sample runs is below. Representation of the deck of cards: The deck of cards will be simulated with integers of values from 1 to 13, where 1 represents the Ace, 11 the Jack, 12 the Queen, and 13 the King – these integers also represent the face values of the...
Write in Java! Do NOT write two different programs for
Deck and Card, it should be only one program not 2 separate
ones!!!!!!
!!!!!!!!!!!!!!!Use at least one array defined in your
code and two array lists defined by the operation of your
code!!!!!!!!!!!!!!!!!!!!!
The array should be 52 elements and contain a representation of
a standard deck of cards, in new deck order. (This is the order of
a deck of cards new from the box.)
The 2 Array lists...
This needs to be done in c++11 and be compatible with g++ compiling Project description: Write a C++ program to simulate a simple card game between two players. The game proceeds as follows: The 52 cards in a deck of cards are shuffled and each player draws three cards from the top of the deck. Remaining cards are placed in a pile face-down between the two players. Players then select a card from the three in their hand. The player...
Hey, I need something like this output for war2 class, when there is tie in card game Computer Player Human Player Result 11 of Clubs 11 of Spades Tie WAR is CALLED! 10 of Spades 11 of Clubs Discard 4 of Clubs 2 of Hearts Discard 7 of Hearts 4 of Diamonds Discard 10 of Clubs 5 of Clubs Discard 2 of Clubs 7 of Diamonds Discard 4 of Hearts 4 of Spades Discard 7 of Diamonds 1 of Hearts...
4. A group of students are playing a card game. The game uses a well-shuffled deck of 56 playing cards. 52 of the cards are exactly as described in your textbook. However, there are also 4 Jokers. This means that there are 56 cards: 14 are hearts, 14 are diamonds, 14 are clubs, and 14 are spades. A hand of cards consists of Eight of the cards. Find the number of different hands that contain: a. At least 6 Diamonds....
19. A Card Game
19. A Card Game Three students are playing a card game. They decide to choose the first person to play by each selectinga card from the 52-card deck and look- ing for the highest card in value and suit. They rank the suits from lowest to highest: clubs, diamonds, hearts, and spades. a. If the card is replaced in the deck after each student chooses, how many possible configurations of the three choices are possible? b....
War—A Card game Playing cards are used in many computer games, including versions of such classics as solitaire, hearts, and poker. War: Deal two Cards—one for the computer and one for the player—and determine the higher card, then display a message indicating whether the cards are equal, the computer won, or the player won. (Playing cards are considered equal when they have the same value, no matter what their suit is.) For this game, assume the Ace (value 1) is...
Using C++: 1. Array and Struct in Card applications: In card game design, card suit and face values can be defined with enumeration values. Declare suit values - – hearts, clubs, diamonds, spades using enum, declare face values of 2 – 10, Jack, Queen, King, Ace using enum Declare a structure called Card, and it includes two data members, whose data types are the above two defined enumerations suit and face typedef an array called Deck, and it includes all...