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.
This commit is contained in:
FiskenPoul
2026-07-11 22:39:38 +02:00
parent 17bcb95c0a
commit 737636b644
3 changed files with 11 additions and 4 deletions

View File

@@ -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

View File

@@ -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"))),

View File

@@ -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: