This project is a Flask web application that validates chess move sequences, detects illegal moves, handles "empty" moves (marked with 'z'), and checks for threefold repetition.
It uses the python-chess library and custom modules for predictions, HTML board rendering, and repetition detection.
- Enter a sequence of chess moves in SAN (Standard Algebraic Notation).
- Detects illegal moves and reports the move number.
- Handles special "z" marker in move sequences:
- Stops parsing when "z" is encountered.
- Reports that an empty move was found.
- Stores user input in Flask session for further processing.
- Checks for threefold repetition using a custom repetition detection function.
- Provides multiple HTML templates for displaying results.
. ├── app.py # Main Flask app ├── minmax.py # model-based move predictor ├── chessBoard.py # HTML chessboard generator ├── repetition.py # Threefold repetition checker ├── templates/ │ ├── index.html # Input form │ ├── legal.html # Shown when all moves are legal │ ├── repetition.html # Repetition results │ └── empty.html # (Optional) predictions page ├── static/ # (Optional) CSS/JS assets └── README.md # Documentation
-
Clone or download the project files.
-
Install dependencies: pip install flask chess
(If using prediction features, also install TensorFlow/Keras and NumPy)
-
Run the Flask server: python app.py
-
Open in browser: http://127.0.0.1:5000/
- Navigate to the index page.
- Enter a sequence of chess moves (e.g., e4 e5 Nf3 Nc6).
- The app will:
- Show "Move sequence is legal" if no errors are found.
- Report illegal moves with their move number.
- Report "Empty move found" if a 'z' is present.
- You can check threefold repetition at
/process_repetition, which uses the last entered move sequence stored in the session.
- python-chess: For move validation and FEN board handling.
- Flask session: Stores the last entered move sequence.
- repetition.py: Custom script for detecting threefold repetition.
- Templates:
- index.html → Input form + error messages.
- legal.html → Shows legal move sequences.
- repetition.html → Shows repetition detection results.
- Render the current board state using HTML chessboard.
- Integrate model predictions (minmax.py + CNN model).
- Provide top move suggestions when a "z" marker is found.
- Add user authentication for saving move history.
This project is open-source. Feel free to use and modify it for research or educational purposes.