๐ How to Play
Objective: Place N queens on the board so that no two queens attack each other (no shared row, column, or diagonal).
Rules: Click any cell to place a queen. Click again to remove it. Red highlighted cells show threatened positions. The conflict counter shows how many queen pairs are attacking each other. Solve it when conflicts = 0.
AI Concept: This is a Constraint Satisfaction Problem (CSP). Variables = queen positions, Domain = row numbers, Constraints = no two queens share a row, column, or diagonal.
๐ How to Play
Objective: Watch how backtracking search solves the N-Queens problem automatically.
Rules: The algorithm places one queen per column from left to right. If it can't find a valid row, it backtracks (undoes the last placement and tries the next option). Use "Step" for manual control or "Auto" with the speed slider.
AI Concept: Backtracking = systematic trial and error with early failure detection. It explores the search tree depth-first, pruning branches that violate constraints.
๐ How to Play
Objective: See how Forward Checking improves upon basic backtracking by eliminating impossible values early.
Rules: After each queen placement, future columns have their invalid rows greyed out (domain reduction). If any future column has 0 valid rows left, the algorithm backtracks immediately without trying further.
AI Concept: Forward Checking propagates constraints after each assignment, reducing future domains. This detects failures earlier than basic backtracking โ fewer backtracks needed.
๐ How to Play
Objective: See the formal CSP formulation update live as the puzzle is solved.
Rules: This panel shows the mathematical representation: Variables (Xโ..Xโ), Domains (1..n), and Constraints. The "Current Assignment" updates as queens are placed in any mode.
AI Concept: Every CSP has 3 components: Variables, Domains, and Constraints. The 8-Queens CSP has n variables (one per column), each with domain {1..n}, and constraints ensuring no attacks.
CSP Formulation of N-Queens
Variables
X = {Qโ, Qโ, Qโ, Qโ, Qโ
, Qโ, Qโ, Qโ}
Domains
D(Qแตข) = {1, 2, 3, 4, 5, 6, 7, 8} for all i โ {1..8}
Constraints
For all i โ j:
Qแตข โ Qโฑผ (no two queens in same row)
|Qแตข - Qโฑผ| โ |i - j| (no two queens on same diagonal)
Why one variable per column?
Placing exactly one queen per column reduces the problem
from choosing 64 squares to choosing 8 row-values.
Each variable Qแตข represents the row of the queen in column i.
Constraint Graph
Every pair of variables is constrained โ complete graph
Total constraints: C(n,2) ร 2 (row + both diagonals)
For n=8: 56 constraint pairs
Live Assignment (from Mode 2 or 3)
๐ How to Play
Objective: Compare the efficiency of different CSP solving algorithms on the same problem.
Rules: Click "Run All" to execute Backtracking, Forward Checking, and FC+MRV on the current board size. The results show assignments tried, backtracks needed, and time taken.
AI Concept: MRV (Minimum Remaining Values) picks the most constrained variable next, dramatically reducing search. FC+MRV combines domain pruning with smart variable ordering.