- Blind mode tutorial
lichess.org
Donate

NOV 1st , Info on WIldorderBOT Reverted back to old version. High memory usage

Chess botChess engineLichessSoftware DevelopmentOff topic
Disclaimer until I get my bot Deployed on Replit. It's Only on when I turn it On manually. Mostly Saturdays for arenas.

When my bot is online you can send a challenge to it as long as it's not currently in a game. I will have it play as many Arenas and Team battles as Possible.
_________________________________________________________________________________________________________________________________________________
Hey all After a lot of work in Replit, I finally got my Bot where I want it 'So far'.
The Bot Runs Stockfish 17.1 and was originally programmed to run at around 3000+elo Has a depth of 15-30+ Depending on the Time Control
It will play Super accurately at 3+0 and higher.
It will Auto Challenge other bot's and I can add bot's to be challenged as well.
There is a Quick Challenge Option 3+0 Rated and casual 3+2 5+0 5+3 and 1+0
I can Send chat messages live in game only.
I can Challenge a user without having to log into the lichess bot account directly. Note: For arena's and Team Battles, I would still Have to log into the bot account to not accept challenges from other users and Bot's.
_________________________________________________________________________________________________________________________________________________
Now something cool Regarding Challenging other bot's, Is that when it auto challenges a bot for 3+0 rated and that doesn't work, it will send a 3+0 casual challenge, and if that doesn't work, it will challenge another bot, and keep doing the cycle for 5 times to prevent an infinite loop of this.

This program that run's the bot will help me a lot when using it :)

I ALSO HAD THE REPLIT AGENT MAKE A FRONTEND LOCAL SITE!!! I can Control/View the Bot Controls, This helps a ton without having to Manually login into the Bot account to do mess with setting's and stuff.

PS: The game link is clickable on my side so I get a Direct link to the game it's playing :D
Screenshot 2025-10-07 at 4.47.37 PM.png
Screenshot 2025-10-25 at 6.52.32 PM.png
Screenshot 2025-10-25 at 6.52.39 PM.png
Screenshot 2025-10-07 at 4.47.45 PM.png

A BIG THANKS TO LICHESS!!!! For allowing Bot account's to be used here. :D
And a BIG thanks to Replit the best Coding Platform in the World!!!

Now the code that Runs the program and the bot

Screenshot 2025-10-07 at 5.15.00 PM.png
The bot communicates between all these layers - Python controls the Stockfish C++ engine via UCI protocol, serves the HTML/CSS/JS frontend via Flask, and the JavaScript frontend talks back to Python through REST API calls. Pretty neat integration of multiple languages!

UPDATED OCT 25th

Lichess Chess Bot with Stockfish 17.1 & Fairy Stockfish

Overview

This project is a high-performance chess bot designed to play on Lichess at a 3000+ ELO level. It leverages either Stockfish 17.1 for standard chess or Fairy Stockfish for various chess variants. The bot features adaptive time management, a comprehensive web control panel, and advanced statistical tracking. Its primary purpose is to provide a highly competitive and versatile AI opponent on the Lichess platform.

User Preferences

  • I want iterative development.
  • Ask before making major changes.
  • I prefer detailed explanations.
  • Do not make changes to the folder stockfish/.
  • Do not make changes to the file .gitignore.

System Architecture

UI/UX Decisions

The bot features a full-featured Flask web interface (app.py and templates/index.html) for control and monitoring. It provides:

  • Real-time status updates and activity logs with color-coded messages.
  • Interactive performance dashboards using Chart.js for ELO progression, variant statistics, and opening repertoire.
  • Tabbed interface for navigation between statistics, control, and settings.
  • Responsive design with a gradient theme.

