From b51dcfbda21d69898009c24a983f44e7329897aa Mon Sep 17 00:00:00 2001 From: spinerak Date: Sat, 1 Jun 2024 02:02:55 +0200 Subject: [PATCH] Changed logic, tweaked a bit too --- worlds/yachtdice/Options.py | 10 +++++----- worlds/yachtdice/Rules.py | 19 ++++++++++--------- worlds/yachtdice/__init__.py | 8 ++++---- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/worlds/yachtdice/Options.py b/worlds/yachtdice/Options.py index 2b7b1b3481..8d76ba4a74 100644 --- a/worlds/yachtdice/Options.py +++ b/worlds/yachtdice/Options.py @@ -182,14 +182,14 @@ class minimizeExtraItems(Choice): class addExtraPoints(Choice): """ Yacht Dice typically has space for extra items. - If there is space, would you like extra points shuffled in the item pool? + If there is space, would you like bonus points shuffled in the item pool? They make the game a little bit easier, as they are not considered in the logic. all_of_it: fill all locations with extra points - sure: put some extra points in - never: don't put any extra points + sure: put some bonus points in + never: don't put any bonus points """ - display_name = "Extra points in the pool" + display_name = "Extra bonus in the pool" option_all_of_it = 1 option_sure = 2 option_never = 3 @@ -251,6 +251,6 @@ class YachtDiceOptions(PerGameCommonOptions): points_size: pointsSize minimize_extra_items: minimizeExtraItems - add_extra_points: addExtraPoints + add_bonus_points: addExtraPoints add_story_chapters: addStoryChapters which_story: whichStory \ No newline at end of file diff --git a/worlds/yachtdice/Rules.py b/worlds/yachtdice/Rules.py index 75d7611283..896c260a8d 100644 --- a/worlds/yachtdice/Rules.py +++ b/worlds/yachtdice/Rules.py @@ -2,7 +2,6 @@ from ..generic.Rules import set_rule from BaseClasses import MultiWorld from .YachtWeights import yacht_weights import math -from collections import defaultdict category_mappings = { "Category Ones": "Ones", @@ -128,14 +127,16 @@ def diceSimulationStrings(categories, nbDice, nbRolls, fixed_mult, step_mult, di #sort categories because for the step multiplier, you will want low-scorig categories first categories.sort(key=lambda category: category.meanScore(nbDice, nbRolls)) - - + #function to add two discrete distribution. def add_distributions(dist1, dist2): - combined_dist = defaultdict(float) + combined_dist = {} for val1, prob1 in dist1.items(): for val2, prob2 in dist2.items(): - combined_dist[int(val1 + val2)] += prob1 * prob2 - return dict(combined_dist) + if int(val1 + val2) in combined_dist.keys(): + combined_dist[int(val1 + val2)] += prob1 * prob2 + else: + combined_dist[int(val1 + val2)] = prob1 * prob2 + return combined_dist #function to take the maximum of 'times' i.i.d. dist1. def max_dist(dist1, mults): @@ -145,7 +146,7 @@ def diceSimulationStrings(categories, nbDice, nbRolls, fixed_mult, step_mult, di new_dist = {} for val1, prob1 in c.items(): for val2, prob2 in dist1.items(): - new_val = max(val1, val2 * mult) + new_val = int(max(val1, val2 * mult)) new_prob = prob1 * prob2 # Update the probability for the new value @@ -172,8 +173,8 @@ def diceSimulationStrings(categories, nbDice, nbRolls, fixed_mult, step_mult, di return prev_val if prev_val is not None else sorted_values[0] - percReturn = [0, 0.4, 0.4, 0.45, 0.45, 0.45][diff] - diffDivide = [0, 9, 8, 5, 4, 3][diff] + percReturn = [0, 0.30, 0.45, 0.53, 0.7, 0.9][diff] + diffDivide = [0, 9, 8, 4, 2, 1][diff] #calculate total distribution total_dist = {0: 1} diff --git a/worlds/yachtdice/__init__.py b/worlds/yachtdice/__init__.py index 0a69c2703b..e6e382ddbd 100644 --- a/worlds/yachtdice/__init__.py +++ b/worlds/yachtdice/__init__.py @@ -238,7 +238,7 @@ class YachtDiceWorld(World): # making sure not to exceed the number of locations. #first, we flood the entire pool with extra points (useful), if that setting is chosen. - if self.options.add_extra_points.value == 1: #all of the extra points + if self.options.add_bonus_points.value == 1: #all of the extra points already_items = len(self.itempool) + self.extra_plando_items + 1 self.itempool += ["Bonus Point"] * min(self.number_of_locations - already_items, 100) @@ -250,7 +250,7 @@ class YachtDiceWorld(World): self.itempool += ["Story Chapter"] * number_of_items #add some extra points (useful) - if self.options.add_extra_points.value == 2: #add extra points if wanted + if self.options.add_bonus_points.value == 2: #add extra points if wanted already_items = len(self.itempool) + self.extra_plando_items + 1 self.itempool += ["Bonus Point"] * min(self.number_of_locations - already_items, 10) @@ -261,7 +261,7 @@ class YachtDiceWorld(World): self.itempool += ["Story Chapter"] * 10 #add some extra points if there is still room - if self.options.add_extra_points.value == 2: + if self.options.add_bonus_points.value == 2: already_items = len(self.itempool) + self.extra_plando_items + 1 self.itempool += ["Bonus Point"] * min(self.number_of_locations - already_items, 10) @@ -374,7 +374,7 @@ class YachtDiceWorld(World): "weight_of_points", "points_size", "minimize_extra_items", - "add_extra_points", + "add_bonus_points", "add_story_chapters", "which_story" )