def test_assign_hands(self): assignment = distribute_cards(self.card_constraints, self.number_constraints) for key, value in assignment.items(): possibility = self.card_constraints[key] value = set(value) self.assertTrue(value.issubset(possibility))
def test_case_2(self): card_constraints = { 0: {'GK_', 'G8_', 'H9_', 'H10'}, 2: {'GK_', 'G8_', 'EA_', 'EK_'}, 3: {'EA_', 'EK_'} } number_constraints = {0: 2, 2: 2, 3: 2} assignment = distribute_cards(card_constraints, number_constraints) expected = {0: {'H9_', 'H10'}, 2: {'GK_', 'G8_'}, 3: {'EA_', 'EK_'}} self.assertEqual(assignment, expected)
def test_case_3(self): """ Test that it can solve a case with multiple solutions """ card_constraints = { 1: { 'E8_', 'E9_', 'G10', 'G8_', 'G9_', 'GA_', 'GK_', 'H10', 'H7_', 'H8_', 'H9_', 'HA_', 'HK_', 'S8_', 'S9_' }, 2: { 'E8_', 'E9_', 'G10', 'G8_', 'G9_', 'GA_', 'GK_', 'H10', 'H7_', 'H8_', 'H9_', 'HA_', 'HK_', 'S8_', 'S9_' }, 3: {'G10', 'G8_', 'G9_', 'GA_', 'GK_'} } number_constraints = {1: 5, 2: 5, 3: 5} result = distribute_cards(card_constraints, number_constraints) for i in card_constraints.keys(): self.assertTrue(result[i].issubset(card_constraints[i]))
def assign_hands(self): """ Generate a set of plausible hands given the play history.""" result = distribute_cards(self.card_constraints, self.number_constraints) result[self.p_id] = set(self.p_hand) return result
def test_case_1(self): card_constraints = {0: {'EA_', 'SU_'}, 2: {'GK_', 'SU_'}, 3: {'EA_'}} number_constraints = {0: 1, 2: 1, 3: 1} assignment = distribute_cards(card_constraints, number_constraints) expected = {0: {"SU_"}, 2: {"GK_"}, 3: {"EA_"}} self.assertEqual(assignment, expected)