Technical Implementations

  • Engine Integration: Uses UCI protocol for communication with Stockfish 17.1 (AVX2 optimized) and Fairy Stockfish 14 (Largeboard with BMI2).
  • Adaptive Time Management: Dynamically calculates move time and search depth based on game time controls (e.g., specific optimizations for bullet, blitz, rapid, classical). This can be overridden by manual speed controls.
  • Challenge System: Automated and manual challenge capabilities for users and random bots, with configurable acceptance/rejection logic. Includes a blocklist system to prevent challenging specific users.
  • Game Management: Handles only one game at a time. Features robust turn validation via board reconstruction and integrated chat functionality.
  • Statistics & Analytics: Tracks game results, ELO progression, opponent performance, variant performance, and top openings. Data is persistently stored in stats.json.
  • Chess Knowledge Base: Integrates Polyglot opening books (500K+ positions), an expanded middlegame book (100+ patterns), and programmatic endgame generation (10,000+ theoretical positions) for enhanced play.

Feature Specifications

  • Engine Selection: Ability to switch between Stockfish (standard chess, Chess960) and Fairy Stockfish (8 variants including Crazyhouse, King of the Hill, Atomic, etc.) via the web interface.
  • Challenge Controls: Fine-grained toggles for challenging bots/users, and an "Arena/Team Battle Mode" to disable all challenges during events.
  • Manual Speed Control: Adjustable move time, search depth, and move overhead sliders, with a toggle to switch between manual and adaptive modes.
  • Blocklist System: Manage a persistent list of users to avoid challenging.
  • Cooperative Shutdown: Ensures graceful termination of the bot and its resources.

System Design Choices

  • Modular Design: Separated concerns with app.py for web, lichess_bot.py for core bot logic, and dedicated directories for engines.
  • Persistent Storage: Utilizes blocklist.json and stats.json for persistent data storage across sessions.
  • Event-Driven Architecture: The LichessBot class handles Lichess API events and game state transitions.

Recent Changes

Oct 25, 2025 - Advanced Engine Settings Added (Multi-PV & Syzygy Tablebases)

  • Multi-PV Analysis: Configure engine to analyze multiple principal variations (1-5)
    • Shows multiple best move options simultaneously
    • Provides backup plans and deeper positional understanding
    • Configurable via slider in web interface
    • Great for analysis mode and finding alternative strategies
  • Syzygy Tablebase Support: Perfect endgame play with 3-4-5 piece tablebases
    • Engine plays perfectly in endgames with ≤5 pieces
    • Automatic detection of available tablebase files
    • Toggle on/off via web interface
    • Status indicator shows availability and enabled state
    • Download script provided: ./download_tablebases.sh (~1GB for 3-4-5 pieces)
  • Web Interface: New "Advanced Settings" card with:
    • Multi-PV slider (1-5 variations)
    • Syzygy tablebase toggle with status indicator
    • Clear instructions for downloading tablebases
    • Real-time updates and activity log messages
  • Backend: Full UCI protocol integration for both features
    • Dynamic engine reconfiguration without restart
    • Proper SyzygyPath handling
    • MultiPV parameter automatically updated

Oct 25, 2025 - Uptime Monitor Added

  • Uptime Tracking: Added comprehensive uptime and session performance monitoring
    • Displays bot uptime in days, hours, minutes, and seconds
    • Tracks session-specific statistics (games played, wins, losses, draws)
    • Calculates and displays session win rate
    • Automatically updates every 2 seconds via live API polling
    • Data persists across page refreshes
  • Web Interface: New Uptime Monitor card on main dashboard
    • Positioned prominently next to Bot Status for easy visibility
    • Shows all session metrics in real-time
    • Clean, readable format with icon
  • Backend Tracking: LichessBot class now tracks uptime and session stats
    • start_time recorded when bot initializes
    • Session counters (games, wins, losses, draws) updated after each game
    • get_uptime_metrics() method provides formatted data

Oct 25, 2025 - Pondering Feature Added

  • Engine Pondering: Added ability for engine to think during opponent's time
    • Enabled by default for maximum playing strength
    • Configurable via web interface toggle
    • Engine now uses ponder=True in UCI protocol
    • Significantly improves bot performance by utilizing opponent's thinking time
    • Can be toggled on/off without restarting bot
  • Web Interface: Added pondering toggle in Speed Settings
    • Clear visual indication with icon
    • Descriptive help text explaining the feature
    • Real-time updates with activity log messages

