def ordered_domain(self, dk, sk): domain_dict = {} for dom_elem in self.states[self.domains][dk]: if dom_elem not in domain_dict: new_obj = self.copy_states(Matchups, dk, sk, dom_elem) counts = constraint.game_counts(new_obj, dk) if counts is not None: if len(counts) == 0: domain_dict[dom_elem] = float("inf") else: l_k = sorted(counts.values())[0] domain_dict[dom_elem] = l_k #order domain elements from lowest to highest, when this gets added #to the states list, it will be read backwards so highest to lowest return sorted(domain_dict.keys(), key= lambda x: domain_dict[x])
def ordered_domain(self, dk, sk): domain_dict = {} for dom_elem in self.states[self.domains][dk]: if dom_elem not in domain_dict: new_obj = self.copy_states(Matchups, dk, sk, dom_elem) counts = constraint.game_counts(new_obj, dk) if counts is not None: if len(counts) == 0: domain_dict[dom_elem] = float("inf") else: l_k = sorted(counts.values())[0] domain_dict[dom_elem] = l_k #order domain elements from lowest to highest, when this gets added #to the states list, it will be read backwards so highest to lowest return sorted(domain_dict.keys(), key=lambda x: domain_dict[x])
def min_key(self): best_count = float("inf") best_game = None best_k = None for k in self.states[self.domains]: l = len(self.states[self.domains][k]) if l > 0: counts = constraint.game_counts(self, k) if counts is not None: l_k = sorted(counts.keys(), key= lambda x: counts[x])[0] if counts[l_k] < best_count: best_count = counts[l_k] best_game = l_k best_k = k if best_k is None: return (None, None) return (best_k, (best_k, best_game))
def min_key(self): best_count = float("inf") best_game = None best_k = None for k in self.states[self.domains]: l = len(self.states[self.domains][k]) if l > 0: counts = constraint.game_counts(self, k) if counts is not None: l_k = sorted(counts.keys(), key=lambda x: counts[x])[0] if counts[l_k] < best_count: best_count = counts[l_k] best_game = l_k best_k = k if best_k is None: return (None, None) return (best_k, (best_k, best_game))