Exemplo n.º 1
0
    def bfs(self, hand):
        """
        Thy
        Generates a priority queue based on 4-card hand scores with different permutations of 2 discarded cards
        :param hand: 6-card hand
        :return: a priority queue of 4-card hand based on their scores
        """
        priorityq = []
        possible_cut_cards = [(1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1),
                              (7, 1), (8, 1), (9, 1), (10, 1), (11, 1),
                              (12, 1), (13, 1)]
        for i in range(len(hand)):

            first_removed = hand[i]
            for j in range(i + 1, len(hand)):
                copyhand = deepcopy(hand)
                second_removed = hand[j]
                copyhand.remove(first_removed)
                copyhand.remove(second_removed)

                for cut_card in possible_cut_cards:
                    if not i == j:
                        points = scorer.score_hand(copyhand, cut_card)
                        heapq.heappush(priorityq, (-points, i, j))

        return priorityq
Exemplo n.º 2
0
 def score_hand(self, hand4cards, cutcard, is_a, is_crib=False):
     """
     scores points from a given hand
     :param hand4cards: the hand's cards
     :param cutcard: the cut card
     :return:
     """
     self.score_points(score_hand(hand4cards, cutcard, is_crib),
                       "Their cards", is_a)
Exemplo n.º 3
0
 def test_is_it_working(self):
     hand = [(4, 1), (5, 2), (7, 3), (11, 3)]
     cutcard = (5, 1)
     self.assertEqual(6, score_hand(hand, cutcard, False))
Exemplo n.º 4
0
 def test_it_broke(self):
     hand = [(4, 1), (5, 2), (7, 3), (11, 3)]
     cutcard = (11, 2)
     self.assertEqual(6, score_hand(hand, cutcard, False))
Exemplo n.º 5
0
 def test_best_hand(self):
     hand = [(11, 1), (5, 2), (5, 3), (5, 0)]
     cutcard = (5, 1)
     self.assertEqual(29, score_hand(hand, cutcard, False))
Exemplo n.º 6
0
 def test_no_points(self):
     hand = [(4, 0), (3, 1), (7, 1), (12, 2)]
     cutcard = (9, 1)
     self.assertEqual(0, score_hand(hand, cutcard, False))