CSCI 105 Ivy Tech Community College of Indiana Card Game Python Project
Question Description
Use what you have created and extend it to actually implement a working card game. War is pretty easy, as is BlackJack. If you’re feeling more ambitious, you might try something like “Go Fish.” Poker is easy to write, but the scorekeeping can be tricky.
Or keep the program as it is and try another implementation closer to the way humans play cards (Uno or any other card games you prefer).
from random import *
NUMCARDS = 52
DECK = 0
PLAYER = 1
COMP = 2
cardLoc = [0] * NUMCARDS
cardSuit1=[]
cardSuit2=[]
deck=[]
suitName = (“hearts”, “diamonds”, “spades”, “clubs”)
rankName = (“Ace”, “Two”, “Three”, “Four”, “Five”, “Six”, “Seven”,
“Eight”, “Nine”, “Ten”, “Jack”, “Queen”, “King”)
playerName = (“deck”, “player”, “computer”)
def clearDeck():
for x in range(52):
cardLoc[x]= x
deck.append(x)
”’
def assignCard(option):
count = len(deck)//2
if option== PLAYER :
cardSuit1.clear()
else:
cardSuit2.clear()
for x in range(count):
value= randint(0,len(deck))
if(option==PLAYER):
cardSuit1[x] = deck.pop(value)
else:
cardSuit2[x] = deck.pop(value)
”’
def assignCard(option):
value = randint(0,len(deck))
if option == PLAYER:
cardSuit1.append(deck.pop(value))
else:
cardSuit2.append(deck.pop(value))
def showHand(option):
if option==PLAYER:
print(“nDiplaying Players hand:” )
for x in cardSuit1:
r = x//13
c = x%13
print(rankName[c],”of”,suitName[r],” “)
else:
print(“nDiplaying computer hand:” )
for x in cardSuit2:
r = x//13
c = x%13
print(rankName[c],”of”,suitName[r],” “)
def showDeck():
print(” Location of all cards: “)
for x in cardLoc:
r = x//13
c = x%13
if x in cardSuit1:
print(x,rankName[c],”of”,suitName[r],”player”)
elif x in cardSuit2:
print(x,rankName[c],”of”,suitName[r],”computer”)
else:
print(x,rankName[c],”of”,suitName[r],”deck”)
def main():
clearDeck()
for i in range(5):
assignCard(PLAYER)
assignCard(COMP)
showDeck()
showHand(PLAYER)
showHand(COMP)
main()
"Place your order now for a similar assignment and have exceptional work written by our team of experts, guaranteeing you "A" results."