Hill Climbing: N-Queens

Complete Algorithm Execution on 4×4 Board

See ALL neighbor evaluations and watch the complete search process

Hill Climbing Strategy

🎯 Goal:

Place 4 queens with no conflicts (U = 0)

🔄 Each Step:

Move one queen to best position in its column

Key Insight: With 4×4 board, we can see ALL possible neighbors! Evaluate every move (each queen to every position in its column), then choose the best.
Important: Hill climbing can get stuck in LOCAL MAXIMA! Sometimes it will find the solution (U=0), other times it will get trapped before reaching it. Try clicking "Reset" multiple times to see different outcomes.
Utility Function
U = -conflicts
Higher utility = Better state

Step 1: Initial State

Current board state
-8
Current Utility
8
Total Conflicts
1
Step Number
0
Neighbors Checked
Algorithm Status:

Starting with initial random placement. Each queen is in a different column.

Complete Neighbor Evaluation

Showing ALL possible neighbors - maximum 12 moves per step (4 queens × 3 alternate positions each)

Click "Next Step" to see neighbor evaluation and selection process