publish eve_rock_watcher.py

This commit is contained in:
brockdarnold 2026-06-15 05:36:26 +00:00
parent a69e64ff4f
commit d49c570fd1

View file

@ -354,11 +354,13 @@ def main():
poll = max(poll, 8) # full-window OCR is heavy; don't spin
MAX_DROP_PS = 4000 / 60.0 # units/sec ceiling — a faster "drop" than this is a misread
print(f"[rock] started; switch<{switch_secs}s, poll {poll}s (waits for !mining on)")
idle_secs = cp.getint("rock", "idle_secs", fallback=150) if sec else 150
hist = deque() # accepted (t, units), cleaned of OCR outliers
pending = None # a jumped value awaiting a confirming second read
last_status = 0.0
last_alert = 0.0
last_ore = "rock"
last_decrease = 0.0 # last time the rock actually got smaller (= active mining)
while True:
if not w.bot_mining(cp): # only during a mining session
hist.clear(); pending = None
@ -379,6 +381,8 @@ def main():
lt, lu = hist[-1]
dt = max(1.0, now - lt)
if (lu - units) <= MAX_DROP_PS * dt + 400 and units <= lu + 40:
if units < lu - 5:
last_decrease = now # rock is actually shrinking
hist.append((now, units)); pending = None # normal depletion / flat
elif pending is not None and abs(units - pending) <= max(400, units * 0.03):
hist.clear(); hist.append((now, units)); pending = None # new rock, confirmed
@ -395,6 +399,12 @@ def main():
if 0 < r <= MAX_DROP_PS: # ignore impossible rates
rate = r
tleft = units / rate if rate > 0 else None
# if the rock hasn't shrunk in a while you've stopped mining it (done, or warped
# off) — go quiet instead of editing a stale readout / firing switch alerts.
active = (now - last_decrease) <= idle_secs
if not active:
time.sleep(poll)
continue
# live readout (edit-in-place, no spam)
if post_rock and not w.bot_muted(cp) and now - last_status >= status_secs:
if tleft: