An advanced AI-powered Chess.com bot with human-like behavior and anti-detection capabilities
- Stockfish Engine: Powered by the world's strongest chess engine
- Dynamic Elo Rating: Configure target playing strength (800-3000 Elo)
- Opening Book Support: Polyglot (
.bin) format with random selection - Blunder Logic: Intentional mistakes to simulate human imperfection
- Dynamic Depth & Nodes: Adaptive analysis based on game phase
| Phase | Feature | Description |
|---|---|---|
| 1 | Browser Stealth | Playwright stealth mode + Bezier curve mouse movement |
| 2 | Human Delays | Exponential thinking time with occasional deep thought pauses |
| 3 | Idle Actions | Random mouse movements during opponent's turn |
| 4 | Viewport Randomization | Randomized window size (1366-1920px) and zoom (90-110%) |
| 5 | Human Typing | Variable typing speed (180-350 CPM) with typos |
Adaptive delays based on game mode and remaining time:
- Normal: 0.5-1.5s thinking time
- Time pressure (<60s): Instant moves (0.1-0.3s)
- Fast mouse mode: Linear movement (0.03s vs 1.5s)
- Normal: 0.5-4.0s thinking time
- Time pressure (<60s): Fast moves (0.3-0.8s)
- Deep thought: Rare (1.5% chance, max 6s)
- Normal: 0.5-15s thinking time
- Deep thought: 5% chance, up to 30s
- Full human-like delays enabled
- Auto-play: Continuous game mode with configurable delays
- Headless Mode: Run browser in background
- Auto-move: Automatic piece movement
- Game Loop: Handles game-over modal and restarts automatically
- Python 3.8+
- Git
- Internet connection
# 1. Clone the repository
git clone https://github.com/Veloruze/chess.git
cd chess
# 2. Create virtual environment (recommended)
python -m venv venv
# Windows:
.\venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
# 3. Install dependencies
pip install -r requirements.txt
playwright install chromium- Create credentials file (
credentials.txtin root directory):
your_chess_com_username
your_chess_com_password
-
Add opening books (optional):
- Download Polyglot
.binfiles - Place them in
opening_books/directory - Bot will randomly select one per game
- Download Polyglot
-
Configure settings (edit
config.ini):
[play]
mode = Blitz # Bullet, Blitz, or Rapid
headless = false # true = background, false = visible
auto_move = true # Automatic piece movement
auto_play = true # Play multiple games
num_games = 0 # 0 = unlimited
[engine_settings]
UCI_Elo = 1500 # Target playing strength (800-3000)python chess_assist/main.py| Parameter | Values | Description |
|---|---|---|
mode |
Bullet, Blitz, Rapid |
Time control mode |
headless |
true, false |
Run browser in background |
auto_move |
true, false |
Automatic piece movement |
auto_play |
true, false |
Play multiple games |
num_games |
0-999 |
Number of games (0 = unlimited) |
advanced_time_management |
true, false |
Dynamic time allocation |
| Parameter | Default | Description |
|---|---|---|
UCI_LimitStrength |
true |
Enable Elo-based strength |
UCI_Elo |
1500 |
Target Elo rating (800-3000) |
Skill Level |
20 |
Stockfish skill (0-20) |
Contempt |
10 |
Draw reluctance (-100 to 100) |
Threads |
4 |
CPU cores to use |
Hash |
128 |
Memory in MB (16-4096) |
MultiPV |
3 |
Lines to analyze (β₯2 for blunders) |
Search depth adjusts by game phase:
| Phase | Min Depth | Max Depth | Description |
|---|---|---|---|
| Opening | 8 | 12 | Book moves + tactical awareness |
| Middlegame | 10 | 15 | Full analysis, complex tactics |
| Endgame | 12 | 18 | Precise calculation required |
Simulate human mistakes:
enabled = true
max_score_diff_cp = 100 # Max centipawn loss
min_blunder_chance = 0.05 # 5% minimum probability
max_blunder_chance = 0.15 # 15% maximum probabilityHow it works:
- Analyzes top 3 moves (requires
MultiPV β₯ 2) - Randomly chooses suboptimal move 5-15% of the time
- Only if score difference < 100 centipawns (1 pawn)
Exponential distribution for realistic thinking:
enabled = true
min_base_thinking_time = 0.5 # Minimum delay (seconds)
max_base_thinking_time = 2.5 # Maximum delay (seconds)
exponential_lambda = 0.7 # Distribution shape
deep_thought_probability = 0.05 # 5% chance of long pauseMode-specific limits:
- Bullet: Max 1.5s normal, 2.5s deep thought
- Blitz: Max 4.0s normal, 6.0s deep thought
- Rapid: Max 15s normal, 30s deep thought
Random mouse movement during opponent's turn:
enabled = true
action_probability = 0.25 # 25% chance per turn
action_types = random_move,piece_hover,board_scanDelays before starting next game:
min_rapid_delay_seconds = 15
max_rapid_delay_seconds = 45
min_blitz_delay_seconds = 10
max_blitz_delay_seconds = 30
min_bullet_delay_seconds = 5
max_bullet_delay_seconds = 15When remaining time < 60 seconds:
- Instant thinking (0.1-0.8s based on urgency)
- Fast mouse mode enabled:
- Normal: 30 steps, 50ms delay = 1.5s
- Fast: 5 steps, 2ms delay = 0.03s (98% faster)
- No deep thought pauses
When remaining time < 30 seconds:
- Ultra-fast moves (0.1-0.3s)
- Minimal mouse animation
Chess.com uses two formats:
| Time Remaining | Format | Example | Parsing |
|---|---|---|---|
| > 20 seconds | mm:ss |
0:59, 1:30 |
Split by : |
| < 20 seconds | ss.d |
19.2, 01.4 |
Parse float, strip leading zeros |
1. Module Import Error
ModuleNotFoundError: No module named 'src'
Solution: This is already fixed. Make sure you're running the latest version.
2. Play Button Not Found
Exception: Play button not found
Solution: Updated to use data-cy='new-game-index-play'. Pull latest changes.
3. Timeout in Blitz Games
Solution: Delays are optimized for each mode. Ensure advanced_time_management = true in config.
4. "Play a Friend" Instead of Online Mode Solution: Fixed - bot now explicitly selects "Online" mode before starting.
5. Invalid Time Format
invalid literal for int() with base 10: '01.4'
Solution: Already fixed - handles leading zeros in time format.
Enable detailed logging:
# Windows
set PYTHONUNBUFFERED=1
python chess_assist/main.py
# Linux/macOS
PYTHONUNBUFFERED=1 python chess_assist/main.pyCheck log files in project root for detailed error traces.
chess-from-zero/
βββ chess_assist/
β βββ main.py # Entry point
βββ src/
β βββ browser.py # Playwright automation + stealth
β βββ game.py # Game logic + time management
β βββ engine.py # Stockfish interface
β βββ automove.py # Mouse movement (Bezier curves)
β βββ human_delays.py # Phase 2: Thinking delays
β βββ human_typing.py # Phase 5: Typing patterns
β βββ idle_actions.py # Phase 3: Mouse movements
β βββ selectors.py # CSS selectors for Chess.com
β βββ utils.py # Helper functions
βββ engine/
β βββ stockfish.exe # Chess engine
βββ opening_books/ # Polyglot .bin files
βββ config.ini # Main configuration
βββ credentials.txt # Chess.com login (gitignored)
βββ requirements.txt # Python dependencies
This project is for educational purposes only. Using automated bots on Chess.com violates their Terms of Service and may result in:
- Account suspension
- Permanent ban
- Rating/title revocation
Use at your own risk. The developers assume no responsibility for account penalties.
If you choose to use this bot:
- Never use on your main account
- Don't use in rated games (practice only)
- Respect fair play guidelines
- Don't ruin the experience for others
The purpose of this project is to demonstrate:
- Browser automation techniques
- Anti-detection strategies
- Chess engine integration
- Human behavior simulation
For more realistic progression, modify UCI_Elo over time:
# In main.py
game_number = 1
base_elo = 1200
for game in range(10):
current_elo = base_elo + (game_number * 25) # +25 Elo per game
config.set('engine_settings', 'UCI_Elo', str(current_elo))
# ... play game
game_number += 1Increase blunder rate when winning:
# In game.py
if score > 200: # Winning by 2 pawns
blunder_chance *= 2 # Double the mistake rateOrganize books by color/opening:
opening_books/
βββ white_e4/
β βββ italian.bin
β βββ spanish.bin
βββ white_d4/
β βββ queens_gambit.bin
βββ black/
βββ sicilian.bin
βββ french.bin
- β
Fixed time parsing for formats with leading zeros (
01.4) - β Optimized auto-play loop (skip mode selection for game 2+)
- β Updated selectors for "Start Game" and "New Game" buttons
- β Removed unnecessary selector fallbacks for cleaner code
- β Implemented fast mouse mode for time pressure (<60s)
- β Fixed double delay issue (thinking + mouse animation)
- β Added Chess.com dual time format support (<20s vs >20s)
- β Optimized delays for Bullet/Blitz/Rapid modes
- β Complete 5-phase anti-detection system
- β Human-like delays with exponential distribution
- β Idle actions during opponent's turn
- β Viewport randomization
- β Human typing patterns with typos
Contributions welcome! Please follow these guidelines:
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
# Install dev dependencies
pip install -r requirements-dev.txt
# Run tests
pytest tests/
# Format code
black src/ chess_assist/This project is licensed under the MIT License - see the LICENSE file for details.
- Stockfish - The world's strongest chess engine
- Playwright - Reliable browser automation
- python-chess - Chess library for Python
- GitHub Issues: Report bugs
- Discussions: Ask questions
Made with βοΈ by Veloruze
If you found this useful, give it a β!