State Space Visualization

Understanding State Space through the 8-Puzzle Problem

Explore states, transitions, and search algorithms

What is State Space?

A state space is the set of all possible configurations (states) that a problem can be in. Each state represents a specific arrangement of the puzzle pieces.

Key Concepts:
  • State: A specific configuration of the puzzle
  • State Space: All possible states (up to 181,440 for 8-puzzle)
  • Transitions: Legal moves between states
  • Goal State: The solved puzzle configuration
  • Search: Finding path from initial to goal state
9! Total Permutations
181,440 Valid States
4 Max Moves per State

Interactive 8-Puzzle

Click tiles adjacent to the empty space to move them
Current State Representation
[1, 2, 3, 4, 5, 6, 7, 8, 0]
0 represents the blank space
Available Transitions
Current Session Stats
0 Moves Made
1 States Visited
? Distance to Goal
Puzzle ready - Make some moves or scramble to begin

State Space Tree

How to use the State Space Tree:
  • 🖱️ Click nodes to jump to that state
  • 🔍 Hover nodes to see state details
  • 🔄 Drag nodes to rearrange the tree
  • 🔍 Scroll to zoom in/out of the tree
  • 📈 Click "Expand Tree" to generate more neighboring states
Current State (Pulsing) Goal State Visited Unvisited
Search Algorithm Progress

Click "Auto Solve" to see BFS search through the state space

Understanding State Space
🎯 State Representation:
  • Each state is a 3×3 grid configuration
  • Represented as array: [1,2,3,4,5,6,7,8,0]
  • 0 represents the blank (empty) space
  • Goal state: tiles in numerical order
🔄 State Transitions:
  • Move blank space: Up, Down, Left, Right
  • Each move creates a new state
  • Not all moves are valid (edge constraints)
  • Maximum 4 transitions per state
🔍 Search Properties:
  • BFS guarantees shortest path
  • DFS may find longer paths
  • A* uses heuristics for efficiency
  • State space forms a connected graph
⚡ Complexity Analysis:
  • State space size: 9!/2 = 181,440
  • Branching factor: ~2.13 average
  • Maximum solution depth: 31
  • Most puzzles solvable in < 25 moves
💡 Key Insight:
The 8-puzzle state space is a perfect example of how complex problems can be modeled as graph search problems. Each state is a node, each legal move is an edge, and finding a solution becomes a path-finding problem in this graph.