The code below places values based on the card turned over. Next will be to add bidding and including dealer's (player 4) advantage taking the card. Can be tested at https://www.online-python.com/
#This is to evaluate dealt cards for all four players.
import random
trump_order = []
cnums_dealt = []
cards = ["9♣", "10♣", "J♣", "Q♣", "K♣", "A♣", "9♠", "10♠", "J♠", "Q♠", "K♠", "A♠", "9♦", "10♦", "J♦", "Q♦", "K♦", "A♦", "9♥", "10♥", "J♥", "Q♥", "K♥", "A♥"]
cards2 = ["9♣", "10♣", "J♣", "Q♣", "K♣", "A♣", "9♠", "10♠", "J♠", "Q♠", "K♠", "A♠", "9♦", "10♦", "J♦", "Q♦", "K♦", "A♦", "9♥", "10♥", "J♥", "Q♥", "K♥", "A♥"]
cnums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
cnums_value = []
cardsnum_dealt = 23
#Generating cards dealt out
for x in range (21):
cards_dealt = (random.randint(0,cardsnum_dealt))
if len (cnums) == 4:
cnums_number = cnums[cards_dealt]
trump_order.append(cards[cards_dealt])
cnums_dealt.append(cnums[cards_dealt])
cardsnum_dealt = cardsnum_dealt - 1
cards.pop(cards_dealt)
cnums.pop(cards_dealt)
#print ("trump order ", trump_order)
#print ("cnums_dealt ", cnums_dealt)
print ("\nThe card the dealer turned over was", trump_order[20])
#Assigning values to each card
if cnums_dealt[20] < 6:
cnums_dealtcopy = cnums_dealt.copy()
#print("cnums_dealtcopy:", cnums_dealtcopy)
#print("Trump could be clubs.")
for value in range (13):
for card_num in range (21):
if cnums_dealt[card_num] == 6 or cnums_dealt[card_num] == 12 or cnums_dealt[card_num] == 18:
cnums_dealtcopy[card_num] = 1
if cnums_dealt[card_num] == 7 or cnums_dealt[card_num] == 13 or cnums_dealt[card_num] == 19:
cnums_dealtcopy[card_num] = 2
if cnums_dealt[card_num] == 14 or cnums_dealt[card_num] == 20:
cnums_dealtcopy[card_num] = 3
if cnums_dealt[card_num] == 9 or cnums_dealt[card_num] == 15 or cnums_dealt[card_num] == 21:
cnums_dealtcopy[card_num] = 4
if cnums_dealt[card_num] == 10 or cnums_dealt[card_num] == 16 or cnums_dealt[card_num] == 22:
cnums_dealtcopy[card_num] = 5
if cnums_dealt[card_num] == 11 or cnums_dealt[card_num] == 17 or cnums_dealt[card_num] == 23:
cnums_dealtcopy[card_num] = 6
if cnums_dealt[card_num] == 0:
cnums_dealtcopy[card_num] = 7
if cnums_dealt[card_num] == 1:
cnums_dealtcopy[card_num] = 8
if cnums_dealt[card_num] == 2:
cnums_dealtcopy[card_num] = 13
if cnums_dealt[card_num] == 3:
cnums_dealtcopy[card_num] = 9
if cnums_dealt[card_num] == 4:
cnums_dealtcopy[card_num] = 10
if cnums_dealt[card_num] == 5:
cnums_dealtcopy[card_num] = 11
if cnums_dealt[card_num] == 8:
cnums_dealtcopy[card_num] = 12
#print ("New cnums_dealtcopy", cnums_dealtcopy)
if cnums_dealt[20] > 5 and cnums_dealt[20] < 12:
cnums_dealtcopy = cnums_dealt.copy()
#print("cnums_dealtcopy:", cnums_dealtcopy)
#print("Trump could be spades.")
for value in range (13):
for card_num in range (21):
if cnums_dealt[card_num] == 0 or cnums_dealt[card_num] == 12 or cnums_dealt[card_num] == 18:
cnums_dealtcopy[card_num] = 1
if cnums_dealt[card_num] == 1 or cnums_dealt[card_num] == 13 or cnums_dealt[card_num] == 19:
cnums_dealtcopy[card_num] = 2
if cnums_dealt[card_num] == 14 or cnums_dealt[card_num] == 20:
cnums_dealtcopy[card_num] = 3
if cnums_dealt[card_num] == 3 or cnums_dealt[card_num] == 15 or cnums_dealt[card_num] == 21:
cnums_dealtcopy[card_num] = 4
if cnums_dealt[card_num] == 4 or cnums_dealt[card_num] == 16 or cnums_dealt[card_num] == 22:
cnums_dealtcopy[card_num] = 5
if cnums_dealt[card_num] == 5 or cnums_dealt[card_num] == 17 or cnums_dealt[card_num] == 23:
cnums_dealtcopy[card_num] = 6
if cnums_dealt[card_num] == 6:
cnums_dealtcopy[card_num] = 7
if cnums_dealt[card_num] == 7:
cnums_dealtcopy[card_num] = 8
if cnums_dealt[card_num] == 8:
cnums_dealtcopy[card_num] = 13
if cnums_dealt[card_num] == 9:
cnums_dealtcopy[card_num] = 9
if cnums_dealt[card_num] == 10:
cnums_dealtcopy[card_num] = 10
if cnums_dealt[card_num] == 11:
cnums_dealtcopy[card_num] = 11
if cnums_dealt[card_num] == 2:
cnums_dealtcopy[card_num] = 12
#print ("New cnums_dealtcopy", cnums_dealtcopy)
if cnums_dealt[20] > 11 and cnums_dealt[20] < 18:
cnums_dealtcopy = cnums_dealt.copy()
#print("cnums_dealtcopy:", cnums_dealtcopy)
#print("Trump could be diamonds.")
for value in range (13):
for card_num in range (21):
if cnums_dealt[card_num] == 0 or cnums_dealt[card_num] == 6 or cnums_dealt[card_num] == 18:
cnums_dealtcopy[card_num] = 1
if cnums_dealt[card_num] == 1 or cnums_dealt[card_num] == 7 or cnums_dealt[card_num] == 19:
cnums_dealtcopy[card_num] = 2
if cnums_dealt[card_num] == 2 or cnums_dealt[card_num] == 8:
cnums_dealtcopy[card_num] = 3
if cnums_dealt[card_num] == 3 or cnums_dealt[card_num] == 9 or cnums_dealt[card_num] == 21:
cnums_dealtcopy[card_num] = 4
if cnums_dealt[card_num] == 4 or cnums_dealt[card_num] == 10 or cnums_dealt[card_num] == 22:
cnums_dealtcopy[card_num] = 5
if cnums_dealt[card_num] == 5 or cnums_dealt[card_num] == 11 or cnums_dealt[card_num] == 23:
cnums_dealtcopy[card_num] = 6
if cnums_dealt[card_num] == 12:
cnums_dealtcopy[card_num] = 7
if cnums_dealt[card_num] == 13:
cnums_dealtcopy[card_num] = 8
if cnums_dealt[card_num] == 14:
cnums_dealtcopy[card_num] = 13
if cnums_dealt[card_num] == 15:
cnums_dealtcopy[card_num] = 9
if cnums_dealt[card_num] == 16:
cnums_dealtcopy[card_num] = 10
if cnums_dealt[card_num] == 17:
cnums_dealtcopy[card_num] = 11
if cnums_dealt[card_num] == 20:
cnums_dealtcopy[card_num] = 12
#print ("New cnums_dealtcopy", cnums_dealtcopy)
if cnums_dealt[20] > 17 and cnums_dealt[20] < 24:
cnums_dealtcopy = cnums_dealt.copy()
#print("cnums_dealtcopy:", cnums_dealtcopy)
#print("Trump could be hearts.")
for value in range (13):
for card_num in range (21):
if cnums_dealt[card_num] == 0 or cnums_dealt[card_num] == 6 or cnums_dealt[card_num] == 12:
cnums_dealtcopy[card_num] = 1
if cnums_dealt[card_num] == 1 or cnums_dealt[card_num] == 7 or cnums_dealt[card_num] == 13:
cnums_dealtcopy[card_num] = 2
if cnums_dealt[card_num] == 2 or cnums_dealt[card_num] == 8:
cnums_dealtcopy[card_num] = 3
if cnums_dealt[card_num] == 3 or cnums_dealt[card_num] == 9 or cnums_dealt[card_num] == 15:
cnums_dealtcopy[card_num] = 4
if cnums_dealt[card_num] == 4 or cnums_dealt[card_num] == 10 or cnums_dealt[card_num] == 16:
cnums_dealtcopy[card_num] = 5
if cnums_dealt[card_num] == 5 or cnums_dealt[card_num] == 11 or cnums_dealt[card_num] == 17:
cnums_dealtcopy[card_num] = 6
if cnums_dealt[card_num] == 18:
cnums_dealtcopy[card_num] = 7
if cnums_dealt[card_num] == 19:
cnums_dealtcopy[card_num] = 8
if cnums_dealt[card_num] == 20:
cnums_dealtcopy[card_num] = 13
if cnums_dealt[card_num] == 21:
cnums_dealtcopy[card_num] = 9
if cnums_dealt[card_num] == 22:
cnums_dealtcopy[card_num] = 10
if cnums_dealt[card_num] == 23:
cnums_dealtcopy[card_num] = 11
if cnums_dealt[card_num] == 14:
cnums_dealtcopy[card_num] = 12
#print ("New cnums_dealtcopy", cnums_dealtcopy)
player1 = trump_order[0], trump_order[4], trump_order[8], trump_order[12], trump_order[16]
player2 = trump_order[1], trump_order[5], trump_order[9], trump_order[13], trump_order[17]
player3 = trump_order[2], trump_order[6], trump_order[10], trump_order[14], trump_order[18]
player4 = trump_order[3], trump_order[7], trump_order[11], trump_order[15], trump_order[19]
player1_bidding_points = cnums_dealtcopy[0]+cnums_dealtcopy[4]+cnums_dealtcopy[8]+cnums_dealtcopy[12]+cnums_dealtcopy[16]
player2_bidding_points = cnums_dealtcopy[1]+cnums_dealtcopy[5]+cnums_dealtcopy[9]+cnums_dealtcopy[13]+cnums_dealtcopy[17]
player3_bidding_points = cnums_dealtcopy[2]+cnums_dealtcopy[6]+cnums_dealtcopy[10]+cnums_dealtcopy[14]+cnums_dealtcopy[18]
player4_bidding_points = cnums_dealtcopy[3]+cnums_dealtcopy[7]+cnums_dealtcopy[11]+cnums_dealtcopy[15]+cnums_dealtcopy[19]
print("\n\nPlayer 1: ",player1, "\nbidding points =", player1_bidding_points)
print("\nPlayer 2: ",player2, "\nbidding points =", player2_bidding_points)
print("\nPlayer 3: ",player3, "\nbidding points =", player3_bidding_points)
print("\nPlayer 4: ",player4, "\nbidding points =", player4_bidding_points)
Monday, September 30, 2024
Euchre (Card Game) - Placing values based on card turned over
Subscribe to:
Post Comments (Atom)
-
**See 6/22 post for adjustments.** Code can be tested at https://www.programiz.com/python-programming/online-compiler/ (Remove the 3 lines ...
-
I forgot to put the spellchecker conditional back in, and when I did I realized "elif" had to be used. Otherwise, it would skip in...
No comments:
Post a Comment