ClashGO

command module
v0.8.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README ΒΆ

ClashGO βš”οΈ

This is ClashGO, a super lightweight Clash of Clans bot written in Go.

I basically vibe-coded this in like 3 days because I wanted a bot that actually worked on my Mac (Apple Silicon). It's built from scratch using Go and OpenCV.

⚠️ WARNING: It's Buggy

Look, I made this fast. It's rough around the edges, probably has bugs, and might crash. Use it at your own risk.

πŸš€ Why it's cool
  • Mac Native: Works great on Apple Silicon.
  • Fast: Uses a persistent ADB connection, so screen captures and taps are instant.
  • Lightweight: Just a single binary, with a recent perf audit cutting battle-state CPU ~10–20% and transient RSS ~10–20 MB. See docs/PERFORMANCE.md for the per-change breakdown and how to verify on your machine.
  • Customizable strategies: Drop a YAML strategy + matching formula.json (per-unit deploy coords) into assets/strategies/ and the bot deploys each unit where you want. See assets/strategies/auto_edrag_rush.yaml + assets/strategies/auto_edrag_rush_formula.json for an end-to-end example (Balloon + EDrag + Rage + Ice).
  • Per-corner formula workflow: target_edge: "Random" (the default in auto_edrag_rush.yaml) picks a random corner per attack. cmd/design_attack -live -corner BR|BL|TR|TL authors the per-corner deploy coords; per-corner overrides in formula.corner_overrides[<CORNER>] are used as-authored (the mirror is only a fallback). See docs/formula-authoring.md for the full walkthrough.
  • Self-healing boot sequence: the bot auto-dismisses the post-boot splash chain ("ВАР!" tap-to-continue β†’ castle logo β†’ news splash) instead of force-restarting in a loop, so unattended runs survive game relaunches.
  • Unattended-run resilience: if the emulator dies mid-session the bot escalates through transport reconnect β†’ adb-server reset β†’ BlueStacks relaunch instead of spinning; a bad frame or missing asset can't crash the process (panic guards + nil-template fallback); and tools/run_bot_keepalive.sh respawns the bot ~10s after any exit so it keeps farming unattended.
  • Text-based observability: ./tools/observe.sh captures the emulator screen, classifies it with the bot's real vision layer, and OCRs the on-screen text β€” a terminal-only "eye view" for debugging without a GUI. See docs/OBSERVABILITY.md.
  • Replayable attacks: make attack-record records a deploy you perform on the emulator; make attack-replay re-fires that JSON on the device with classification + extras. Useful for sharing working attacks without re-engineering.
  • Intuitive 1-Click In-App Updater: New releases ship through GitHub Releases. When an update is detected, ClashGO auto-pops the release window and highlights a persistent status pill in the header. Clicking 1-Click Update & Restart automatically downloads the verified bundle, stops the running bot cleanly, swaps the macOS bundle in place using a detached helper, re-signs ad-hoc, and relaunches seamlessly with rollback protection. "Later" keeps the header pill accessible for whenever you're ready, and updates can also be triggered directly from Settings.
  • Headless CLI (bot_cli): Full bot engine without WebKit/GUI overhead. Ideal for 24/7 background tmux sessions or low-spec machines. Check version with ./build/bin/bot_cli -v and run with -perf for maximum efficiency.
πŸ› οΈ How to use
  1. Emulator: Set your emulator (like BlueStacks) to 860x732 resolution and 160 DPI.
  2. Config: Point config.json to your ADB device.
  3. Run:
    • CLI (Lightweight & Max Performance):
      make build-cli
      ./build/bin/bot_cli -v                             # Print version & commit
      ./build/bin/bot_cli -perf -gold 600000 -elixir 600000
      
      See docs/CLI.md for all options (-perf, -once, -deploy-only, -devices, -strategies).
    • GUI:
      make build-gui && open build/bin/ClashGO.app
      
πŸ’Ύ Resource usage & Performance metrics (estimates)

All numbers below are principled estimates from code analysis (frame sizing, mat pool, template cache, capture-loop cadence), not live measurements. They assume an Apple Silicon Mac, BlueStacks at 860Γ—732 / 160 DPI, and the bot running at the configured capture rate. The recipe in docs/PERFORMANCE.md validates them on your machine.

Frame math (860Γ—732, RGB):

  • Full capture frame: 860 Γ— 732 Γ— 3 β‰ˆ 1.80 MB
  • Half-size frame (Live View JPEG encode): 430 Γ— 366 Γ— 3 β‰ˆ 0.47 MB
