3 Replies - 2731 Views - Last Post: 11 October 2012 - 07:38 PM Rate Topic: -----

#1 phca2011  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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've already a module where the card game is made.
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  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: Python Poker. Hands comparating

Posted 10 October 2012 - 09:48 PM

ack, I can't program in that language!
Was This Post Helpful? 0
  • +
  • -

#3 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,693
  • Joined: 13-March 10

Re: Python Poker. Hands comparating

Posted 11 October 2012 - 08:39 AM

Python??
Was This Post Helpful? 0
  • +
  • -

#4 midknight51  Icon User is offline

  • New D.I.C Head

Reputation: 20
  • View blog
  • 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. :unsure:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1