Autonomous game agent using Tesseract OCR, MVC Architecture, and ETL pipelines for real-time strategy.
An advanced, autonomous bot for Tibianic-like Pokรฉmon MMORPGs, built with Python, OpenCV, and Tesseract OCR. This project demonstrates the power of computer vision and state machine logic for game automation.
Disclaimer: This project is for educational and research purposes only. Use it at your own risk. The author is not responsible for any bans or penalties incurred while using this software.
- Autonomous Navigation: Detects "Goto" buttons and mission prompts to navigate automatically.
- Intelligent Battle System:
- Reads enemy names and your own Pokรฉmon/HP via OCR.
- Makes smart decisions (Fight vs. Flee) based on type advantages.
- Calculates damage multipliers (STAB, effectiveness).
- Detects HP levels and recommends healing/switching.
- Computer Vision (Perception):
- Real-time screen capture using
mss. - State detection (Exploring, Battling, Dialog).
- Shiny Pokรฉmon detection with audible alarms.
- Real-time screen capture using
- OCR Integration: Uses Tesseract to read game text (names, levels, chat).
- Configurable: Highly customizable behavior via
config/settings.yaml.
- Bezier Curve Movements: Mouse moves in natural curves, not straight lines
- Randomized Delays: Variable timing (50-500ms) prevents pattern detection
- Idle Actions: Occasional camera movement, spacebar presses, and pauses
- AI Chat Integration (Optional): Natural conversation using Ollama/Gemini/OpenAI
- HP Detection: Color-based analysis of HP bars for intelligent item/switch decisions
- 4 Operational Modes:
- IDLE: Passive observation (only alerts on Shiny)
- MISSION: Automated quest progression (follows Goto/Talk)
- HUNTING: Targeted Pokรฉmon hunting (flees from non-targets)
- FOLLOW: Tracks and follows your main character (for secondary accounts)
- Priority System: Shiny > Battle > Behavior
- Smart Hunting: Automatically flees from unwanted encounters
- Real-Time Control: Switch modes instantly without restarting the bot
- Global Hotkeys: Works even when game window is focused (F1-F9)
- Pause/Resume: Freeze bot temporarily with a single key press
- Follow Mode:
- Template matching to visually track your character
- Party button support for automatic following
- Configurable distance and detection thresholds
- 30-60x Faster: Change modes in ~1 second vs ~30-60 seconds before!
- VM Control: Control bot running in VM from your physical machine
- Ultra-Low Latency: 1-5ms response time (UDP protocol)
- No RDP Required: Send commands without opening VM console
- Multi-VM Support: Control multiple VMs simultaneously from one host
- Simple Setup: Just open 1 UDP port and configure IP
- Background Operation: Works even when VM is minimized
- Dynamic HP Detection:
- Color-based HP analysis (HSV color space)
- 10-40x faster than OCR (5-10ms vs 50-200ms)
- Detects green/yellow/red HP bars
- Persistent Follow Mode:
- OCR Name Tracking: Finds player by in-game username
- Memory System: Remembers last seen position (5s timeout)
- Recovery Search: Automatically rotates camera/moves to reacquire lost targets
- Smart Movement: 70% proportional movement prevents vibration
- Battle Intelligence:
- HP-based healing decisions (< 25% HP)
- Automatic Pokรฉmon switching when HP critical
- Type advantage calculations with STAB bonus
- Risk/Reward Analysis:
- Projects next turn to prevent suicidal plays
- Calculates if you'll survive before attacking
- Smart healing: only heals when safe
- Damage Prediction System:
- Estimates incoming enemy damage
- Factors type effectiveness & enemy items
- Auto-switches when death is imminent
- Item Inference (AI):
- Detects Choice Scarf automatically (speed-based)
- Detects Choice Band/Life Orb (damage-based)
- Adjusts strategy mid-battle based on inference
- Speed Tier Calculations:
- Real Pokรฉmon formula (IVs, EVs, Nature)
- Predicts who attacks first
- Considers worst-case scenarios
- Python: Core logic and control.
- OpenCV: Image processing and template matching.
- Tesseract OCR: Optical Character Recognition for reading text.
- MSS: Ultra-fast cross-platform screen capture.
- PyAutoGUI: Simulating mouse and keyboard actions.
- SciPy: Bezier curve calculations for human-like movements.
- Pynput: Global hotkey listener for real-time control.
- Loguru: Pleasant execution logging.
- Windows OS (Required for
winsoundalerts and specific input handling). - Python 3.8+ installed.
- Tesseract OCR installed:
- Download and install from UB-Mannheim/tesseract/wiki.
- Ensure the installation path matches the one in your
config/settings.yaml(default:C:\Program Files\Tesseract-OCR\tesseract.exe).
-
Clone the repository:
git clone https://github.com/Fesisp/PokeBot.git cd PokeBot -
Install dependencies:
pip install -r requirements.txt
-
Configure Tesseract: Open
config/settings.yamland verify theocr.tesseract_cmdpath points to your local Tesseract executable.
- Launch the Game Client and ensure it is visible on the screen.
- Run the Bot:
python run_bot.py
- Controls:
- The bot will display available hotkeys on startup
- F1-F4: Switch between modes instantly
- F5/F6: Pause/Resume bot
- F9: Stop bot completely
- Ctrl+C (terminal): Alternative way to stop
No need to restart the bot anymore! Use hotkeys to control in real-time:
| Hotkey | Action |
|---|---|
| F1 | Switch to IDLE mode |
| F2 | Switch to MISSION mode |
| F3 | Switch to HUNTING mode |
| F4 | Switch to FOLLOW mode |
| F5 | Pause bot |
| F6 | Resume bot |
| F9 | Stop bot |
Example workflow:
1. Start bot: python run_bot.py
2. Press F2 โ Bot starts doing missions
3. Press F5 โ Bot pauses (you take control)
4. Press F6 โ Bot resumes
5. Press F3 โ Bot switches to hunting mode
6. Press F9 โ Bot stops
All in ~1 second each - no more editing configs and restarting!
You can also set the initial mode in config/settings.yaml:
Mission Mode (Default) - Automated quest progression:
bot:
behavior: "mission"Hunting Mode - Target specific Pokรฉmon:
bot:
behavior: "hunting"
hunt:
target_pokemon: ["ditto", "eevee"]
move_interval: 2.0Follow Mode - Track and follow your main character:
bot:
behavior: "follow"
follow:
method: "template" # or "party_button"
player_template: "player_char.png"
match_threshold: 0.7Idle Mode - Passive Shiny detection only:
bot:
behavior: "idle"- ๐ Hotkey Quick Setup - Get started with hotkeys in 5 minutes
- ๐ฎ Hotkey System Guide - Complete hotkey documentation
- ๐ Remote Control UDP - Control bot in VM from host machine
- ๐ง Follow Mode Guide - Advanced FOLLOW with memory and AI
- โ๏ธ Advanced Battle Engine - Risk calculation & damage prediction โญ NEW!
- ๐ Changelog v2.4 - What's new in v2.4
- Quick Start Guide - Installation and setup
- Modes Guide - How to use IDLE/MISSION/HUNTING/FOLLOW
- State Machine - Technical architecture
- Humanization Features - Anti-detection features
- Changelog - Version history and updates
PokeBot/
โโโ assets/ # Template images for OpenCV matching
โโโ config/ # Configuration files (settings.yaml)
โโโ data/ # Game knowledge (Pokedex, moves, types JSONs)
โโโ docs/ # Documentation and design overviews
โโโ src/ # Source code
โ โโโ action/ # Mouse/Keyboard inputs
โ โโโ core/ # Main loop and bot controller
โ โโโ decision/ # Battle logic and strategy
โ โโโ knowledge/ # Data managers (PokeAPI, Team)
โ โโโ perception/ # Vision, OCR, and state detection
โ โโโ utils/ # Helper functions
โโโ tests/ # Unit tests
โโโ run_bot.py # Entry point
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.