A Spring Boot web app that solves the N-Queens problem using three CSP algorithms — Backtracking, Forward Checking, and MAC — with optional MRV, Degree, and LCV heuristics. Includes an interactive frontend for visualizing and comparing results across algorithms.
- Backend:
Java 17,Spring Boot 3.2 - Build:
Maven - Frontend:
HTML,CSS,JavaScript - Libraries:
AOS(scroll animations) - Deployment:
Railway
Three CSP Algorithms: Backtracking (baseline), Forward Checking (domain pruning after each placement), and MAC (arc consistency via AC-3 at every step).Three Heuristics: MRV (choose the most constrained variable), Degree (break ties by most-constrained), and LCV (order values by least impact on neighbors) — toggleable per run.Random Start: Optional random initialization to diversify search paths, enabling board sizes up to N=32.Interactive Board Visualizer: Renders the solved chessboard per algorithm with tabbed switching between results.Metrics Comparison: Displays constraint checks and solve time for each algorithm side-by-side.Preset Board Sizes: One-click presets (4, 8, 16, 20 — and up to 32 with Random Start enabled).
- Modeled N-Queens as a CSP: variables = columns, domains = rows, constraints = no two queens share a row, column, or diagonal.
- Implemented Backtracking as the baseline recursive search.
- Extended with Forward Checking to prune domain sizes after each queen placement.
- Implemented AC-3 for MAC to propagate arc consistency more aggressively at each step.
- Layered MRV, Degree, and LCV heuristics as optional enhancements on top of all three algorithms.
- Exposed a
/api/solveREST endpoint via Spring Boot and built a vanilla JS frontend to drive it. - Deployed to Railway.
mvn spring-boot:run- Live at: n-queens.up.railway.app
- Or locally at
http://localhost:8080
