Game Settings
Introduction to Sliding Puzzle Game
The Sliding Puzzle is a classic puzzle game where players need to rearrange scrambled numbers into the correct order by moving tiles. The goal is to arrange the numbers in ascending order with the empty space at the end.
Rules:
 The game board consists of nÃ—n grid cells (this game supports 3Ã—3, 4Ã—4, 5Ã—5);
 Each cell contains numbers from 1 to nÂ²1, plus one empty space;
 Numbers can only be rearranged by moving them into the adjacent empty space;
 The game is won when all numbers are arranged in sequence (1 to nÂ²1) with the empty space at the end;
Features of This Page

Support for Different Difficulty Levels:
 Easy: 15 random moves
 Medium: 550 random moves
 Hard: 50500 random moves

Excellent User Experience:
 Click adjacent numbers to swap with empty space, responsive layout for different screens;
 Animated movements to easily observe each step
 Track moves count and time

Special Features:
 Manual setup of initial layout, convenient for solving any configuration
 Smart solving feature (A* algorithm)
 Stepbystep solution display
 Validation of solvability during manual setup
Playing Tips
Finding a solution for the sliding puzzle is relatively easy, but finding the optimal solution is an NPhard problem.
There are some techniques, such as identifying optimal paths by observing the shortest route from target numbers to their destinations, planning empty space movements in advance, and avoiding ineffective backandforth moves. Additionally, try to think multiple steps ahead rather than just one move at a time, plan 23 moves ahead, and be careful not to obstruct subsequent operations.
It's important to note that not all manually set number layouts are solvable. For a configuration to be solvable, it must meet these conditions:
 Oddsized boards (3Ã—3, 5Ã—5): The number of inversions must be even
 Evensized boards (4Ã—4): The sum of inversions and empty space row number (counting from bottom) must be odd
Smart Solving Algorithm
All randomly generated initial layouts on this page are solvable. The page uses the A* algorithm for smart solving, with these steps:
 Uses Manhattan distance as the heuristic function;
 Stores states to explore in a priority queue;
 Records visited states to avoid repeated searches;
 Shows solution steps after finding the shortest path;
For larger sizes (4Ã—4, 5Ã—5) at higher difficulties, more steps may be needed, and smart calculation might get stuck. It's recommended to start with lower difficulties.
This game is open source, with code available on Github.