Scenario ClashGO RSS ClashGO CPUΒΉ + BlueStacks RSSΒ² Combined RSS (est.)
CLI Headless (Idle / UI only) ~25–40 MB <1% (1 core) ~800 MB–1.2 GB ~0.8–1.2 GB
CLI Headless (Active battle @ 15 FPS, -perf) ~45–70 MB ~8–15% (1 core) ~1.0–1.5 GB ~1.0–1.6 GB
GUI (Idle / UI only) (1 FPS capture) ~60–90 MB ~1–3% (1 core) ~800 MB–1.2 GB ~0.9–1.3 GB
GUI (Active battle @ 15 FPS) ~90–140 MB ~15–25% (1 core) ~1.0–1.5 GB ~1.1–1.7 GB

CLI vs GUI Footprint: The CLI (bot_cli) strips out the embedded Wails / WebKit browser runtime, saving ~35–50 MB RSS and eliminates UI re-render cycles entirely for maximum 24/7 battery and CPU efficiency.

ΒΉ CPU is single-core; the bot is largely single-threaded per capture frame (classify + template match + tap). Higher FPS = proportionally more CPU. At 15 FPS the per-frame vision work (~7–15 ms) consumes ~15–25% of one core. The bot also reports cpu_time_sec β€” absolute CPU time since process start β€” which is the device-independent metric: it means the same on an M1 or an M3 Max, so you can compare efficiency across machines without normalizing by core count. The "% CPU" shown in the UI is derived by multiplying the per-core fraction (cpu_cores) by the host's logical core count; treat that number as host-relative only. Β² BlueStacks footprint is driven by the emulator + Android guest, not the bot. It scales with emulator window size / DPI and the guest's own memory pressure, not with ClashGO's FPS.

Where the bot's RAM goes:

  • Capture + working Mats (mat pool): ~2–4 MB retained (serial capture keeps only 1–2 mats per size alive).
  • ScaledTemplateCache (6 classifier rules Γ— several scales): ~1–3 MB.
  • Live View base64 frame buffer (lastFrame): a few hundred KB.
  • Wails/WebKit GUI harness: the bulk of the idle ~60–90 MB is the embedded browser, not the Go bot logic.

ClashGO itself is tiny; the dominant memory cost when running is almost always BlueStacks, not the bot.

🚒 Releasing a new version

Updates are powered by GitHub Releases β€” no extra infrastructure.

  1. Bump productVersion in wails.json (e.g. 0.3.0-beta).

  2. Commit + push, then tag it:

    git tag v0.3.0-beta && git push origin v0.3.0-beta
    

    Pushing a v* tag runs the Release workflow (.github/workflows/release.yml), which builds the macOS zip, the DMG, and latest.json on a fresh runner and publishes them to a GitHub Release automatically. No manual upload, no secrets β€” the workflow uses GitHub's built-in GITHUB_TOKEN, and the app itself checks the public GitHub API unauthenticated.

  3. Existing users get an auto-popping update window within 6h (or on next launch) offering one-click Update & Restart.

Manual fallback (no CI):

  1. make release VERSION=0.3.0-beta β€” produces the zip, the DMG, and latest.json.
  2. Publish a GitHub release tagged v0.3.0-beta, and attach:
    • ClashGO-v0.3.0-beta-macOS.zip
    • latest.json
🀝 HELP WANTED (Porting to Windows)

Right now, this is heavily tested on macOS. I'd love some help porting/testing this for Windows. If you're a dev and want to help me make this not-just-a-Mac-thing, open a PR or hit me up!

Also, if you find bugs (you will), just open an issue.

πŸ“„ License

