diff --git a/probability_playground.html b/probability_playground.html
new file mode 100644
index 000000000..666000b0f
--- /dev/null
+++ b/probability_playground.html
@@ -0,0 +1,341 @@
+
+
+
+ Loading Python Engine (Pyodide)...
+
+
+
+
+
+
+
+
+
Python Algorithm
+
Modify the Python function below. It must accept the 4 arguments and return a DICT.
+
+
+
+
+
+
+
diff --git a/src/Ankimon/functions/encounter_functions.py b/src/Ankimon/functions/encounter_functions.py
index eb06b2f72..73bd17649 100644
--- a/src/Ankimon/functions/encounter_functions.py
+++ b/src/Ankimon/functions/encounter_functions.py
@@ -52,60 +52,50 @@
mainpokemon_path,
)
-def modify_percentages(total_reviews, daily_average, player_level):
+def modify_percentages(total_reviews, daily_average, trainer_level):
"""
- Modify Pokémon encounter percentages based on total reviews, player level, event modifiers, and main Pokémon level.
+ Modify Pokémon encounter percentages based on total reviews, trainer level, and main Pokémon level.
"""
- # Start with the base percentages
- percentages = {"Baby": 2, "Legendary": 0.5, "Mythical": 0.2, "Normal": 92.3, "Ultra": 5}
-
- # Adjust percentages based on total reviews relative to the daily average
- review_ratio = total_reviews / daily_average if daily_average > 0 else 0
-
- # Adjust for review progress
- if review_ratio < 0.4:
- percentages["Normal"] += percentages.pop("Baby", 0) + percentages.pop("Legendary", 0) + \
- percentages.pop("Mythical", 0) + percentages.pop("Ultra", 0)
- elif review_ratio < 0.6:
- percentages["Baby"] += 2
- percentages["Normal"] -= 2
- elif review_ratio < 0.8:
- percentages["Ultra"] += 3
- percentages["Normal"] -= 3
- else:
- percentages["Legendary"] += 2
- percentages["Ultra"] += 3
- percentages["Normal"] -= 5
-
- # Restrict access to certain tiers based on main Pokémon level
- if main_pokemon.level:
- # Define level thresholds for each tier
- level_thresholds = {
- "Ultra": 30, # Example threshold for Ultra Pokémon
- "Legendary": 50, # Example threshold for Legendary Pokémon
- "Mythical": 75 # Example threshold for Mythical Pokémon
- }
-
- for tier in ["Ultra", "Legendary", "Mythical"]:
- if main_pokemon.level < level_thresholds.get(tier, float("inf")):
- percentages[tier] = 0 # Set percentage to 0 if the level requirement isn't met
-
- # Example modification based on player level
- if player_level:
- adjustment = 5 # Adjustment value for the example
- if player_level > 10:
- for tier in percentages:
- if tier == "Normal":
- percentages[tier] = max(percentages[tier] - adjustment, 0)
- else:
- percentages[tier] = percentages.get(tier, 0) + adjustment
-
- # Normalize percentages to ensure they sum to 100
- total = sum(percentages.values())
- for tier in percentages:
- percentages[tier] = (percentages[tier] / total) * 100 if total > 0 else 0
- # this function gets called maybe 10 times per battle round, which is concerning.
- # it could be rewritten to run ONLY when the change in review ratio is detected.
+
+ percentages = {
+ "Baby": 2,
+ "Legendary": 0.5,
+ "Mythical": 0.2,
+ "Normal": 95.3,
+ "Ultra": 2,
+ }
+
+ level_thresholds = {"Ultra": 30, "Legendary": 50, "Mythical": 75}
+ for tier in level_thresholds:
+ # let high level players have high tiers even if their main pokemon level is low
+ scale = 1 - min(trainer_level * (1/12), 1)
+ threshold = level_thresholds[tier] * scale
+
+ if main_pokemon.level < threshold:
+ percentages["Normal"] += percentages[tier]
+ percentages[tier] = 0
+
+ trainer_level_bonus = min(trainer_level * 0.04, 1)
+ main_pokemon_level_bonus = min(main_pokemon.level * 0.005, 0.8)
+ review_bonus = min((total_reviews / max(daily_average, 30)) * 0.25, 1)
+
+ luck_factor = 1.0 + trainer_level_bonus + main_pokemon_level_bonus + review_bonus
+
+ total_boost_amount = 0.0
+
+ for p_type in ["Baby", "Legendary", "Mythical", "Ultra"]:
+ original_value = percentages[p_type]
+ new_value = original_value * luck_factor
+
+ if p_type == "Baby":
+ new_value = min(new_value, 4)
+
+ percentages[p_type] = new_value
+ total_boost_amount += new_value - original_value
+
+ total_boost_amount = min(total_boost_amount, percentages["Normal"])
+ percentages["Normal"] -= total_boost_amount
+
return percentages
def get_pokemon_id_by_tier(tier):