Files
DirtyLeague_Bot/test_vector_vision.py

61 lines
1.8 KiB
Python

"""
Validation test for Vector Vision & YOLO State Detection.
"""
import os
import json
import cv2
from bot_core import DirtyLeagueBot
def main():
with open("config.json", "r", encoding="utf-8") as f:
cfg = json.load(f)
bot = DirtyLeagueBot(cfg)
test_cases = {
"dl_screen_20260909_092820_419.png": "TOWER_LOBBY",
"dl_screen_20260910_233743_310.png": "IN_GAME",
"dl_screen_defeat_screen_4k.png": "DEFEAT_SCREEN",
"dl_screen_chest_collect_4k.png": "CHEST_OPEN_SCREEN",
"dl_screen_crown_chest_open_4k.png": "CHEST_OPEN_SCREEN",
"dl_screen_leave_dialog_4k.png": "IN_GAME",
"dl_screen_no_free_slots_4k.png": "NO_FREE_SLOTS_SCREEN",
"dl_screen_victory_screen_4k.png": "VICTORY_SCREEN",
}
print("\n" + "=" * 80)
print(" VECTOR VISION & YOLO STATE DETECTION TEST SUITE")
print("=" * 80)
passed = 0
total = len(test_cases)
for fname, expected in test_cases.items():
img_path = os.path.join("dataset", "raw", fname)
if not os.path.exists(img_path):
print(f"[-] Missing: {fname}")
continue
frame = cv2.imread(img_path)
dets = bot.detector.detect_dict(frame)
state = bot.detect_state(frame, dets)
match = state.value == expected
if match:
passed += 1
status_tag = "[PASS]"
else:
status_tag = "[FAIL]"
detected_classes = list(dets.keys())
print(f"{status_tag} {fname:<36} -> {state.value:<22} (Expected: {expected})")
print(f" YOLO Detections: {detected_classes}")
print("=" * 80)
print(f"Results: {passed}/{total} tests passed ({passed/total*100:.1f}%)")
print("=" * 80)
if __name__ == "__main__":
main()