Skip to content

hypoxic127/FH6-AFK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

215 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽ๏ธ FH6 AutoBot

๐ŸŒ Language: English | ไธญๆ–‡

An autonomous bot that plays Forza Horizon 6 with zero human input. It sees the game through computer vision (OpenCV + Tesseract OCR) and plays it through a virtual Xbox 360 controller (ViGEmBus), looping farm โ†’ buy โ†’ upgrade โ†’ sell forever โ€” and you drive the whole thing from a real-time web dashboard, even from your phone.

CI Release Latest Release Python 3.10+ Platform License Stars


๐ŸŽฌ Preview

FH6 AutoBot โ€” autonomous farm loop in action
Farming skill points, buying, upgrading, and selling cars โ€” hands-free.

FH6 AutoBot โ€” Web UI Dashboard
Web dashboard: live stage tracking, loop & super-wheelspin counters, log stream, and a QR code for phone monitoring.


๐Ÿ›๏ธ How It Works

FH6 AutoBot is a closed perception โ†’ decision โ†’ actuation loop. Every tick it captures the game window, decides what state the game is in, and issues controller input โ€” no human in the loop.

flowchart LR
    P["๐Ÿ‘๏ธ Perception (see)<br/>MSS capture<br/>OpenCV + OCR<br/>color histograms"]
    D["๐Ÿง  Decision (decide)<br/>4-stage state machine<br/>+ visual sub-FSMs"]
    A["๐ŸŽฎ Actuation (act)<br/>Virtual Xbox 360 pad<br/>(ViGEmBus)"]
    P --> D --> A
    A -.->|game window| P
Loading

The codebase is four layers with a strict one-way dependency direction (web โ†’ macro / farm โ†’ engine, never the reverse), so perception never depends on the UI:

Layer Responsibility
engine/ Perception + infrastructure โ€” OCR, hybrid state detection, screen capture, gamepad, i18n, auto-updater
macro/ The automation โ€” the master state machine plus per-stage menu macros (navigate / purchase / garage / upgrade)
farm/ A self-contained visual sub-state-machine that auto-drives an EventLab race to completion
web/ Flask + SocketIO server and the vanilla-JS dashboard

Notable engineering:

  • 12-pass OCR voting โ€” every skill-point read runs 3 preprocessing variants ร— 4 Tesseract PSM modes and votes on the result, so a single bad frame can't derail it.
  • Histogram + OCR hybrid state detection โ€” fast color-distribution screening narrows the candidates, then OCR confirms โ€” cheap and robust across 10+ similar menus.
  • Self-healing capture โ€” on a BitBlt/GDI failure it resets the MSS instance and re-foregrounds the game window instead of feeding on black frames.
  • Cooperative-first safe stop โ€” halts on a clean boundary (gamepad released, never mid-keypress); async exception injection is only a fallback when a native call is blocking.

โœจ Features

Feature Description
๐Ÿ” 4-Stage Auto Loop Farm โ†’ Buy โ†’ Upgrade โ†’ Sell, infinite loop โ€” sleep while it farms
๐Ÿ–ฅ๏ธ Web Dashboard Glassmorphism UI + real-time logs + QR-code mobile monitoring
โน๏ธ Safe Instant Stop Stops the bot instantly and cleanly โ€” gamepad released, never mid-keypress
๐Ÿ”„ Auto-Update One-click update from the Web UI or --update, multi-mirror download
๐ŸŽฐ Super-Wheelspin Counter Automatically tracks upgrade-macro executions
๐Ÿ“ฆ One-Click Build PyInstaller single-file .exe, no Python required

๐Ÿ”„ Workflow

flowchart LR
    A["๐ŸŽ๏ธ Farm Skill Points"] --> B["๐Ÿ›’ Buy Cars"] --> C["โšก Upgrade Cars"] --> D["๐Ÿ—‘๏ธ Sell Cars"]
    D -->|"โ™ป๏ธ Infinite Loop"| A
Loading
Stage State Constant Description
1๏ธโƒฃ STATE_FARM_POINTS OCR scans skill points โ†’ auto-enters EventLab to farm up to 999
2๏ธโƒฃ STATE_BUY_CARS Five-step visual navigation โ†’ batch-purchase 33 Subaru Impreza 22B-STIs
3๏ธโƒฃ STATE_UPGRADE_CARS Select each car with a NEW tag โ†’ spend skill points on the skill tree
4๏ธโƒฃ STATE_TRASH_CARS Batch-remove upgraded Imprezas (keeping the S2 main car)

