{"id":50623590,"url":"https://github.com/hypoxic127/fh6-afk","last_synced_at":"2026-06-06T15:00:58.747Z","repository":{"id":359996643,"uuid":"1248299329","full_name":"hypoxic127/FH6-AFK","owner":"hypoxic127","description":"🏎️ Fully automated super wheel farming bot for Forza Horizon 6, powered by Computer Vision \u0026 Virtual Gamepad","archived":false,"fork":false,"pushed_at":"2026-06-02T00:34:34.000Z","size":13616,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-02T01:19:07.173Z","etag":null,"topics":["afk-farming","automation","bot","computer-vision","forza-horizon-6","opencv","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hypoxic127.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-24T13:10:42.000Z","updated_at":"2026-06-02T00:34:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/hypoxic127/FH6-AFK","commit_stats":null,"previous_names":["hypoxic127/fh6","hypoxic127/fh6-afk"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/hypoxic127/FH6-AFK","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypoxic127%2FFH6-AFK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypoxic127%2FFH6-AFK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypoxic127%2FFH6-AFK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypoxic127%2FFH6-AFK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hypoxic127","download_url":"https://codeload.github.com/hypoxic127/FH6-AFK/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypoxic127%2FFH6-AFK/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33986901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-06T02:00:07.033Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["afk-farming","automation","bot","computer-vision","forza-horizon-6","opencv","python"],"created_at":"2026-06-06T15:00:28.732Z","updated_at":"2026-06-06T15:00:58.715Z","avatar_url":"https://github.com/hypoxic127.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🏎️ FH6 AutoBot — A Never-Ending AFK Farming Machine\n\n**🌐 Language: English | [中文](README_zh-CN.md)**\n\n[![CI](https://github.com/hypoxic127/FH6-AFK/actions/workflows/ci.yml/badge.svg)](https://github.com/hypoxic127/FH6-AFK/actions/workflows/ci.yml)\n[![Release](https://github.com/hypoxic127/FH6-AFK/actions/workflows/release.yml/badge.svg)](https://github.com/hypoxic127/FH6-AFK/actions/workflows/release.yml)\n![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-3776ab?logo=python\u0026logoColor=white)\n![Platform](https://img.shields.io/badge/platform-Windows-0078d4?logo=windows\u0026logoColor=white)\n![License](https://img.shields.io/badge/license-Personal%20Use-f5c542)\n\n\u003e A fully automated, infinite-loop Skill Points farming system for **Forza Horizon 6**.\n\u003e Powered by **Computer Vision (OpenCV + Tesseract OCR)** and **Virtual Gamepad (ViGEmBus)**, achieving **zero human intervention** closed-loop farming.\n\u003e Comes with a **Cyberpunk-styled Web UI** dashboard for remote monitoring and one-click control.\n\n---\n\n## 📋 Table of Contents\n\n- [✨ Features](#-features)\n- [🔄 Workflow](#-workflow)\n- [🛠️ Tech Stack](#️-tech-stack)\n- [🚀 Getting Started](#-getting-started)\n- [📖 Usage](#-usage)\n- [📁 Project Structure](#-project-structure)\n- [🧪 Testing \u0026 CI](#-testing--ci)\n- [🔍 Technical Details](#-technical-details)\n- [🤝 Contributing](#-contributing)\n- [📝 License](#-license)\n\n---\n\n## ✨ Features\n\n| Feature | Description |\n|:--------|:------------|\n| 🔁 **4-Stage Auto Loop** | Farm → Buy → Upgrade → Sell, infinite loop, sleep \u0026 farm |\n| 👁️ **Computer Vision State Machine** | Color histogram + OCR hybrid detection, identifies 10+ game UI states |\n| 🎮 **Virtual Gamepad** | ViGEmBus simulates Xbox 360 controller, native-level input |\n| 🖥️ **Web UI Dashboard** | Glassmorphism UI + real-time logs + QR code mobile monitoring |\n| ⏹️ **Instant Stop** | Thread injection technology, bot stops immediately on button click |\n| 🎰 **Super Wheelspin Counter** | Automatically tracks upgrade macro executions |\n| 📦 **One-Click Build** | PyInstaller single-file `.exe`, no Python required |\n| 🧪 **95 Test Cases** | Ruff linting + Pytest coverage, GitHub Actions CI |\n\n---\n\n## 🔄 Workflow\n\n```\n    ┌─────────────┐     ┌─────────────┐     ┌─────────────┐     ┌─────────────┐\n    │  🏎️ Farm     │────▶│  🛒 Buy      │────▶│  ⚡ Upgrade  │────▶│  🗑️ Sell     │\n    │ Skill Points│     │    Cars     │     │    Cars     │     │    Cars     │\n    └──────┬──────┘     └─────────────┘     └─────────────┘     └──────┬──────┘\n           │                                                           │\n           │                    ♻️ Infinite Loop                       │\n           └───────────────────────────────────────────────────────────┘\n```\n\n| Stage | State Constant | Description |\n|:-----:|:---------------|:------------|\n| 1️⃣ | `STATE_FARM_POINTS` | OCR scans skill points → auto-enters EventLab to farm up to 999 |\n| 2️⃣ | `STATE_BUY_CARS` | Five-step visual navigation → batch-purchase 33 Subaru Impreza 22B-STIs |\n| 3️⃣ | `STATE_UPGRADE_CARS` | Select each car with NEW tag → spend skill points on skill tree |\n| 4️⃣ | `STATE_TRASH_CARS` | Batch-remove upgraded Imprezas (keeping S2 main car) |\n\n---\n\n## 🛠️ Tech Stack\n\n| Category | Technology | Purpose |\n|:---------|:-----------|:--------|\n| **Vision Engine** | OpenCV, Tesseract OCR | Image processing, text recognition, color detection |\n| **Numerics** | NumPy | Histogram comparison, image matrix operations |\n| **Screen Capture** | MSS | High-performance cross-platform screenshots |\n| **Gamepad** | VGamepad + ViGEmBus | Virtual Xbox 360 controller input |\n| **Web Server** | Flask + Flask-SocketIO | Real-time Web UI control panel |\n| **Frontend** | Vanilla JS + CSS3 | Glassmorphism dashboard, WebSocket live logs |\n| **Testing** | Pytest + Ruff | Unit testing + code quality checks |\n| **Packaging** | PyInstaller | One-click single-file executable build |\n| **CI/CD** | GitHub Actions | Automated testing + Release publishing |\n\n---\n\n## 🚀 Getting Started\n\n### 📋 Prerequisites\n\n\u003e ⚠️ The following software must be installed before running\n\n| Software | Version | Download | Notes |\n|:---------|:--------|:---------|:------|\n| **Python** | 3.10+ | [python.org](https://www.python.org/downloads/) | Check \"Add to PATH\" during install |\n| **Tesseract OCR** | 5.x | [Download](https://github.com/UB-Mannheim/tesseract/releases) | Check \"Add to PATH\" during install |\n| **ViGEmBus** | Latest | [Download](https://github.com/ViGEm/ViGEmBus/releases) | **Reboot required** after install |\n\n### 📥 Installation\n\n```bash\n# 1. Clone the repository\ngit clone https://github.com/hypoxic127/FH6-AFK.git\ncd FH6-AFK\n\n# 2. One-click install (auto-creates venv + installs dependencies)\npython setup.py\n\n# 3. Launch (Web UI mode)\npython main_bot.py --web\n```\n\n### 🎮 In-Game Preparation\n\nBefore starting the bot, ensure the following:\n\n1. **Game language must be set to English** — OCR depends on English text\n2. **Windowed mode** — Windowed or Borderless Windowed (recommended: 2560×1440)\n3. **Purchase main car** — `1998 Subaru Impreza 22B-STI Version`\n4. **Install S2 tune** — Any S2-class tune (PI badge = blue)\n5. **Favorite the EventLab blueprint** — Share code `890169683`\n6. **Enable Auto-Steering** — Go to `Settings → Difficulty → Auto-Steering: ON`. The bot relies on auto-steering for autonomous driving in EventLab\n\n\u003e **⚠️ Important:** The S2 **blue PI badge** on the main car is the sole indicator the program uses to distinguish \"keep\" vs \"deletable\" cars. Make sure your main car has an S2 tune applied.\n\n---\n\n## 📖 Usage\n\n### 🌐 Web UI Mode (Recommended)\n\n```bash\npython main_bot.py --web              # Default port 6800\npython main_bot.py --web --port 8080  # Custom port\n```\n\nOpen `http://localhost:6800` in your browser to access the control panel:\n\n- 🎯 **Live Status** — Current stage, loop count, runtime, super wheelspin count\n- 🔄 **Progress Bar** — Visual 4-stage progress indicator\n- ⚙️ **Stage Selector** — Start from any stage via dropdown\n- 📜 **Live Log Terminal** — Syntax-highlighted real-time log stream\n- 📱 **QR Remote Monitoring** — Scan QR code to monitor from your phone\n\n### 💻 Terminal Mode\n\n```bash\npython main_bot.py\n```\n\n| Option | Function | When to Use |\n|:------:|:---------|:------------|\n| `[0]` | 🔄 Auto loop (full cycle) | Main menu — full 4-stage infinite loop |\n| `[1]` | 🏎️ Farm Skill Points | Main menu — enter EventLab |\n| `[2]` | 🛒 Buy Cars | Main menu — batch purchase Imprezas |\n| `[3]` | ⚡ Upgrade Cars | Main menu — spend skill points |\n| `[4]` | 🗑️ Sell Cars | In garage, Subaru brand selected |\n| `[5]` | ⏭️ Skip Buy loop | When garage already has un-upgraded cars |\n\n### 📦 Build Executable\n\n```bash\npython packaging/build.py\n```\n\nProduces `dist/FH6AutoBot.exe` — portable, no Python needed (Tesseract \u0026 ViGEmBus still required).\n\n\u003e **💡 Tip:** Push a git tag (e.g. `git tag v1.2.0 \u0026\u0026 git push --tags`) to auto-trigger GitHub Actions build and publish to the Releases page.\n\n---\n\n## 📁 Project Structure\n\n```\nFH6_AutoBot/\n│\n├── main_bot.py                 # 🚀 Entry point (Terminal / Web UI)\n│\n├── engine/                     # 🧠 Perception Engine\n│   ├── ocr.py                  #    Computer vision (OCR + color detection)\n│   ├── state_detect.py         #    Game state detector (histogram + OCR hybrid)\n│   ├── event_bus.py            #    Event bus (log/state push to Web UI)\n│   ├── runtime.py              #    PyInstaller runtime path resolution\n│   └── utils.py                #    Logging / window ops / gamepad / MSS capture\n│\n├── macro/                      # 🎮 Macro Operations\n│   ├── master_loop.py          #    Master state machine (4-stage loop engine)\n│   ├── core.py                 #    Infrastructure: screenshots, logging, constants\n│   ├── navigation.py           #    Menu navigation / visual braking / return-to-garage\n│   ├── purchase.py             #    5-step Impreza purchase navigation\n│   ├── garage.py               #    Garage grid: select / delete / main car nav\n│   └── upgrade.py              #    Upgrade macro (Cannot Afford detection)\n│\n├── farm/                       # 🏁 EventLab Farming\n│   └── skills.py               #    Visual state machine (auto-drive + finish detection)\n│\n├── web/                        # 🌐 Web UI Control Panel\n│   ├── server.py               #    Flask + SocketIO server\n│   ├── state_manager.py        #    Global state manager\n│   └── static/                 #    Frontend assets\n│       ├── index.html          #      Dashboard page\n│       ├── style.css           #      Cyberpunk theme styles\n│       └── app.js              #      WebSocket client logic\n│\n├── packaging/                  # 📦 Build \u0026 Packaging\n│   ├── build.py                #    One-click PyInstaller build script\n│   ├── FH6AutoBot.spec         #    PyInstaller spec (--onefile)\n│   └── hook_utf8.py            #    Runtime hook (Windows UTF-8 fix)\n│\n├── tests/                      # 🧪 Unit Tests (95 cases)\n├── tools/                      # 🔧 Dev utilities (not packaged)\n│\n├── .github/workflows/\n│   ├── ci.yml                  #    CI (Ruff check + Pytest)\n│   └── release.yml             #    Release (PyInstaller → GitHub Release)\n│\n├── setup.py                    # ⚙️ One-click environment setup\n├── requirements.txt            # 📋 Python dependencies\n├── ruff.toml                   # 🔍 Ruff linter config\n└── pytest.ini                  # 🧪 Pytest config\n```\n\n---\n\n## 🧪 Testing \u0026 CI\n\n```bash\n# Run all tests\npython -m pytest\n\n# Lint check\npython -m ruff check .\n\n# Format check\npython -m ruff format --check .\n```\n\n| CI Job | Trigger | Description |\n|:-------|:--------|:------------|\n| **Lint** | Push / PR | Ruff lint + format validation |\n| **Test** | Push / PR | 95 test cases (ubuntu-latest) |\n| **Release** | `v*` tag | PyInstaller build → GitHub Release |\n\n---\n\n## 🔍 Technical Details\n\n### 👁️ Visual State Detection\n\n- **Histogram + OCR Hybrid** — `StateDetector` uses color distribution features for fast candidate screening, then OCR for precise verification\n- **PI Badge Color Detection** — HSV color space analysis: blue = S2 main car (keep), orange = deletable\n\n### 🔤 OCR Strategy\n\n- **Dual PSM Mode** — Uses PSM 8 (single word) + PSM 7 (single line), picks the result with most digits\n- **OTSU Adaptive Thresholding** — Prevents single-digit zero-padding errors\n- **Zero Skill Points Fallback** — Detects \"No Skill Points Available\" text\n\n### 🎯 Garage Grid Navigation\n\n- **Typewriter Traversal** — Column by column, top to bottom (3×N grid)\n- **Triple Verification** — OCR keywords (2/3 match) + NEW yellow tag + LEGENDARY orange rarity\n- **Cannot Afford Detection** — Auto-dismisses popup, stops purchasing\n\n### 📦 Build \u0026 Packaging\n\n- **PyInstaller --onefile** — Single ~44MB executable\n- **Runtime Path Layer** — `engine/runtime.py` unified path resolution (dev/packaged dual-mode)\n- **UTF-8 Console Fix** — `hook_utf8.py` resolves Chinese log garbling on Windows\n\n---\n\n## 🤝 Contributing\n\nContributions are welcome! Please follow this workflow:\n\n1. **Fork** this repository\n2. Create a feature branch (`git checkout -b feat/amazing-feature`)\n3. Commit your changes (`git commit -m 'feat: add amazing feature'`)\n4. Push to the branch (`git push origin feat/amazing-feature`)\n5. Open a **Pull Request**\n\n### Development Standards\n\n- 🐍 Code style: PEP 8 (enforced by Ruff)\n- 🏷️ Commit format: [Conventional Commits](https://www.conventionalcommits.org/) (`feat` / `fix` / `docs` / `refactor` / `chore`)\n- ✅ All PRs must pass CI checks (Lint + Test)\n\n---\n\n## 📝 License\n\nThis project is for **learning and personal use** only.\n\n---\n\n**If this project helps you, please give it a ⭐ Star!**\n\nMade with ❤️ by [hypoxic127](https://github.com/hypoxic127)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypoxic127%2Ffh6-afk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypoxic127%2Ffh6-afk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypoxic127%2Ffh6-afk/lists"}