Corrected high card error for hands < 5 cards. Added discard to Player.

git-svn-id: file:///srv/svn/euler@51 e5f4c3ec-3c0c-11df-b522-21efaa4426b5
This commit is contained in:
Correl Roush 2010-04-23 03:48:36 +00:00
parent 3373f8f1f7
commit ad80b41e06

View file

@ -176,6 +176,8 @@ class Hand:
self.__rank = Hand.ONE_PAIR
mvalues = [m[0] for m in multiples]
self.__values = mvalues + [c.value for c in self.__cards if c.value not in mvalues]
if not self.__rank:
self.__rank = Hand.HIGH_CARD
return self.__rank
def values(self):
@ -349,6 +351,9 @@ class Player:
# Rebuild and re-evaluate hand
self.__hand = Hand.create_best_hand([str(c) for c in self.__community_cards + self.__cards])
def discard(self, index):
self.__cards.pop(index)
self.__hand = Hand.create_best_hand([str(c) for c in self.__community_cards + self.__cards])
def hand(self):
return self.__hand
def __repr__(self):
@ -376,4 +381,4 @@ if __name__ == '__main__':
players = sorted(players, reverse=True)
print 'Community', community_cards
for player in players:
print player
print player