예제 #1
0
def get_player_winning_hand(player_cards, middle_cards):
    all_cards = player_cards[:]
    all_cards.extend(middle_cards)
    all_hands = sorted(
        [Hand.create_hand(x) for x in itertools.combinations(all_cards, 5)],
        reverse=True)
    return all_hands[0]
예제 #2
0
 def getHand(cls, cardnos):
     hand = PartialHand.empty()
     for c in cardnos:
         hand.addCard(cls.card(c))
     print(hand)
     assert hand.num_cards() == 13, "got {} cards in hand".format(
         hand.num_cards)
     return Hand.from_partial_hand(hand)
예제 #3
0
 def from_expectation_tuple_in_group(cls, expectation, test_group):
     hand_string = expectation[0]
     assert '.' in hand_string, "_split_expectation expectes C.D.H.S formatted hands, missing '.': %s" % hand_string
     expected_call = Call.from_string(expectation[1])
     history_string = expectation[2] if len(expectation) > 2 else ""
     vulnerability_string = expectation[3] if len(expectation) > 3 else None
     hand = Hand.from_cdhs_string(hand_string)
     call_history = CallHistory.from_string(history_string, vulnerability_string=vulnerability_string)
     return cls(test_group, hand, call_history, expected_call)
예제 #4
0
 def test_pbn_string(self):
     reverse_pbn = "AKJ52.J.J9743.54"
     hand = Hand.from_cdhs_string(reverse_pbn)
     self.assertEquals(hand.reverse_pbn_string(), reverse_pbn)
     self.assertEquals(hand.pbn_string(), "54.J9743.J.AKJ52")
예제 #5
0
 def _hand_with_clubs(self, clubs_string):
     spade_filler_string = 'AKQJT98765432'
     hand_string = clubs_string + '...' + spade_filler_string[:-len(clubs_string)]
     return Hand.from_cdhs_string(hand_string)
예제 #6
0
 def test_support_points(self):
     self.assertEquals(Hand.from_cdhs_string("AKJ52.J.J9743.54").support_points(HEARTS), 13)
     self.assertEquals(Hand.from_cdhs_string("AKJ52.J.J9743.54").generic_support_points(), 13)
     self.assertEquals(Hand.from_cdhs_string("AKJ52..J9743.J54").generic_support_points(), 15)
예제 #7
0
 def _assert_non_working_honor_adjustment(self, hand_string, trump, expected_adjustment):
     hand = Hand.from_cdhs_string(hand_string)
     self.assertEquals(hand._support_point_adjustment_for_non_working_honors(trump), expected_adjustment)
예제 #8
0
 def _assert_flat(self, hand_string, flat):
     self.assertEquals(Hand.from_cdhs_string(hand_string).is_flat(), flat)
예제 #9
0
 def _assert_balanced(self, hand_string, balanced):
     self.assertEquals(Hand.from_cdhs_string(hand_string).is_balanced(), balanced)
예제 #10
0
 def test_shdc_dot_string(self):
     cdhs_dot_string = "AKJ52.J.J9743.54"
     hand = Hand.from_cdhs_string(cdhs_dot_string)
     self.assertEquals(hand.cdhs_dot_string(), cdhs_dot_string)
     self.assertEquals(hand.shdc_dot_string(), "54.J9743.J.AKJ52")
예제 #11
0
def hands_from_deal_str(deal_str):
    result = []
    for hand in deal_str.split('\t'):
        cdhs_str = '.'.join(map(lambda s: s[1:], reversed(hand.split())))
        result.append(Hand.from_cdhs_string(cdhs_str))
    return result