@@ -58,6 +58,10 @@ class Category:
58
58
def __init__ (self , name , quantity = 1 ):
59
59
self .name = name
60
60
self .quantity = quantity # how many times you have the category
61
+
62
+ def __hash__ (self ):
63
+ return hash ((self .name , self .quantity ))
64
+
61
65
62
66
# return mean score of a category
63
67
def mean_score (self , num_dice , num_rolls ):
@@ -100,17 +104,17 @@ def extract_progression(state, player, options):
100
104
number_of_fixed_mults = state .count ("Fixed Score Multiplier" , player )
101
105
number_of_step_mults = state .count ("Step Score Multiplier" , player )
102
106
103
- categories = [
107
+ categories = tuple (
104
108
Category (category_value , state .count (category_name , player ))
105
109
for category_name , category_value in category_mappings .items ()
106
110
if state .count (category_name , player ) # want all categories that have count >= 1
107
- ]
111
+ )
108
112
109
113
extra_points_in_logic = state .count ("1 Point" , player )
110
114
extra_points_in_logic += state .count ("10 Points" , player ) * 10
111
115
extra_points_in_logic += state .count ("100 Points" , player ) * 100
112
116
113
- return categories , number_of_dice , number_of_rerolls , number_of_fixed_mults * 0.1 , number_of_step_mults * 0.01 , extra_points_in_logic ,
117
+ return ( categories , number_of_dice , number_of_rerolls , number_of_fixed_mults * 0.1 , number_of_step_mults * 0.01 , extra_points_in_logic )
114
118
115
119
116
120
@@ -125,7 +129,7 @@ def dice_simulation_strings(categories, num_dice, num_rolls, fixed_mult, step_mu
125
129
Function that returns the feasible score in logic based on items obtained.
126
130
"""
127
131
tup = (
128
- tuple ([ c . name + str ( c . quantity ) for c in categories ]) ,
132
+ categories ,
129
133
num_dice ,
130
134
num_rolls ,
131
135
fixed_mult ,
@@ -138,7 +142,7 @@ def dice_simulation_strings(categories, num_dice, num_rolls, fixed_mult, step_mu
138
142
return yachtdice_cache [tup ]
139
143
140
144
# sort categories because for the step multiplier, you will want low-scoring categories first
141
- categories . sort ( key = lambda category : category .mean_score (num_dice , num_rolls ))
145
+ categories = sorted ( categories , key = lambda category : category .mean_score (num_dice , num_rolls ))
142
146
143
147
# function to add two discrete distribution.
144
148
# defaultdict is a dict where you don't need to check if an id is present, you can just use += (lot faster)
0 commit comments