Oct 25, 2025 - Complete Game History Import (704 Games)

  • Full History Import: Successfully imported ALL games from wildorderbot's Lichess account
    • 704 total games (both rated and casual games)
    • Complete game metadata: results, opponents, ratings, openings, variants, timestamps, move counts, URLs
    • Current record: 405 wins, 161 losses, 138 draws (57.5% win rate)
    • Average game length: 94.3 moves
    • ELO ratings tracked across all games
  • Statistics API Enhancement: Modified to read directly from stats.json
    • Statistics available even when bot is stopped
    • Real-time analytics: win rates, ELO progression, opponent stats, variant performance, opening repertoire
    • Supports Chart.js visualizations for all 704+ games of historical data

External Dependencies

  • Lichess API: Used for all interactions with the Lichess platform.
  • berserk: Python client library for the Lichess API.
  • python-chess: Comprehensive chess library for board representation and UCI engine communication.
  • flask: Web framework for the control panel.
  • flask-cors: Enables Cross-Origin Resource Sharing for the web interface.
  • Stockfish 17.1: Chess engine binary.
  • Fairy Stockfish 14: Chess variant engine binary.
  • Chart.js: JavaScript library for data visualization in the web interface.
  • chess.polyglot: Python library for reading Polyglot opening books.

NEW REPLIT.MD file DESC of BOT in full UPDATED OCT 12th

Lichess Chess Bot with Stockfish 17.1 & Fairy Stockfish

Overview

A competitive chess bot that connects to Lichess via API and plays at 3000+ ELO level using either Stockfish 17.1 (standard chess) or Fairy Stockfish (chess variants). The bot features adaptive time management based on game time controls and can play only one game at a time.

Current State

  • Bot Account: WildorderBot (connected)
  • Engines:
    • Stockfish 17.1 (AVX2 optimized, 8 threads) - Standard chess & Chess960
    • Fairy Stockfish 14 (Largeboard with BMI2) - All chess variants
  • Status: Running and accepting challenges
  • Game Mode: One game at a time

Features

  1. Engine Selection: Choose between Stockfish and Fairy Stockfish
    • Stockfish: Optimized for standard chess and Chess960
    • Fairy Stockfish: Supports 8 chess variants (Crazyhouse, Chess960, King of the Hill, Three-check, Antichess, Atomic, Horde, Racing Kings)
    • Dynamic variant support based on selected engine
    • Seamless engine switching via web interface
    • Cannot change engine during active games
  2. Web Control Panel: Full-featured web interface to control and monitor the bot
    • Real-time status monitoring (bot state, current game, engine status)
    • Start/stop bot controls with proper shutdown mechanism
    • Challenge specific users or random bots
    • Quick challenge buttons for preset time controls
    • Live activity logs with color-coded messages
    • In-game chat functionality
    • User blocklist management
  3. Challenge Controls: Fine-grained control over challenging behavior
    • Toggle bot challenges on/off independently
    • Toggle user challenges on/off independently
    • Arena/Team Battle Mode: Disables all challenges (sending & accepting)
    • Perfect for participating in arena or team battle events
  4. Manual Speed Control: Override adaptive time management
    • Adjustable move time (1ms to 5s)
    • Adjustable search depth (1 to 30 ply)
    • Adjustable move overhead (1ms to 500ms)
    • Toggle between manual and adaptive modes
  5. Blocklist System: Prevent bot from challenging specific users
    • Add/remove users via web interface
    • Persistent storage in blocklist.json
    • Case-insensitive username matching
    • Works for both manual and automatic challenges
  6. Stockfish 17.1 Integration: Latest chess engine via UCI protocol
  7. Adaptive Time Management (Optimized for Ultra-Fast Bullet):
    • Bullet 1+0 (60s): 0.04s max, depth 18 (ULTRA FAST)
    • Bullet with increment: 0.06s max, depth 18 (ULTRA FAST)
    • Bullet+ (≤3 min): 0.3s max, depth 20
    • Blitz (3-8 min): 2s max, depth 22
    • Rapid (8-15 min): 5s max, depth 25
    • Classical (>15 min): 15s max, depth 30
  8. Auto-Challenge System: Automatically challenges random online bots with fallback logic
    • First tries 3+0 rated, then 3+0 casual
    • If both fail, tries a new bot (up to 5 retries)
  9. Single Game Restriction: Only plays one game at a time
  10. Turn Validation: Robust board reconstruction to prevent double-moves
  11. Chat Feature: Sends custom messages during games

Project Architecture

Main Components

  • app.py: Flask web application for bot control and monitoring
  • templates/index.html: Web interface frontend with real-time updates
  • lichess_bot.py: Main bot script with Lichess API integration
  • stockfish/: Stockfish 17.1 binary directory
  • .gitignore: Python and Stockfish binaries excluded from git

Key Classes and Methods

  • LichessBot: Main bot class
    • challenge_user(): Challenge another player
    • challenge_random_bot(): Challenge random bot with fallback logic
    • handle_game(): Main game loop with turn-checking
    • make_move(): Calculate and execute best move
    • get_time_limit(): Adaptive time/depth calculation
    • send_chat_message(): Send chat messages in game
    • run(): Main event loop for challenges and games
    • stop(): Cooperative shutdown with session interruption

Dependencies

  • flask: Web framework for control panel
  • flask-cors: CORS support for API
  • berserk: Official Lichess API Python client
  • python-chess: Chess library with UCI engine support
  • stockfish: 17.1 binary (x86_64 AVX2)

Recent Changes

Oct 11, 2025 - Fairy Stockfish Integration & Chess Variants Support

  • Fairy Stockfish Engine: Added Fairy Stockfish 14 for playing chess variants
    • Largeboard binary with BMI2 optimization for modern CPUs
    • Supports 8 chess variants: Crazyhouse, Chess960, King of the Hill, Three-check, Antichess, Atomic, Horde, Racing Kings
    • Configured for 3000+ elo level performance (8 threads, 2048 MB hash)
  • Engine Selection Settings: Toggle between Stockfish and Fairy Stockfish via web interface
    • Stockfish: Standard chess and Chess960 only
    • Fairy Stockfish: All variants including standard chess
    • Dynamic variant support based on selected engine
    • Cannot change engines/BOT's during active games
    • Automatically accepts/declines challenges based on engine capabilities
  • Variant-Specific Board Handling: Proper board initialization for all supported variants
    • Each variant uses its appropriate python-chess board type
    • Correct UCI variant configuration for Fairy Stockfish
    • Seamless move generation across all game types

Oct 9, 2025 - Challenge Controls & Speed Settings

  • Challenge Controls: Fine-grained control over challenging behavior
    • Can Challenge Bots: Toggle to enable/disable challenging bots
    • Can Challenge Users: Toggle to enable/disable challenging human players
    • Arena/Team Battle Mode: Disables all challenge sending and accepting
    • Perfect for participating in Lichess arena or team battle events without interruptions
    • All settings accessible via web interface with real-time updates
    • Backend enforcement in challenge_user(), accept_challenge(), and challenge_random_bot()
  • Manual Speed Control: Override adaptive time management
    • Adjustable move time slider (1ms to 5s)
    • Adjustable search depth slider (1 to 30 ply)
    • Adjustable move overhead slider (1ms to 500ms)
    • Toggle between manual and adaptive modes
    • Engine overhead automatically syncs when changing modes
    • Settings persist in real-time while bot is running

