From f1d25fd1c6a21980a63bdc97404368ff0925854b Mon Sep 17 00:00:00 2001 From: Someon1e <142684596+Someon1e@users.noreply.github.com> Date: Tue, 13 Jan 2026 19:23:21 +0000 Subject: [PATCH 1/8] feat: New encounter tier algorithm --- src/Ankimon/functions/encounter_functions.py | 91 +++++++++----------- 1 file changed, 39 insertions(+), 52 deletions(-) diff --git a/src/Ankimon/functions/encounter_functions.py b/src/Ankimon/functions/encounter_functions.py index eb06b2f72..df79879df 100644 --- a/src/Ankimon/functions/encounter_functions.py +++ b/src/Ankimon/functions/encounter_functions.py @@ -52,60 +52,47 @@ 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": 92.3, + "Ultra": 5, + } + + 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 * 0.1, 1) + theshold = level_thresholds[tier] * scale + + if main_pokemon.level < theshold: + 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.002, 1) + review_bonus = min((total_reviews / daily_average) * 0.2, 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 + + 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): From 0c662bb5fd92af2320e454ff1b42f5a9de8e4d3a Mon Sep 17 00:00:00 2001 From: Someon1e <142684596+Someon1e@users.noreply.github.com> Date: Tue, 13 Jan 2026 22:17:58 +0000 Subject: [PATCH 2/8] feat: Refine encounter constants --- src/Ankimon/functions/encounter_functions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Ankimon/functions/encounter_functions.py b/src/Ankimon/functions/encounter_functions.py index df79879df..da7d96b25 100644 --- a/src/Ankimon/functions/encounter_functions.py +++ b/src/Ankimon/functions/encounter_functions.py @@ -58,17 +58,17 @@ def modify_percentages(total_reviews, daily_average, trainer_level): """ percentages = { - "Baby": 2, + "Baby": 3, "Legendary": 0.5, "Mythical": 0.2, "Normal": 92.3, - "Ultra": 5, + "Ultra": 4, } 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 * 0.1, 1) + scale = 1 - min(trainer_level * (1/12), 1) theshold = level_thresholds[tier] * scale if main_pokemon.level < theshold: @@ -76,8 +76,8 @@ def modify_percentages(total_reviews, daily_average, trainer_level): percentages[tier] = 0 trainer_level_bonus = min(trainer_level * 0.04, 1) - main_pokemon_level_bonus = min(main_pokemon.level * 0.002, 1) - review_bonus = min((total_reviews / daily_average) * 0.2, 1) + main_pokemon_level_bonus = min(main_pokemon.level * 0.003, 1) + review_bonus = min((total_reviews / daily_average) * 0.25, 1) luck_factor = 1.0 + trainer_level_bonus + main_pokemon_level_bonus + review_bonus From ec441fad95e870c10b0b80a505d18354673451a4 Mon Sep 17 00:00:00 2001 From: h0tp-ftw Date: Sun, 18 Jan 2026 10:34:18 -0700 Subject: [PATCH 3/8] [!] temp: probability visualizer --- probability_playground.html | 474 ++++++++++++++++++++++++++++++++++++ 1 file changed, 474 insertions(+) create mode 100644 probability_playground.html diff --git a/probability_playground.html b/probability_playground.html new file mode 100644 index 000000000..cf2fda564 --- /dev/null +++ b/probability_playground.html @@ -0,0 +1,474 @@ + + + + + + Ankimon Encounter Probability Playground + + + + + + +
+
+ +
+ +
+

Algorithm Output Logic (JavaScript)

+

+ Edit the function body below to test new scaling logic. Must return an + object with tier keys. +

+ +
+
+ + + + From 0e79d5b1e42a90879347289e795ee79cfcc753fb Mon Sep 17 00:00:00 2001 From: h0tp-ftw Date: Sun, 18 Jan 2026 10:39:12 -0700 Subject: [PATCH 4/8] [!] temp: pyodide to allow python algo testing --- probability_playground.html | 768 +++++++++++++++--------------------- 1 file changed, 316 insertions(+), 452 deletions(-) diff --git a/probability_playground.html b/probability_playground.html index cf2fda564..5822e430e 100644 --- a/probability_playground.html +++ b/probability_playground.html @@ -1,474 +1,338 @@ - + - - - - Ankimon Encounter Probability Playground + + + + Ankimon Python Playground + + - - - - + From 44c75291cd4a8c2c0201dad9c8e183e5e831d5dc Mon Sep 17 00:00:00 2001 From: Someon1e <142684596+Someon1e@users.noreply.github.com> Date: Sun, 18 Jan 2026 17:58:10 +0000 Subject: [PATCH 5/8] feat: Refine encounter constants (again) --- probability_playground.html | 10 +++++----- src/Ankimon/functions/encounter_functions.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/probability_playground.html b/probability_playground.html index 5822e430e..074353d7b 100644 --- a/probability_playground.html +++ b/probability_playground.html @@ -141,11 +141,11 @@