MIT. Do whatever you want with it.

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
cmd
attack_record command
cmd/attack_record is a MACRO RECORDER + REPLAYER for ClashGO.
cmd/attack_record is a MACRO RECORDER + REPLAYER for ClashGO.
attack_report command
Command attack_report answers the two questions a finished attack actually raises, from the run's own log:
Command attack_report answers the two questions a finished attack actually raises, from the run's own log:
attack_verify command
Command attack_verify is the 720p review harness: it proves the attack plan is correct BEFORE a battle is spent on it, by rendering exactly what the bot would tap onto a live (or saved) 720p battle screenshot.
Command attack_verify is the 720p review harness: it proves the attack plan is correct BEFORE a battle is spent on it, by rendering exactly what the bot would tap onto a live (or saved) 720p battle screenshot.
capture_template command
cmd/capture_template is a manual template-recapture tool.
cmd/capture_template is a manual template-recapture tool.
classify_probe command
Command classify_probe classifies a screenshot (default: live adb capture) with the repo's own classifier and prints the score for every state rule plus a few key pixel reads, so a stuck bot can be diagnosed from what the vision layer actually sees.
Command classify_probe classifies a screenshot (default: live adb capture) with the repo's own classifier and prints the score for every state rule plus a few key pixel reads, so a stuck bot can be diagnosed from what the vision layer actually sees.
countprobe command
design_attack command
cmd/design_attack is the one-stop tool for authoring + verifying the per-unit `formula.json` consumed by the deploy pipeline.
cmd/design_attack is the one-stop tool for authoring + verifying the per-unit `formula.json` consumed by the deploy pipeline.
pick_army_slots command
pick_coords command
Command pick_coords is the deploy-point picker: it shows the live emulator frame in the Preview tab and lets you click the exact points the bot should use, per side, then writes them into precision_config.json.
Command pick_coords is the deploy-point picker: it shows the live emulator frame in the Preview tab and lets you click the exact points the bot should use, per side, then writes them into precision_config.json.
pickpage command
pickpage writes the wall-flow picking page to a file, with the captured frames inlined as data URIs.
pickpage writes the wall-flow picking page to a file, with the captured frames inlined as data URIs.
ratioprobe command
refmap command
refmap converts rectangles a human dragged on a live frame into the reference coordinates the bot's asset files are written in.
refmap converts rectangles a human dragged on a live frame into the reference coordinates the bot's asset files are written in.
release_manifest command
Command release_manifest emits a `latest.json` file for the just-built release zip.
Command release_manifest emits a `latest.json` file for the just-built release zip.
resprobe command
Command resprobe measures how the CoC HUD scales between two framebuffer geometries.
Command resprobe measures how the CoC HUD scales between two framebuffer geometries.
result_probe command
Command result_probe is a diagnostic harness that runs the bot's own battle-result OCR pipeline against a saved screenshot (defaults to last_battle_result.png in the config dir).
Command result_probe is a diagnostic harness that runs the bot's own battle-result OCR pipeline against a saved screenshot (defaults to last_battle_result.png in the config dir).
screendump command
see command
Command see is the debugging agent's eyes on the emulator.
Command see is the debugging agent's eyes on the emulator.
swipe_probe command
Command swipe_probe is a standalone live-verification harness for the human-gesture input layer (Phase 1 of the autonomous hardening loop): it connects to the emulator like the bot does and exercises the sendevent bezier-swipe primitives against the live device.
Command swipe_probe is a standalone live-verification harness for the human-gesture input layer (Phase 1 of the autonomous hardening loop): it connects to the emulator like the bot does and exercises the sendevent bezier-swipe primitives against the live device.
tapaudit command
tapaudit reviews every touch the bot fired, straight from the NDJSON tap trace (CLASHGO_TAP_TRACE=<path>).
tapaudit reviews every touch the bot fired, straight from the NDJSON tap trace (CLASHGO_TAP_TRACE=<path>).
test_wall_upgrade command
cmd/test_wall_upgrade is a manual verification tool for the wall-upgrade system.
cmd/test_wall_upgrade is a manual verification tool for the wall-upgrade system.
tplprobe command
Command tplprobe locates one stored template on a frame across a scale sweep and prints the ranked result.
Command tplprobe locates one stored template on a frame across a scale sweep and prints the ranked result.
wallserve command
wallserve is the local picking session: a page you drag boxes on, a Save button, and the picks written to a file on this machine instead of sitting in a browser tab.
wallserve is the local picking session: a page you drag boxes on, a Save button, and the picks written to a file on this machine instead of sitting in a browser tab.
wedge_probe command
wmresize command
Command wmresize changes a running device's display geometry.
Command wmresize changes a running device's display geometry.
internal
adb
Package adb β€” bootprobe.go
Package adb β€” bootprobe.go
attacklog
Package attacklog turns a bot run log into a per-unit account of what the deploy phase actually did.
Package attacklog turns a bot run log into a per-unit account of what the deploy phase actually did.
bot
Package bot β€” boot_report.go
Package bot β€” boot_report.go
game
Package game β€” chestdismiss.go
Package game β€” chestdismiss.go
paths
Package paths resolves absolute, writable locations for the bot's runtime files.
Package paths resolves absolute, writable locations for the bot's runtime files.
pickpage
Package pickpage renders the wall-flow picking page: the captured frames with the boxes a human dragged on them.
Package pickpage renders the wall-flow picking page: the captured frames with the boxes a human dragged on them.
updater
Package updater polls GitHub Releases for new ClashGO versions, downloads updates with SHA256 verification, and signals the UI / applies updates on demand.
Package updater polls GitHub Releases for new ClashGO versions, downloads updates with SHA256 verification, and signals the UI / applies updates on demand.
vision
Digit classification against canonical-size templates.
Digit classification against canonical-size templates.
pkg
formula
Package formula defines the per-unit deploy coordinate schema produced by the `design_attack` interactive tool and consumed by the deploy pipeline in `internal/attack`.
Package formula defines the per-unit deploy coordinate schema produced by the `design_attack` interactive tool and consumed by the deploy pipeline in `internal/attack`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL