diff --git a/worlds/yachtdice/Rules.py b/worlds/yachtdice/Rules.py index 76317fcbe6..1eb7487254 100644 --- a/worlds/yachtdice/Rules.py +++ b/worlds/yachtdice/Rules.py @@ -58,10 +58,6 @@ class Category: def __init__(self, name, quantity=1): self.name = name self.quantity = quantity # how many times you have the category - - def __hash__(self): - return hash((self.name, self.quantity)) - # return mean score of a category def mean_score(self, num_dice, num_rolls): @@ -104,17 +100,17 @@ def extract_progression(state, player, options): number_of_fixed_mults = state.count("Fixed Score Multiplier", player) number_of_step_mults = state.count("Step Score Multiplier", player) - categories = tuple( + categories = [ Category(category_value, state.count(category_name, player)) for category_name, category_value in category_mappings.items() if state.count(category_name, player) # want all categories that have count >= 1 - ) + ] extra_points_in_logic = state.count("1 Point", player) extra_points_in_logic += state.count("10 Points", player) * 10 extra_points_in_logic += state.count("100 Points", player) * 100 - return (categories, number_of_dice, number_of_rerolls, number_of_fixed_mults * 0.1, number_of_step_mults * 0.01, extra_points_in_logic) + return categories, number_of_dice, number_of_rerolls, number_of_fixed_mults * 0.1, number_of_step_mults * 0.01, extra_points_in_logic, @@ -129,7 +125,7 @@ def dice_simulation_strings(categories, num_dice, num_rolls, fixed_mult, step_mu Function that returns the feasible score in logic based on items obtained. """ tup = ( - categories, + tuple([c.name + str(c.quantity) for c in categories]), num_dice, num_rolls, fixed_mult, @@ -142,7 +138,7 @@ def dice_simulation_strings(categories, num_dice, num_rolls, fixed_mult, step_mu return yachtdice_cache[tup] # sort categories because for the step multiplier, you will want low-scoring categories first - categories = sorted(categories, key=lambda category: category.mean_score(num_dice, num_rolls)) + categories.sort(key=lambda category: category.mean_score(num_dice, num_rolls)) # function to add two discrete distribution. # defaultdict is a dict where you don't need to check if an id is present, you can just use += (lot faster)