Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,26 +1,96 @@
|
|
| 1 |
-
|
| 2 |
-
tags:
|
| 3 |
-
- ml-intern
|
| 4 |
-
---
|
| 5 |
|
| 6 |
-
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
- Source code: https://github.com/huggingface/ml-intern
|
| 15 |
|
| 16 |
-
##
|
| 17 |
|
| 18 |
-
```
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
```
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ClashCR
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
Real-time Clash Royale opponent card tracker for emulator gameplay (MuMu Player, BlueStacks).
|
| 4 |
|
| 5 |
+
## Key Principle
|
| 6 |
+
**Prefer "no detection / unknown" over a wrong card.** The tracker is only useful if it stops hallucinating.
|
| 7 |
|
| 8 |
+
## Why the Old Approach Failed
|
| 9 |
+
The previous whole-frame card classifier was the wrong visual task. In normal live gameplay, opponent card art and names are **never visible**. The only visible signals are:
|
| 10 |
+
- Unit spawns on the arena
|
| 11 |
+
- Spell/effect animations
|
| 12 |
+
- Building placements
|
| 13 |
|
| 14 |
+
This rewrite detects **card-play events from spawn/effect evidence**, not by classifying random battlefield frames.
|
|
|
|
| 15 |
|
| 16 |
+
## Architecture
|
| 17 |
|
| 18 |
+
```
|
| 19 |
+
Emulator Capture (Win32 API / mss)
|
| 20 |
+
|
|
| 21 |
+
v
|
| 22 |
+
Battle Gater (detect battle vs lobby, compute ROIs)
|
| 23 |
+
|
|
| 24 |
+
v
|
| 25 |
+
Event Detector (temporal differencing, suppress persistent motion)
|
| 26 |
+
|
|
| 27 |
+
v
|
| 28 |
+
Evidence Model (YOLO unit detector + heuristic spell detectors)
|
| 29 |
+
|
|
| 30 |
+
v
|
| 31 |
+
Card Resolver (unit->card mapping, multi-unit rules, ambiguity->UNKNOWN)
|
| 32 |
+
|
|
| 33 |
+
v
|
| 34 |
+
Elixir Tracker + Deck Tracker
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
## Setup
|
| 38 |
+
|
| 39 |
+
```bash
|
| 40 |
+
pip install -e .
|
| 41 |
+
clashcr sync-cards --config config.yaml
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
If you have an Official Clash Royale API token, add it to `config.yaml` under `clash_royale_api_token`.
|
| 45 |
+
|
| 46 |
+
## CLI Commands
|
| 47 |
+
|
| 48 |
+
```bash
|
| 49 |
+
# Sync card registry from APIs
|
| 50 |
+
clashcr sync-cards --config config.yaml
|
| 51 |
+
|
| 52 |
+
# Record battle footage
|
| 53 |
+
clashcr record-battle --config config.yaml --output data/live-recordings/session-001 --seconds 180 --fps 8
|
| 54 |
|
| 55 |
+
# Label a recording (edit labels.csv manually)
|
| 56 |
+
clashcr label-recording --recording data/live-recordings/session-001
|
| 57 |
+
|
| 58 |
+
# Train event detection model (placeholder)
|
| 59 |
+
clashcr train-event-model --config config.yaml --data data/live-recordings
|
| 60 |
+
|
| 61 |
+
# Evaluate predictions vs labels
|
| 62 |
+
clashcr evaluate-recording --config config.yaml --recording data/live-recordings/session-heldout --labels data/live-recordings/session-heldout/labels.csv
|
| 63 |
+
|
| 64 |
+
# Live tracking run
|
| 65 |
+
clashcr run --config config.yaml --raw --debug-frame debug-frame.jpg --debug-dir debug-events
|
| 66 |
```
|
| 67 |
|
| 68 |
+
## Project Structure
|
| 69 |
+
|
| 70 |
+
```
|
| 71 |
+
clashcr/
|
| 72 |
+
core/
|
| 73 |
+
capture.py # Emulator window capture
|
| 74 |
+
battle_gating.py # Battle detection and ROI separation
|
| 75 |
+
event_detector.py # Temporal event detection
|
| 76 |
+
recorder.py # Evidence recording and labeling
|
| 77 |
+
evaluator.py # Offline metrics evaluation
|
| 78 |
+
models/
|
| 79 |
+
evidence_model.py # YOLO + spell heuristics
|
| 80 |
+
card_resolver.py # Unit->card mapping with ambiguity handling
|
| 81 |
+
game/
|
| 82 |
+
elixir_tracker.py # Wall-clock elixir estimation
|
| 83 |
+
deck_tracker.py # Deck/cycle inference
|
| 84 |
+
utils/
|
| 85 |
+
card_registry.py # Sync card list from RoyaleAPI + Official API
|
| 86 |
+
cli.py # Entry point
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
## Verification
|
| 90 |
+
See VERIFICATION_PLAN.md for the full validation protocol. No accuracy claims should be made without labeled recordings.
|
| 91 |
+
|
| 92 |
+
## Research
|
| 93 |
+
See RESEARCH_SUMMARY.md for evaluated projects, datasets, and APIs.
|
| 94 |
+
|
| 95 |
+
## Rewrite Plan
|
| 96 |
+
See REWRITE_PLAN.md for the detailed technical migration guide.
|