lucasguo
projects / coc-bot
building

Clash of Clans Attack Bot

A computer-vision bot that farms Clash of Clans loot with no game API: it captures the screen over ADB, reads menus and each base's loot with OpenCV template matching, and decides whether to attack. The secondary goal is to learn computer vision and system design by building in small, testable steps.

Language
Python
Emulator
BlueStacks Air (macOS)
Capture & Input
ADB via adbutils (raw screencap over a persistent connection)
Vision
OpenCV template matching, NumPy
Detection
YOLO26 via Ultralytics, about 18 ms per base

Roadmap

  1. Done: KM 1

    Plumbing

    Capture the BlueStacks Air screen over ADB (~176 ms/frame) and build frame-recording and offline replay tools.

  2. Done: KM 2

    Navigate

    Identify screens by template-matching their buttons, and drive the full attack loop with a state machine that only taps screens it recognizes.

  3. Done: KM 3

    Read Loot

    Read gold, elixir, and dark elixir with per-digit template matching: 96/96 labelled digits correct, and unreadable panels are never guessed.

  4. Done: KM 4

    Deploy

    Attack bases whose loot clears a threshold: drop troops along the deployable perimeter, wait out the battle, and return home.

  5. Done: KM 5

    Building Detection

    Train a YOLO model to find the 8 loot-building classes, bootstrapping labels from 100 reviewed frames: 0.987 recall on frames it had never seen.

  6. In progress: KM 6

    Loot per HourNow

    Measure loot per hour and test each rule change in randomized live runs. An audit capped a trained base-scoring model at 3–8%, so it wasn't worth it.

  7. Up next: FINISH

    Polish

    Test the new loot threshold live, handle the event screens that break the first runs, and clean up the code.

Build log