Changeset 6

Show
Ignore:
Timestamp:
01/23/08 08:53:40 (4 years ago)
Author:
mike
Message:

had judge hand return tuples with the first item beign the rank of the highest type of hand

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • hand.py

    r5 r6  
    11import deck 
    22 
    3 hand_orders = ["straight_flush", 
     3hand_orders = [ "high_card", 
     4                "pair", 
     5                "two_pair", 
     6                "three_of_a_kind", 
     7                "straight", 
     8                "flush", 
     9                "full_house", 
    410                "four_of_a_kind", 
    5                 "full_house", 
    6                 "flush", 
    7                 "straight", 
    8                 "three_of_a_kind", 
    9                 "two_pair", 
    10                 "pair", 
    11                 "high_card"] 
     11                "straight_flush" ] 
    1212 
    1313#returns the best combination for the 5 cards 
    1414def judge_hand(cards): 
    1515    ret = is_straight_flush(cards) 
    16     if ret: return ret 
    17     else: return is_n_kinds([a for (a,b) in cards]) 
     16    if not ret: ret = is_n_kinds([a for (a,b) in cards]) 
     17    #replace the text with a value 
     18    return (hand_orders.index(ret[0]), ret[1]) 
     19 
    1820 
    1921#for all these functions, make sure cards are sorted DESCENDING!!!! 
     
    6971        #now check if it's two pair 
    7072        if len(whats_left) >= 2: 
    71             print highest_card 
    7273            ret = is_n_kinds(whats_left) 
    7374            #if the subset is a pair then this is a two pair