Python Poker. Hands comparating

Page 1 of 1

3 Replies - 4513 Views - Last Post: 11 October 2012 - 07:38 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=294939&amp;s=c496a932d9dffbdce5eb4267f3f7fb13&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 phca2011

Reputation: 0
• Posts: 3
• Joined: 09-October 12

Python Poker. Hands comparating

Posted 09 October 2012 - 12:51 PM

Hi guys,

I'm new in Python and I have to made a simple program where I have to compare 2 hands of Poker.
I don't have to consider the flush, the straight flush and the straight.
I've made a dictionnary where my cards value are.
I know the value of the hand (four of kind, pair, etc.)

I have to program the Donne class, but I don't know where to start. Thanks !

```import JeuDeCarte

class Carte(JeuDeCarte.Carte):

def valeur(self):
""" Calculer la valeur de la carte.

:returns: la valeur nominale de la carte pour les cartes de '2' à '10',
10 pour les figures ('J', 'Q' et 'K'), et 1 pour les aces.
"""
return self.valeurs[self.figure]

class Donne(JeuDeCarte.Donne):

'''Valeurs des cartes'''

valeurs = {'A': 14, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8,
'9': 9, '10': 10, 'J': 11, 'Q': 12, 'K': 13}

def _lt_(self, other):
d1 = self.carte
d2 = other.carte
if d1 < d2:
return self
else:
return other

def _eq_(self, other):
d1 = self.carte
d2 = other.carte
if d1 == d2:
return

'''Valeurs des donnes'''

carre = 17
pleine = 13
brelan = 11
doublepaire = 9
paire = 7
haute = 5

paquet = JeuDeCarte.Paquet()
d1 = Poker.Donne()
d2 = Poker.Donne()

for i in range (5):
d1.ajouter(paquet.tirer().flipper())
d2.ajouter(paquet.tirer().flipper())

if d1 < d2:
print('{:>20} < {:<20}'.format(d1, d2))
else:
print('{:>20} => {:<20}'.format(d1, d2))
```

Is This A Good Question/Topic? 0

Replies To: Python Poker. Hands comparating

#2 atraub

• Pythoneer

Reputation: 827
• Posts: 2,231
• Joined: 23-December 08

Re: Python Poker. Hands comparating

Posted 10 October 2012 - 09:48 PM

ack, I can't program in that language!

#3 darek9576

• D.I.C Lover

Reputation: 203
• Posts: 1,717
• Joined: 13-March 10

Re: Python Poker. Hands comparating

Posted 11 October 2012 - 08:39 AM

Python??

#4 midknight51

Reputation: 20
• Posts: 47
• Joined: 25-September 12

Re: Python Poker. Hands comparating

Posted 11 October 2012 - 07:38 PM

Python is about readability. You have completely destroyed that idea by posting in a language I cant understand.