๐Ÿ› ๏ธ Tech Stack

Category Technology
Vision OpenCV ยท Tesseract OCR ยท NumPy
Capture & Input MSS ยท VGamepad + ViGEmBus
Web Flask + Flask-SocketIO ยท Vanilla JS + CSS3
Tooling Pytest + Ruff ยท PyInstaller ยท GitHub Actions

๐Ÿš€ Getting Started

๐Ÿ“‹ Prerequisites

Software Version Download Notes
Python 3.10+ python.org Check "Add to PATH" during install
Tesseract OCR 5.x Download Install to default location (auto-detected)
ViGEmBus Latest Download Reboot required after install

๐Ÿ“ฅ Installation

git clone https://github.com/hypoxic127/FH6-AFK.git
cd FH6-AFK
python setup.py          # creates a venv + installs dependencies
python main_bot.py --web # launch the Web UI

๐ŸŽฎ In-Game Preparation

  1. Set the game language to English โ€” OCR depends on English text
  2. Windowed / Borderless mode โ€” any 16:9 resolution works (the skill-points OCR region is tuned for 16:9). On a non-16:9 monitor or non-default HUD scale, use the Web UI Calibrate button to box the skill-points number and save your own ROI
  3. Buy the main car โ€” 1998 Subaru Impreza 22B-STI Version and install an S2 tune (PI badge = blue)
  4. Favorite an EventLab blueprint โ€” any works; the default share code 890169683 yields ~10 skill points per race
  5. Set Points / Match + Target Points in the Web UI to match your blueprint (wrong values over- or under-farm)
  6. Enable Auto-Steering (Settings โ†’ Difficulty โ†’ Auto-Steering: ON) โ€” the bot relies on it to drive in EventLab

โš ๏ธ The S2 blue PI badge on the main car is the only thing the bot uses to tell "keep" from "deletable" cars โ€” make sure your main car has an S2 tune applied.


๐Ÿ“– Usage

๐ŸŒ Web UI (recommended)

python main_bot.py --web              # default port 6800
python main_bot.py --web --port 8080  # custom port

Open http://localhost:6800 for live status, the stage selector, a syntax-highlighted log terminal, and a QR code to monitor from your phone.

FH6AutoBot.exe --update             # update to the latest release
FH6AutoBot.exe --skip-update --web  # skip the update check (e.g. autostart)

๐Ÿ’ป Terminal mode

python main_bot.py
Option Function When to Use
[0] ๐Ÿ”„ Auto loop (full cycle) Full 4-stage infinite loop
[1] ๐ŸŽ๏ธ Farm Skill Points Enter EventLab
[2] ๐Ÿ›’ Buy Cars Batch purchase Imprezas
[3] โšก Upgrade Cars Spend skill points
[4] ๐Ÿ—‘๏ธ Sell Cars In garage, Subaru brand selected
[5] โญ๏ธ Skip Buy loop When the garage already has un-upgraded cars

๐Ÿ“ฆ Build the executable

python packaging/build.py   # โ†’ dist/FH6AutoBot.exe (Tesseract & ViGEmBus still required)

๐Ÿ—บ๏ธ Roadmap

Indicative direction, not a promise โ€” ideas and PRs welcome.

  • Resolution-agnostic OCR โ€” auto-detect the skill-points ROI, dropping the 16:9 assumption
  • Dashboard analytics โ€” points/hour, cars processed, session history
  • Multi-monitor โ€” pick the capture display in the Web UI
  • More languages โ€” localization beyond en/zh

๐Ÿค Contributing

Contributions are welcome โ€” see CONTRIBUTING.md.


โš ๏ธ Disclaimer

FH6 AutoBot is provided for educational and personal use only. Automating gameplay may violate the game's Terms of Service and could result in penalties or an account ban โ€” use it at your own risk. This is an independent, fan-made tool, not affiliated with, endorsed by, or associated with the developers or publisher of any game it interacts with. The authors accept no liability for any consequences of its use.


๐Ÿ“ License

For learning and personal use only โ€” see LICENSE.


โญ Star History

Star History Chart


If this project helps you, please give it a โญ Star โ€” it genuinely helps others discover it.

Made with โค๏ธ by hypoxic127

About

Fully autonomous AFK skill point and super wheelspin farming bot for Forza Horizon 6 - computer-vision perception + virtual Xbox 360 controller, with a real-time web dashboard.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors