A web-based chess training application focused on drilling fundamental endgame positions against perfect computer play.
-
Three Core Endgame Positions:
- Lucena Position (Rook + Pawn vs Rook - winning technique)
- Philidor Position (Rook + Pawn vs Rook - drawing technique)
- King + Pawn vs King (opposition and breakthrough)
-
Perfect Computer Opposition: Stockfish engine at depth 20+ for theoretically perfect play
-
Interactive Web Interface: Drag-and-drop chess board with immediate feedback
-
Repetitive Practice: Reset positions instantly for kata-style training
-
Position Evaluation: Get engine analysis of current position
-
Clone or download this repository
-
Create and activate a virtual environment:
# Create virtual environment python3 -m venv venv # Activate virtual environment # On macOS/Linux: source venv/bin/activate # On Windows: # venv\Scripts\activate
-
Install Python dependencies:
pip install -r requirements.txt
-
Install Stockfish:
macOS (using Homebrew):
brew install stockfish
Ubuntu/Debian:
sudo apt-get install stockfish
Windows:
- Download from Stockfish website
- Add to PATH or update
engine.pywith correct path
-
Activate the virtual environment (if not already active):
# On macOS/Linux: source venv/bin/activate # On Windows: # venv\Scripts\activate
-
Start the application:
python app.py
-
Open your browser and go to:
http://localhost:5000 -
How to play:
- Select an endgame position from the dropdown
- Click "Start Position" to begin
- Make moves by dragging pieces
- The computer will respond with perfect play
- Use "Show Hint" to see the best move
- Use "Undo Move" to take back your last move
- Use "Reset Position" to start over
- Stockfish not found: Update the
stockfish_pathinengine.pyto point to your Stockfish binary - Import errors: Make sure all dependencies are installed with
pip install -r requirements.txt - Port already in use: Change the port in
app.py(last line) to a different number
chess-endgames/
├── app.py # Flask application with API endpoints
├── positions.py # FEN strings and position metadata
├── engine.py # Stockfish interface and chess logic
├── requirements.txt # Python dependencies
├── static/
│ ├── js/
│ │ └── game.js # Frontend game logic and API calls
│ └── css/
│ └── style.css # Styling and responsive design
├── templates/
│ └── index.html # Main game interface
└── README.md # This file
- Lucena Position: Learn the bridge-building technique to win R+P vs R
- Philidor Position: Master the passive defense to hold a draw in R+P vs R
- King + Pawn vs King: Understand opposition and breakthrough patterns
Practice these positions repeatedly until the patterns become automatic!