The code is divided into several classes that model the different components of the 8-puzzle problem:
Sq8Action Class: This class models an action in the 8-puzzle, such as sliding a tile from one position to another. It inherits from a base `Action` class and adds details specific to the 8-puzzle, like the tile being moved and its source and destination positions.
Sq8State Class: The `Sq8State` class represents the state of the puzzle at any given time. It includes methods for displaying the state, comparing states, generating successors (i.e., possible moves), and applying actions. For instance, the `__str__` method converts the state into a human-readable string format, showing tiles and empty spaces.
Sq8Problem Class: This class models the overall 8-puzzle problem, integrating the initial state, goal state, and the logic to determine whether a state is the goal. It can be used with search algorithms like BFS or DFS to find the solution.