From 737636b644b0378eb6c3538d9828ca7ce6519c19 Mon Sep 17 00:00:00 2001 From: FiskenPoul <123322006+FiskenPoul@users.noreply.github.com> Date: Sat, 11 Jul 2026 22:39:38 +0200 Subject: [PATCH] Make pickup-drought health check window configurable (pickup_drought_window) Was hardcoded to 10 games; a strict pickit on a fast boss-only rush route can legitimately go 10 games without a keep-worthy drop, making the log warning noisy. Defaults to 10 (unchanged), override per-user via profile.ini. --- config/params.ini | 5 +++++ src/config.py | 1 + src/game_stats.py | 9 +++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/config/params.ini b/config/params.ini index 9941c75..21ea650 100644 --- a/config/params.ini +++ b/config/params.ini @@ -55,6 +55,11 @@ discord_log_errors=1 discord_status_runs=10 ; discord_status_count: legacy fallback, send periodic status every X games (blank/0 disables) discord_status_count=20 +; pickup_drought_window: warn/alert after this many consecutive games with zero +; item pickups. Raise this if you run a strict pickit and 0-pickup streaks are +; expected/normal for you (a fast boss-only rush route with a tight filter can +; easily go 10 games without a keep-worthy drop). +pickup_drought_window=10 ; message_api_type: "" disables messaging, "discord" or "generic_api" message_api_type=discord diff --git a/src/config.py b/src/config.py index 74246b6..e37044a 100644 --- a/src/config.py +++ b/src/config.py @@ -265,6 +265,7 @@ class Config: "info_screenshots": bool(int(self._select_val("general", "info_screenshots"))), "error_screenshots": bool(int(self._select_optional("general", "error_screenshots", "1"))), "disable_run_after_failures": int(self._select_optional("general", "disable_run_after_failures", "5")), + "pickup_drought_window": int(self._select_optional("general", "pickup_drought_window", "10")), "pickit_screenshots": bool(int(self._select_val("general", "pickit_screenshots"))), "d2r_path": _default_iff(self._select_val("general", "d2r_path"), "", r"C:\Program Files (x86)\Diablo II Resurrected"), "restart_d2r_when_stuck": bool(int(self._select_val("general", "restart_d2r_when_stuck"))), diff --git a/src/game_stats.py b/src/game_stats.py index 0e5b048..408325e 100644 --- a/src/game_stats.py +++ b/src/game_stats.py @@ -83,11 +83,11 @@ class GameStats: self._events_filename = f'events_{time.strftime("%Y%m%d_%H%M%S")}.jsonl' self._mini_stats_filename = f'mini_stats_{time.strftime("%Y%m%d_%H%M%S")}.json' self._nopickup_active = False - # Per-game pickup / problem tracking (rolling 10-game health check) + # Per-game pickup / problem tracking (rolling pickup-drought health check) self._current_game_had_pickup = False self._current_game_chickens = 0 self._current_game_merc_deaths = 0 - self._recent_games: deque[dict] = deque(maxlen=10) + self._recent_games: deque[dict] = deque(maxlen=Config().general["pickup_drought_window"]) self._starting_exp = 0 self._current_exp = 0 self._current_lvl = 0 @@ -419,14 +419,15 @@ class GameStats: self._send_status_update() def _check_pickup_health(self): - """Warn when the last 10 games contained zero item pickups. + """Warn when the last N games (config: pickup_drought_window) contained + zero item pickups. Fires a log warning always, and also sends a Discord alert when chickens or merc deaths are present (confirms the bot is in active combat but still collecting nothing — strong signal of a real problem vs. a strict filter). """ window = list(self._recent_games) - if len(window) < 10: + if len(window) < self._recent_games.maxlen: return # not enough data yet games_with_pickup = sum(1 for g in window if g["had_pickup"]) if games_with_pickup > 0: