From 7a9b3e2d8b412446fcb408b1ef694c75b65b83f2 Mon Sep 17 00:00:00 2001 From: spinerak Date: Tue, 11 Jun 2024 19:33:36 +0200 Subject: [PATCH] .append instead of += for single items, percentile function changed Also an extra comment for location ids. --- worlds/yachtdice/Locations.py | 2 +- worlds/yachtdice/Rules.py | 8 +++----- worlds/yachtdice/__init__.py | 30 +++++++++++------------------- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/worlds/yachtdice/Locations.py b/worlds/yachtdice/Locations.py index 659d66430b..147e0d50a2 100644 --- a/worlds/yachtdice/Locations.py +++ b/worlds/yachtdice/Locations.py @@ -18,7 +18,7 @@ class YachtDiceLocation(Location): all_locations = {} -starting_index = 16871244500 # 500 more than the starting index for items +starting_index = 16871244500 # 500 more than the starting index for items (not necessary, but this is what it is now) diff --git a/worlds/yachtdice/Rules.py b/worlds/yachtdice/Rules.py index 055b638f48..00393a5e12 100644 --- a/worlds/yachtdice/Rules.py +++ b/worlds/yachtdice/Rules.py @@ -173,16 +173,14 @@ def dice_simulation_strings(categories, num_dice, num_rolls, fixed_mult, step_mu def percentile_distribution(dist, percentile): sorted_values = sorted(dist.keys()) cumulative_prob = 0 - prev_val = None for val in sorted_values: - prev_val = val cumulative_prob += dist[val] if cumulative_prob >= percentile: - return prev_val # Return the value before reaching the desired percentile + return val - # Return the first value if percentile is lower than all probabilities - return prev_val if prev_val is not None else sorted_values[0] + # Return the last value if percentile is higher than all probabilities + return sorted_values[-1] # parameters for logic. # perc_return is, per difficulty, the percentages of total score it returns (it averages out the values) diff --git a/worlds/yachtdice/__init__.py b/worlds/yachtdice/__init__.py index 5a71b938a9..13d4f9da3f 100644 --- a/worlds/yachtdice/__init__.py +++ b/worlds/yachtdice/__init__.py @@ -107,30 +107,30 @@ class YachtDiceWorld(World): possible_categories = [] for index, cats in enumerate(all_categories): - possible_categories += [cats[categorylist[index]]] + possible_categories.append(cats[categorylist[index]]) # Add Choice and Inverse choice (or their alts) to the precollected list. if index == 0 or index == 1: - self.precollected += [cats[categorylist[index]]] + self.precollected.append(cats[categorylist[index]]) else: - self.itempool += [cats[categorylist[index]]] + self.itempool.append(cats[categorylist[index]]) # Also start with one Roll and one Dice - self.precollected += ["Roll"] - self.precollected += ["Dice"] + self.precollected.append("Roll") + self.precollected.append("Dice") # if one fragment per dice, just add "Dice" objects if frags_per_dice == 1: self.itempool += ["Dice"] * (num_of_dice - 1) # minus one because one is in start inventory else: - self.itempool += ["Dice"] # always add a full dice to make generation easier (will be early) + self.itempool.append("Dice") # always add a full dice to make generation easier (will be early) self.itempool += ["Dice Fragment"] * (frags_per_dice * (num_of_dice - 2)) # if one fragment per roll, just add "Roll" objects if frags_per_roll == 1: self.itempool += ["Roll"] * (num_of_rolls - 1) # minus one because one is in start inventory else: - self.itempool += ["Roll"] # always add a full roll to make generation easier (will be early) + self.itempool.append()"Roll") # always add a full roll to make generation easier (will be early) self.itempool += ["Roll Fragment"] * (frags_per_roll * (num_of_rolls - 2)) already_items = len(self.itempool) @@ -211,16 +211,10 @@ class YachtDiceWorld(World): item_to_add = "" if which_item_to_add == 0: weights[0] /= 1 + frags_per_dice - if frags_per_dice == 1: - return "Dice" - else: - return "Dice Fragment" + return "Dice" if frags_per_dice == 1 else "Dice Fragment" elif which_item_to_add == 1: weights[1] /= 1 + frags_per_roll - if frags_per_roll == 1: - return "Roll" - else: - return "Roll Fragment" + return "Roll" if frags_per_roll == 1 else "Roll Fragment" elif which_item_to_add == 2: weights[2] /= 1.05 multipliers_added += 1 @@ -264,7 +258,7 @@ class YachtDiceWorld(World): # adding 17 items as a start seems like the smartest way to get close to 1000 points for _ in range(17): - self.itempool += [get_item_to_add()] + self.itempool.append(get_item_to_add()) score_in_logic = dice_simulation(self.itempool + self.precollected, "state_is_a_list", self.options) @@ -279,7 +273,7 @@ class YachtDiceWorld(World): # Keep adding items until a score of 1000 is in logic while score_in_logic < 1000: item_to_add = get_item_to_add() - self.itempool += [item_to_add] + self.itempool.append(item_to_add) if item_to_add == "1 Point": score_in_logic += 1 elif item_to_add == "10 Points": @@ -381,8 +375,6 @@ class YachtDiceWorld(World): if loc_data.region == board.name ] - # which index of all locations should have the Victory item. - # Add the victory item to the correct location. # The website declares that the game is complete when the victory item is obtained. board.locations[goal_index].place_locked_item(self.create_item("Victory"))