mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-04-10 08:08:15 -07:00
Adjusted max_dist, split dice_simulation function
This commit is contained in:
@@ -154,18 +154,18 @@ def dice_simulation_strings(categories, num_dice, num_rolls, fixed_mult, step_mu
|
||||
def max_dist(dist1, mults):
|
||||
new_dist = {0: 1}
|
||||
for mult in mults:
|
||||
c = new_dist.copy()
|
||||
new_dist = {}
|
||||
for val1, prob1 in c.items():
|
||||
temp_dist = {}
|
||||
for val1, prob1 in new_dist.items():
|
||||
for val2, prob2 in dist1.items():
|
||||
new_val = int(max(val1, val2 * mult))
|
||||
new_prob = prob1 * prob2
|
||||
|
||||
# Update the probability for the new value
|
||||
if new_val in new_dist:
|
||||
new_dist[new_val] += new_prob
|
||||
if new_val in temp_dist:
|
||||
temp_dist[new_val] += new_prob
|
||||
else:
|
||||
new_dist[new_val] = new_prob
|
||||
temp_dist[new_val] = new_prob
|
||||
new_dist = temp_dist
|
||||
|
||||
return new_dist
|
||||
|
||||
@@ -215,20 +215,22 @@ def dice_simulation_strings(categories, num_dice, num_rolls, fixed_mult, step_mu
|
||||
return yachtdice_cache[tup]
|
||||
|
||||
|
||||
|
||||
def dice_simulation(state, player, options):
|
||||
def dice_simulation_fill_pool(state, options):
|
||||
"""
|
||||
Returns the feasible score that one can reach with the current state, options and difficulty.
|
||||
"""
|
||||
# if the player is called "state_is_a_list", we are filling the itempool and want to calculate anyways.
|
||||
if player == "state_is_a_list":
|
||||
categories, num_dice, num_rolls, fixed_mult, step_mult, expoints = extract_progression(state, player, options)
|
||||
return (
|
||||
dice_simulation_strings(
|
||||
categories, num_dice, num_rolls, fixed_mult, step_mult, options.game_difficulty.value
|
||||
)
|
||||
+ expoints
|
||||
categories, num_dice, num_rolls, fixed_mult, step_mult, expoints = extract_progression(state, "state_is_a_list", options)
|
||||
return (
|
||||
dice_simulation_strings(
|
||||
categories, num_dice, num_rolls, fixed_mult, step_mult, options.game_difficulty.value
|
||||
)
|
||||
+ expoints
|
||||
)
|
||||
|
||||
def dice_simulation_state_change(state, player, options):
|
||||
"""
|
||||
Returns the feasible score that one can reach with the current state, options and difficulty.
|
||||
"""
|
||||
|
||||
if state.prog_items[player]["state_is_fresh"] == 0:
|
||||
state.prog_items[player]["state_is_fresh"] = 1
|
||||
@@ -252,7 +254,7 @@ def set_yacht_rules(world: MultiWorld, player: int, options):
|
||||
for location in world.get_locations(player):
|
||||
set_rule(
|
||||
location,
|
||||
lambda state, curscore=location.yacht_dice_score, player=player: dice_simulation(state, player, options)
|
||||
lambda state, curscore=location.yacht_dice_score, player=player: dice_simulation_state_change(state, player, options)
|
||||
>= curscore,
|
||||
)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from worlds.AutoWorld import WebWorld, World
|
||||
from .Items import YachtDiceItem, item_groups, item_table
|
||||
from .Locations import YachtDiceLocation, all_locations, ini_locations
|
||||
from .Options import YachtDiceOptions, yd_option_groups
|
||||
from .Rules import dice_simulation, set_yacht_completion_rules, set_yacht_rules
|
||||
from .Rules import dice_simulation_fill_pool, dice_simulation_state_change, set_yacht_completion_rules, set_yacht_rules
|
||||
|
||||
|
||||
class YachtDiceWeb(WebWorld):
|
||||
@@ -260,14 +260,14 @@ class YachtDiceWorld(World):
|
||||
for _ in range(17):
|
||||
self.itempool.append(get_item_to_add())
|
||||
|
||||
score_in_logic = dice_simulation(self.itempool + self.precollected, "state_is_a_list", self.options)
|
||||
score_in_logic = dice_simulation_fill_pool(self.itempool + self.precollected, self.options)
|
||||
|
||||
# if we overshoot, remove items until you get below 1000, then return the last removed item
|
||||
if score_in_logic > 1000:
|
||||
removed_item = ""
|
||||
while score_in_logic > 1000:
|
||||
removed_item = self.itempool.pop()
|
||||
score_in_logic = dice_simulation(self.itempool + self.precollected, "state_is_a_list", self.options)
|
||||
score_in_logic = dice_simulation_fill_pool(self.itempool + self.precollected, self.options)
|
||||
self.itempool.append(removed_item)
|
||||
else:
|
||||
# Keep adding items until a score of 1000 is in logic
|
||||
@@ -281,7 +281,7 @@ class YachtDiceWorld(World):
|
||||
elif item_to_add == "100 Points":
|
||||
score_in_logic += 100
|
||||
else:
|
||||
score_in_logic = dice_simulation(self.itempool + self.precollected, "state_is_a_list", self.options)
|
||||
score_in_logic = dice_simulation_fill_pool(self.itempool + self.precollected, self.options)
|
||||
|
||||
# count the number of locations in the game.
|
||||
already_items = len(self.itempool) + 1 # +1 because of Victory item
|
||||
|
||||
Reference in New Issue
Block a user