So, what I changed in the code?
def start():
[...]
I added this two dictonaries to make the pc2 able to answer to a little card, that is not a briscola... after he chase for a card that makes him gain points, he search for cards that will let the other win without gainining money... so with those dictonaries and the next function...... it should work. When you call this it puts together 3 lists: the list that make me do points, the list with the cards of any color, except the color of the briscola, and the list with the cards equal or greater than the card played by PC1 but of another color, so that PC2 doesn' take the lead, because he wants the other to play until he gains points ... well this part must be revisited, because PC1 should take even if he does not gain, if acting so he avoids loosing points...
def start():
[...]
dictworst = {7:[2,4,5,6],
6:[2,4,5],
5:[2,4],
4:[2],
2:[11]}
otherseed = {7:[7,8,9,10],
6:[6,7,8,9,10],
5:[5,6,7,8,9],
4:[4,5,6,7,8,9,10],
2:[2,3,4,5,6,7,8,9,10]}
[...]
def take(cardontable,listofcards):
'creates a list of cards to play against a card of the other player'
seeds = ['♥','♦','♣','♠']
seed = cardontable[-1]
seeds.pop(seeds.index(briscola[-1]))
worstnum = dictworst[num(cardontable)]
# create a list with the scartine of various colors
worstlist = [str(x)+s for x in worstnum for s in seeds]
worsts = otherseed[num(cardontable)]
seeds.pop(seeds.index(cardontable[-1]))
otherslist = [str(x)+s for x in otherseed for s in seeds]
# the cards that gives points
wish = [str(x)+seed for x in listofcards]
# adding the cards that don't gives points that you play if don't have the previous
wish = wish + worstlist + otherslist
print("Order of cards PC2 would play if he had:\n",wish)
return wish
[...]
def pc2Turn():
[...]
if isScart(pc1_tbl):
for c in take(pc1_tbl,[1,3,10,9,8]):
if c in pc2:
print(c, "<== tiro di PC2")
break
Comments
Post a Comment