Below is code to show possible trump with values. The dictionary {} was used, and it nicely lists things without [] brackets. Next will be to actually compare the cards dealt. Either that code will be put back in or something new will replace. Can be tested at https://www.programiz.com/python-programming/online-compiler/ (Remove the 3 lines of "stuff" on the left on their site, or it might not run properly.)
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♥"]
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]
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:
print("Trump could be clubs.")
clubstrump = {
"High Trump": "\nTop 3: A♣ J♠ J♣", "High Trump2": "Other trump: 9♣ 10♣ Q♣ K♣",
"One Point": "\n1 point cards: 9♠ 9♦ 9♥",
"Two Points": "\n2 point cards: 10♠ 10♦ 10♥",
"Three Points": "\n3 point cards: J♦ J♥",
"Four Points": "\n4 point cards: Q♠ Q♦ Q♥",
"Five Points": "\n5 point cards: K♠ K♦ K♥",
"Six Points": "\n6 point cards: A♠ A♦ A♥",
}
print(clubstrump["High Trump"],clubstrump["High Trump2"], clubstrump["One Point"], clubstrump["Two Points"], clubstrump["Three Points"], clubstrump["Four Points"], clubstrump["Five Points"], clubstrump["Six Points"])
if cnums_dealt[20] > 5 and cnums_dealt[20] < 12:
print("Trump could be spades.")
spadestrump = {
"High Trump": "\nTop 3: A♠ J♣ J♠", "High Trump2": "Other trump: 9♠ 10♠ Q♠ K♠",
"One Point": "\n1 point cards: 9♣ 9♦ 9♥",
"Two Points": "\n2 point cards: 10♣ 10♦ 10♥",
"Three Points": "\n3 point cards: J♦ J♥",
"Four Points": "\n4 point cards: Q♣ Q♦ Q♥",
"Five Points": "\n5 point cards: K♣ K♦ K♥",
"Six Points": "\n6 point cards: A♣ A♦ A♥",
}
print(spadestrump["High Trump"],spadestrump["High Trump2"], spadestrump["One Point"], spadestrump["Two Points"], spadestrump["Three Points"], spadestrump["Four Points"], spadestrump["Five Points"], spadestrump["Six Points"])
if cnums_dealt[20] > 11 and cnums_dealt[20] < 18:
print("Trump could be diamonds.")
diamondtrump = {
"High Trump": "\nTop 3: A♦ J♥ J♦", "High Trump2": "Other trump: 9♦, 10♦, Q♦, K♦",
"One Point": "\n1 point cards: 9♣ 9♠ 9♥",
"Two Points": "\n2 point cards: 10♣ 10♠ 10♥",
"Three Points": "\n3 point cards: J♣ J♠",
"Four Points": "\n4 point cards: Q♣ Q♠ Q♥",
"Five Points": "\n5 point cards: K♣ K♠ K♥",
"Six Points": "\n6 point cards: A♣ A♠ A♥",
}
print(diamondtrump["High Trump"],diamondtrump["High Trump2"], diamondtrump["One Point"], diamondtrump["Two Points"], diamondtrump["Three Points"], diamondtrump["Four Points"], diamondtrump["Five Points"], diamondtrump["Six Points"])
if cnums_dealt[20] > 17 and cnums_dealt[20] < 24:
print("Trump could be hearts.")
heartstrump = {
"High Trump": "\nTop 3: A♥ J♦ J♥", "High Trump2": "Other trump: 9♥, 10♥, Q♥, K♥",
"One Point": "\n1 point cards: 9♣ 9♠ 9♦",
"Two Points": "\n2 point cards: 10♣ 10♠ 10♦",
"Three Points": "\n3 point cards: J♣ J♠",
"Four Points": "\n4 point cards: Q♣ Q♠ Q♦",
"Five Points": "\n5 point cards: K♣ K♠ K♦",
"Six Points": "\n6 point cards: A♣ A♠ A♦",
}
print(heartstrump["High Trump"], heartstrump["High Trump2"], heartstrump["One Point"], heartstrump["Two Points"], heartstrump["Three Points"], heartstrump["Four Points"], heartstrump["Five Points"], heartstrump["Six Points"])
Thursday, September 12, 2024
Euchre (Card Game) Placing values (using dictionary command)
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