def test_side_pair(self): cards = [ Card(2, Suit.hearts), Card(2, Suit.spades), Card(3, Suit.diamonds) ] self.assertEqual(Hand(cards).type_side, HandType.pair_side)
def test_expected_ride(self): hand = [ Card(11, Suit.clubs), Card(11, Suit.spades), Card(12, Suit.clubs) ] self.assertEqual(Statistics.shouldRide(hand), True)
def test_side_three_of_kind(self): cards = [ Card(2, Suit.hearts), Card(2, Suit.diamonds), Card(2, Suit.spades) ] self.assertEqual(Hand(cards).type_side, HandType.three_of_kind_side)
def test_side_flush(self): cards = [ Card(2, Suit.hearts), Card(4, Suit.hearts), Card(6, Suit.hearts) ] self.assertEqual(Hand(cards).type_side, HandType.flush_side)
def test_side_royal(self): cards = [ Card(11, Suit.hearts), Card(12, Suit.hearts), Card(13, Suit.hearts) ] self.assertEqual(Hand(cards).type_side, HandType.mini_royal)
def test_four_of_kind(self): cards = [ Card(4, Suit.clubs), Card(4, Suit.hearts), Card(4, Suit.diamonds), Card(4, Suit.spades), Card(8, Suit.clubs) ] self.assertEqual(Hand(cards).type, HandType.four_of_kind)
def test_high(self): cards = [ Card(3, Suit.hearts), Card(5, Suit.clubs), Card(6, Suit.diamonds), Card(7, Suit.clubs), Card(8, Suit.clubs) ] self.assertEqual(Hand(cards).type, HandType.high)
def test_full_house(self): cards = [ Card(4, Suit.clubs), Card(4, Suit.hearts), Card(4, Suit.diamonds), Card(8, Suit.spades), Card(8, Suit.clubs) ] self.assertEqual(Hand(cards).type, HandType.full_house)
def test_flush(self): cards = [ Card(2, Suit.clubs), Card(4, Suit.clubs), Card(6, Suit.clubs), Card(8, Suit.clubs), Card(10, Suit.clubs) ] self.assertEqual(Hand(cards).type, HandType.flush)
def test_royal_flush(self): cards = [ Card(1, Suit.clubs), Card(10, Suit.clubs), Card(11, Suit.clubs), Card(12, Suit.clubs), Card(13, Suit.clubs) ] self.assertEqual(Hand(cards).type, HandType.royal_flush)
def test_three_of_kind(self): cards = [ Card(1, Suit.hearts), Card(1, Suit.clubs), Card(1, Suit.diamonds), Card(2, Suit.clubs), Card(3, Suit.clubs) ] self.assertEqual(Hand(cards).type, HandType.three_of_kind)
def test_straight_flush(self): cards = [ Card(4, Suit.clubs), Card(5, Suit.clubs), Card(6, Suit.clubs), Card(7, Suit.clubs), Card(8, Suit.clubs) ] self.assertEqual(Hand(cards).type, HandType.straight_flush)
def test_pair(self): cards = [ Card(1, Suit.hearts), Card(2, Suit.clubs), Card(2, Suit.diamonds), Card(3, Suit.clubs), Card(4, Suit.clubs) ] self.assertEqual(Hand(cards).type, HandType.pair)
def init_54_deck(): ''' Initialize a standard deck of 52 cards, BJ and RJ Returns: (list): Alist of Card object ''' suit_list = ['S', 'H', 'D', 'C'] rank_list = ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K'] res = [Card(suit, rank) for suit in suit_list for rank in rank_list] res.append(Card('BJ', '')) res.append(Card('RJ', '')) return res
def test_expected_val(self): hand = [Card(3, Suit.clubs), Card(3, Suit.spades), Card(10, Suit.clubs)] handDistribution = Statistics.handDistribution(hand, 1) expectedDistribution = dict() expectedDistribution[HandType.pair] = 880 expectedDistribution[HandType.two_pair] = 198 expectedDistribution[HandType.three_of_kind] = 88 expectedDistribution[HandType.full_house] = 9 expectedDistribution[HandType.four_of_kind] = 1 for k,v in handDistribution.items(): if k in expectedDistribution: self.assertEqual(v, expectedDistribution[k]) else: self.assertEqual(v, 0) self.assertEqual(sum(handDistribution.values()), 1176)
def test_payout(self): cards = [ Card(3, Suit.hearts), Card(5, Suit.clubs), Card(6, Suit.diamonds), Card(7, Suit.clubs), Card(8, Suit.clubs) ] self.assertEqual(Hand(cards).payout(1), 0) cards = [ Card(1, Suit.hearts), Card(1, Suit.clubs), Card(1, Suit.diamonds), Card(2, Suit.clubs), Card(3, Suit.clubs) ] self.assertEqual(Hand(cards).payout(1), 3 + 1)
def test_side_straight(self): cards = [ Card(4, Suit.hearts), Card(5, Suit.diamonds), Card(6, Suit.spades) ] self.assertEqual(Hand(cards).type_side, HandType.straight_side) cards = [ Card(12, Suit.hearts), Card(13, Suit.diamonds), Card(1, Suit.spades) ] self.assertEqual(Hand(cards).type_side, HandType.straight_side) cards = [ Card(1, Suit.hearts), Card(2, Suit.diamonds), Card(3, Suit.spades) ] self.assertEqual(Hand(cards).type_side, HandType.straight_side)
def test_straight(self): cards = [ Card(4, Suit.hearts), Card(5, Suit.clubs), Card(6, Suit.clubs), Card(7, Suit.clubs), Card(8, Suit.clubs) ] self.assertEqual(Hand(cards).type, HandType.straight) cards = [ Card(1, Suit.hearts), Card(2, Suit.clubs), Card(3, Suit.clubs), Card(4, Suit.clubs), Card(5, Suit.clubs) ] self.assertEqual(Hand(cards).type, HandType.straight) cards = [ Card(1, Suit.hearts), Card(10, Suit.clubs), Card(11, Suit.clubs), Card(12, Suit.clubs), Card(13, Suit.clubs) ] self.assertEqual(Hand(cards).type, HandType.straight)
def test_card_str(self): self.assertEqual(str(Card(1, Suit.clubs)), "AC") self.assertEqual(str(Card(2, Suit.diamonds)), "2D") self.assertEqual(str(Card(11, Suit.hearts)), "JH")
def test_expected_pull(self): hand = [Card(3, Suit.clubs), Card(3, Suit.spades), Card(10, Suit.clubs)] self.assertEqual(Statistics.shouldRide(hand), False)