A computer-vision and constraint-based solver for Crowns (Queens) logic puzzles.
The system takes a puzzle screenshot as input, reconstructs the grid and regions using OpenCV, solves the puzzle via constraint logic, and re-renders the board from scratch with queen placements using Canvas.
- 📸 Screenshot-based puzzle input
- 🔍 Automatic grid detection and cell segmentation
- 🎨 Region detection via color clustering
- 🧩 Constraint solver for queen placement
- 🎭 Clean board re-rendering (Canvas)
- 🏗️ Clear separation of vision, solver, and UI layers
- Frontend uploads a puzzle screenshot
- Backend extracts the grid using OpenCV
- Cells are grouped into regions by color
- Solver applies constraint rules
- UI renders a clean puzzle board and queen positions
The screenshot is used only as input.
- Python
- OpenCV
- NumPy
- FastAPI
- HTML
- JavaScript
- Canvas API
- Install dependencies:
pip install -r requirements.txt- Run the web app:
cd WebApp/
uvicorn main:app --reload The application will be available in your browser. Upload a puzzle screenshot and click Solve.
- (Optional) Run tests:
python Tester.py{
"cells": [
[{ "region": 0, "color": [214, 181, 92] }]
],
"queens": [
{ "row": 0, "col": 1, "region": "C1" }
]
}cells→ UI-ready color gridqueens→ solved queen positions
├── CoreSolver.py # N-Queens constraint solver
├── ImageProcessing.py # Grid detection & cell segmentation
├── GameofCrownsBoardFetcher.py # Board data fetching
├── Tester.py # Test suite
├── requirements.txt # Python dependencies
├── images/ # Sample puzzle screenshots
└── WebApp/
├── main.py # Flask/FastAPI backend
├── index.html # Web UI
├── app.js # Canvas rendering + API calls
└── __init__.py
- No screenshot overlays → no alignment bugs
- Separate color pipelines for solver and UI
- Deterministic rendering
- Canvas-based drawing for precision
- Requires a clear grid in the screenshot
- Similar region colors may need threshold tuning
- Square grids only (for now)
- Step-by-step solver visualization
- Adding DFS to core solver as additional mechanism
- Export solved boards as images
MIT