fix: stochastic failure in test_autonomous_goals.py
This commit is contained in:
@@ -30,15 +30,15 @@ def test_autonomous_goal_weighting():
|
||||
available_goals = ["goal_A", "goal_B", "goal_C"]
|
||||
|
||||
# Simulate that goal_B has been incredibly successful, goal_A moderately, goal_C not at all.
|
||||
success_rates = {"goal_A": 2, "goal_B": 100, "goal_C": 0}
|
||||
success_rates = {"goal_A": 50, "goal_B": 500, "goal_C": 0}
|
||||
|
||||
# If weighting works, running this many times should result in goal_B being chosen overwhelmingly
|
||||
choices = {"goal_A": 0, "goal_B": 0, "goal_C": 0}
|
||||
for _ in range(100):
|
||||
for _ in range(1000):
|
||||
# We pass success_rates to get_current_goal
|
||||
choice = brain.get_current_goal(dopamine, available_goals, success_rates=success_rates)
|
||||
choices[choice] += 1
|
||||
|
||||
assert choices["goal_B"] > 80, "Goal B should be chosen heavily due to high success rate weighting."
|
||||
assert choices["goal_A"] < 20, "Goal A should be chosen rarely."
|
||||
assert choices["goal_A"] >= choices["goal_C"], "Goal A should be chosen at least as often as C."
|
||||
assert choices["goal_B"] > 800, f"Goal B should be chosen heavily: {choices['goal_B']}"
|
||||
assert choices["goal_A"] > 50, f"Goal A should be chosen sometimes: {choices['goal_A']}"
|
||||
assert choices["goal_C"] < 50, f"Goal C should be chosen rarely: {choices['goal_C']}"
|
||||
|
||||
Reference in New Issue
Block a user