Ok, so... let's give a nice new make up to the code until now... still not complete, but better... We got to put the code for the case in wich there are all briscole ... we will choose the smallest one as usual, but... we need some code... after that, we should go on with the game and make the other player play ... the output is one of the possible results
from random import shuffle
cards = [str(num)+color for num in range(1,11) for color in ['♥','♦','♣','♠']]
x = 0
shuffle(cards)
pc1 = [cards.pop() for x in range(3)]
print("Pc1 cards: ", pc1)
briscola = cards.pop()
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[-1]
match = card_color == briscola_color
if not match:
cardschoice += [c]
return cardschoice
scelte = choose(pc1)
print("Cards of choice (whitout briscola)",scelte)
pc1v = [] # valori
pc1c = [] # semi
for i in scelte:
if int(i[:-1])==1:
pc1v+= [11]
elif int(i[:-1])==3:
pc1v+= [10]
elif int(i[:-1])==10:
pc1v+= [4]
elif int(i[:-1])==9:
pc1v+= [3]
elif int(i[:-1])==8:
pc1v+= [2]
else:
pc1v += [int(i[:-1])-7] # lista valori
pc1c += i[-1] # lista semi
pcmin = min(pc1v) # minimo dei valori
for i in pc1v: # look for the minimum value
if i == pcmin:
cartascelta = scelte[pc1v.index(pcmin)]
print("La carta scelta è",cartascelta)
Comments
Post a Comment