/Python-Game-Bot

A Python automation script using screen recognition with OpenCV, GUI automation with PyAutoGUI, and human-like interactions to reduce detection risk. This bot works by detecting request templates on screen and clicking the donation buttons intelligently.

Primary LanguagePythonMIT LicenseMIT

πŸ€– Clash of Clans Donation Bot

⚠️ Disclaimer: This project is intended for educational purposes only. Do not use this bot in real Clash of Clans accounts β€” doing so may violate Supercell’s Terms of Service and could result in your account getting banned. The author is not responsible for any misuse of this tool.

A Python automation script that donates troops in Clash of Clans using screen recognition with OpenCV, GUI automation with PyAutoGUI, and human-like interactions to reduce detection risk. This bot works by detecting request templates on screen and clicking the donation buttons intelligently.


πŸš€ Features

  • 🧠 Image recognition using OpenCV for troop and donation button detection
  • πŸ‘† Human-like clicks and movement using sigmoid curve pathing
  • 🀭 Real-time screen scanning and troop response loop
  • πŸ–ΌοΈ Visual overlay with troop request detection windows
  • πŸ₯΅ Multi-threaded design for efficient operation
  • 😢️ Works on screen-shared or emulator-based Clash of Clans sessions

πŸ“‚ File Structure

πŸ“ coc-bot/
β”œβ”€β”€ coc.py              # Main bot script (entry point)
β”œβ”€β”€ draw.py             # Tkinter-based debug visualization
β”œβ”€β”€ human_like.py       # Human-like movement and click simulation
β”œβ”€β”€ donate_file/        # Folder with troop template images (e.g., loon.png, light.png)
β”œβ”€β”€ donate.png          # Image template of the donation button

πŸ“¦ Requirements

Install the required Python packages using pip:

pip install opencv-python pyautogui numpy

⚠️ tkinter comes preinstalled with most Python distributions. If not, install it manually (especially on Linux).


πŸ› οΈ Usage

  1. Prepare your environment:

    • Run Clash of Clans on an emulator or screen-shared device in a fixed screen resolution (e.g., 1920x1080).
    • Position the game so that troop requests appear in the upper-left region of the screen.
  2. Add troop templates:

    • Place cropped grayscale images of troop requests (e.g., loon.png, light.png) in the donate_file/ directory.
    • Make sure each image matches the screen size and resolution precisely.
  3. Run the bot:

python coc.py

The bot will:

  • Continuously scan for troop requests
  • Detect and click donation buttons
  • Log activity to the console
  • Draw visual boxes to show detection zones

🧠 How It Works

  • find_template() scans specific screen regions for matching troop request templates.
  • If a match is found, it looks for the donate button nearby.
  • Clicks are performed via human_like.py, which simulates realistic motion paths.
  • draw.py draws a temporary red box to show what part of the screen is being scanned.

πŸ‘ Notes & Warnings

  • πŸ” Use at your own risk – while this mimics human behavior, automation tools may still be against game ToS.
  • πŸ–₯️ This bot is not universal – you must use proper screen resolution, or the templates won't match.
  • πŸ§ͺ Test in sandboxed or secondary accounts before using on your main.

πŸ€› Contributing

Contributions are welcome! Feel free to open issues or pull requests.