Knight's Tour

Move a knight so it visits every square of the board once.

Knight's Tour Visualization

AI CHESS LAB

Knight’s Tour Visualizer

A cinematic backtracking showcase with premium motion, reactive lighting, path choreography, and synchronized algorithm telemetry.

Moves

0/64

Completion

0%

Mode

IDLE

Candidates

0

Neural Search Board
Pathfinding Active
Execution Progress0%
Playback Speed220ms

Synced Code Panel

1function solveKnightTour(board) {
2 const path = [];
3
4 function backtrack(row, col, moveIndex) {
5 board[row][col] = moveIndex;
6 path.push({ row, col });
7
8 if (moveIndex === 63) return true;
9
10 for (const [dr, dc] of knightMoves) {
11 const nr = row + dr;
12 const nc = col + dc;
13
14 if (isValid(nr, nc, board)) {
15 if (backtrack(nr, nc, moveIndex + 1)) {
16 return true;
17 }
18 }
19 }
20
21 board[row][col] = -1;
22 path.pop();
23 return false;
24 }
25
26 return backtrack(0, 0, 0);
27}

Telemetry

Current Position(0, 0)
Visited Nodes0
Remaining64
Search PatternBacktracking
Board Size8 × 8
Move SetKnight L-Moves

Knight Brain

Status: Awaiting command...

Next legal candidates: 0

Heuristic: Sequential DFS path expansion.

Visual cue: Green pulses mark reachable unvisited cells.

Complexity

Time Complexity: O(8^(N²))
Space Complexity: O(N²)

Pseudocode

function tour(step, x, y):
  if step == N*N: return true
  for each knight move:
    if next cell is valid and unvisited:
      mark cell
      if tour(step + 1, nx, ny): return true
      unmark cell
  return false