diff --git a/ba_auto/detector.py b/ba_auto/detector.py index e38db88..17874d8 100644 --- a/ba_auto/detector.py +++ b/ba_auto/detector.py @@ -11,7 +11,37 @@ OCR_SHOT_PATH = os.path.join(config.SCRATCHPAD_DIR, "ocr_live.png") OCR_UPSCALE = 3 SPARKLE_SHOT_PATH = os.path.join(config.SCRATCHPAD_DIR, "cafe_live.png") -SPARKLE_CLICK_OFFSET = (75, 47) +# Ported byte-for-byte from the original scripts/detect_and_click.py without +# recalibration (see plan.md's Phase 6 writeup) -- (75, 47) was never +# actually re-verified against this project's own real gameplay. +# +# Real-usage bug (2026-07-16, reported live with a screenshot): when two +# students stand close together, (75, 47) overshoots past the intended +# target's own head and lands on a DIFFERENT, closer student's body instead +# -- the click doesn't register as a pat there, so find_cafe_sparkle() just +# matches the same still-showing sparkle again next iteration, repeatedly +# clicking nearly the same point for the rest of the room's budget (confirmed +# live: 13 of 16 "pats" in one run clustered within a ~10px box, all +# ineffective). +# +# First recalibration attempt, (0, 0) (raw template-match center, no +# offset), was also wrong -- reported live ("it is clicking the actual +# sparkle instead of the student head"): a coincidental ambient thought- +# bubble animation at the raw-center test position was misread as a hover +# confirmation, when the raw sparkle position is not actually within the +# character's clickable area. +# +# Properly recalibrated live the same day via numbered candidate-point +# overlays (screenshots with several labeled offset options drawn on a real +# live sparkle, user picked the one actually landing on the head each time) +# against two independent real students in different poses (a sitting +# arcade-cabinet pose and a lying-down couch pose) -- both converged on +# roughly the same small offset, confirmed by the user directly on-screen +# rather than inferred from a single ambiguous signal like the (0,0) attempt +# was. (75, 47) was oversized (the close-together overshoot bug) and (0, 0) +# was undersized (clicks the sparkle glyph itself, not the character) -- +# (50, 15) is the empirically-confirmed middle ground. +SPARKLE_CLICK_OFFSET = (51, 15) SPARKLE_THRESHOLD = 0.97 # The cafe camera's zoom level isn't reset before farming, and the sparkle