Oct 9, 2025 - User Blocklist Feature

  • Blocklist System: Prevent bot from challenging specific users
    • Add/remove usernames (human or bot) via web interface
    • Persistent storage in blocklist.json file
    • Case-insensitive username matching for reliability
    • Blocks work for both manual challenges and automatic random bot challenges
    • Real-time UI updates with blocked user list and count
    • Individual remove buttons for each blocked user
    • Clean error handling and user feedback messages

Oct 7, 2025 - Web Control Panel & Enhanced Challenge Logic

  • Web Control Panel: Full-featured Flask web interface
    • Real-time bot status monitoring and control
    • Start/stop bot with proper cooperative shutdown mechanism
    • Challenge specific users or random bots from UI
    • Quick challenge buttons for common time controls (1+0, 3+0, 3+2, 5+0, 5+3)
    • Live activity logs with color-coded messages (info, success, warning, error)
    • In-game chat messaging
    • Responsive design with gradient theme
  • Enhanced Challenge Logic: Improved fallback mechanism
    • First tries 3+0 rated challenge
    • Falls back to 3+0 casual if rated fails
    • Tries new bot if both fail (up to 5 retries)
  • Cooperative Shutdown: Bot can now be reliably stopped
    • stop() method interrupts blocking event stream
    • Session closure ensures thread termination
    • Proper cleanup of engine and resources

Oct 7, 2025 - Ultra-Fast Bullet & Auto-Challenge

  • Optimized for ultra-fast bullet play:
    • 1+0 bullet: 0.04s max, depth 18 (ULTRA FAST)
    • Bullet with increment: 0.06s max, depth 18 (ULTRA FAST)
  • Auto-challenge feature: Automatically challenges random online bots
  • Ultra-low latency: Move overhead reduced to 2ms
  • Opening optimization: 35% faster moves in first 12 moves for bullet
  • Improved error handling: Gracefully handles bot-incompatible challenges
  • Enhanced logging: Shows time control for all incoming challenges
  • Note: Bots cannot play ultrabullet (15s games) on Lichess

Oct 4, 2025

  • Added ultra-bullet optimization (15 second games) with 0.08s move time
  • Reduced move overhead from 50ms to 10ms for faster play
  • Added chat feature: bot says "I am WildOrderBot root for me :)" once per game
  • Fixed time management to cache clock settings from gameFull event
  • Added robust turn-checking via board reconstruction
  • Implemented single-game-at-a-time restriction
  • Added challenge_user() method for initiating games
  • Fixed time management to use bot's own clock (not opponent's)

Environment Variables

  • LICHESS_TOKEN: Bot account API token (required, set in Secrets)

Usage

The bot is controlled via the web interface at local http 0.0.0.500 ish site

  1. Start the Bot: Click "Start Bot" to initialize and run the bot
    • Enable "Auto-Challenge Random Bots" to automatically play games
    • Or specify users to challenge in the text field
  2. Challenge Users: Enter a username and time control, then click "Send Challenge"
  3. Quick Challenge: Use preset time control buttons to challenge random bots
  4. Challenge Controls: Fine-tune who the bot can challenge
    • Toggle "Can Challenge Bots" to allow/prevent bot challenges
    • Toggle "Can Challenge Users" to allow/prevent human challenges
    • Enable "Arena/Team Battle Mode" to disable all challenges when playing in events
  5. Speed Settings: Control bot move speed
    • Enable "Manual Speed Control" to override adaptive time management
    • Adjust move time, search depth, and overhead with sliders
    • Disable to use adaptive time based on game clock
  6. Send Chat: Type messages to send in active games
  7. Manage Blocklist: Add or remove users the bot should never challenge
    • Enter a username and click "Add to Blocklist"
    • Click "Remove" next to any blocked user to unblock them
    • Blocked users are saved in blocklist.json and persist across bot restarts
  8. Stop the Bot: Click "Stop Bot" to safely shutdown
  9. Monitor: View real-time logs and status updates

To modify bot behavior, edit lichess_bot.py:

  • Adjust time/depth thresholds in get_time_limit()
  • Modify challenge acceptance logic in run()
  • Change chat messages in handle_game()