Changeset 21 for hand.py

Show
Ignore:
Timestamp:
02/04/08 08:40:59 (4 years ago)
Author:
mike
Message:

Fixed hand ranking algorithm

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • hand.py

    r9 r21  
    1010                "four_of_a_kind", 
    1111                "straight_flush" ] 
     12 
     13#def format_hand(hand): 
     14#input all 7 cards 
     15def best_hand(cards): 
     16    all_poosible_hands = list(combNoReplace(cards,5)) 
     17    for h in all_poosible_hands: h.sort( cmp = lambda a,b: cmp(b,a) ) 
     18    pos_hands = [judge_hand(h) for h in all_poosible_hands] 
     19    return max(pos_hands) 
     20     
    1221 
    1322#returns the best combination for the 5 cards 
     
    6473                highest_n = current_n 
    6574                highest_card = a 
     75        else: 
     76            last = a 
     77            current_n = 1 
    6678    if highest_n == 1: return ("high_card",card_vals) 
    6779    #check for full house