Python Algorithm

def calculate_probabilities(total_reviews, daily_average, trainer_level, main_pokemon_level): percentages = { - "Baby": 3.0, + "Baby": 2, "Legendary": 0.5, "Mythical": 0.2, - "Normal": 92.3, - "Ultra": 4.0, + "Normal": 95.3, + "Ultra": 2, } # 1. Level Access Thresholds @@ -164,8 +164,8 @@

Python Algorithm

# Trainer Level Bonus (Max +100% at level 25) trainer_level_bonus = min(trainer_level * 0.04, 1.0) - # Main Pkmn Bonus (Max +30% at level 100) - main_pokemon_level_bonus = min(main_pokemon_level * 0.003, 1.0) + # Main Pkmn Bonus (Max +50% at level 100) + main_pokemon_level_bonus = min(main_pokemon_level * 0.005, 0.8) # Review Bonus (Max +100% at 4x daily average) ratio = total_reviews / daily_average if daily_average > 0 else 0 diff --git a/src/Ankimon/functions/encounter_functions.py b/src/Ankimon/functions/encounter_functions.py index da7d96b25..f413434f2 100644 --- a/src/Ankimon/functions/encounter_functions.py +++ b/src/Ankimon/functions/encounter_functions.py @@ -58,11 +58,11 @@ def modify_percentages(total_reviews, daily_average, trainer_level): """ percentages = { - "Baby": 3, + "Baby": 2, "Legendary": 0.5, "Mythical": 0.2, - "Normal": 92.3, - "Ultra": 4, + "Normal": 95.3, + "Ultra": 2, } level_thresholds = {"Ultra": 30, "Legendary": 50, "Mythical": 75} @@ -76,7 +76,7 @@ def modify_percentages(total_reviews, daily_average, trainer_level): percentages[tier] = 0 trainer_level_bonus = min(trainer_level * 0.04, 1) - main_pokemon_level_bonus = min(main_pokemon.level * 0.003, 1) + main_pokemon_level_bonus = min(main_pokemon.level * 0.005, 0.8) review_bonus = min((total_reviews / daily_average) * 0.25, 1) luck_factor = 1.0 + trainer_level_bonus + main_pokemon_level_bonus + review_bonus From 6147a6c74e35849df9f3ba3d01838b5467a5a7d3 Mon Sep 17 00:00:00 2001 From: Someon1e <142684596+Someon1e@users.noreply.github.com> Date: Sun, 18 Jan 2026 18:04:40 +0000 Subject: [PATCH 6/8] feat: Limit `Baby` frequency --- probability_playground.html | 4 ++++ src/Ankimon/functions/encounter_functions.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/probability_playground.html b/probability_playground.html index 074353d7b..77f8997ff 100644 --- a/probability_playground.html +++ b/probability_playground.html @@ -180,6 +180,10 @@

Python Algorithm

if percentages[p_type] > 0: original = percentages[p_type] new_val = original * luck_factor + + if p_type == "Baby": + new_val = min(new_val, 4) + percentages[p_type] = new_val total_boost += (new_val - original) diff --git a/src/Ankimon/functions/encounter_functions.py b/src/Ankimon/functions/encounter_functions.py index f413434f2..87eadbee2 100644 --- a/src/Ankimon/functions/encounter_functions.py +++ b/src/Ankimon/functions/encounter_functions.py @@ -87,6 +87,9 @@ def modify_percentages(total_reviews, daily_average, trainer_level): 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 From 15e747b65689cb23cdeef222e94244d0df64ab35 Mon Sep 17 00:00:00 2001 From: Someon1e <142684596+Someon1e@users.noreply.github.com> Date: Sun, 18 Jan 2026 18:11:04 +0000 Subject: [PATCH 7/8] feat: Clamp daily average --- probability_playground.html | 5 ++--- src/Ankimon/functions/encounter_functions.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/probability_playground.html b/probability_playground.html index 77f8997ff..666000b0f 100644 --- a/probability_playground.html +++ b/probability_playground.html @@ -105,8 +105,8 @@

Configuration

@@ -139,7 +139,6 @@

Python Algorithm