I will post the code until now and the output
cards = [str(num)+color for num in range(1,11) for color in ['♥','♦','♣','♠']]
x = 0
for c in cards:
print(c,end=' ')
x +=1
if x==10:
x = 0
print()
from random import shuffle
shuffle(cards)
def pop(cardnum):
'pc1 = pop(3) # it gives a list of 3 cards as result'
cardlist = []
for i in range(cardnum):
cardlist += [cards.pop()]
return cardlist
pc1 = []
pc1 = pop(3)
print("Pc1 cards: ", pc1)
briscola = pop(1)
print("Briscola", briscola)
def choose(cards):
'It chooses among cards, little cards first, then little briscole, then big cards'
cardschoice = []
for c in cards:
card_color = c[-1]
briscola_color = briscola[0][-1]
match = card_color == briscola_color
if not match:
cardschoice += [c]
number = len(cardschoice)
return cardschoice
def smallest(cards):
card = min(cards)
def choose2(cards):
cartascelta = ''
leng = len(cards)
if leng == 1:
cartascelta = cards[0]
if leng == 2:
cartascelta = smallest(cards)
def evaluate(cards):
dict_card = {}
for c in cards:
num= int(c[:-1])
val = {x:0 for x in range(1,11)}
val[1]=11
val[3]=10
val[8]=2
val[9]=3
val[10]=4
dict_card[c] = val[num]
return dict_card
cardsvalues = evaluate(cards)
print("Cards values:",cardsvalues)
cardsToChoose = choose(pc1)
print("Choose among: ",cardsToChoose)
print("Pc cards values:",evaluate(pc1))
Comments
Post a Comment