This is a Rush Hour puzzle game solver implemented in Python with a Pygame GUI. Rush Hour is a sliding puzzle game where the objective is to move a goal car (red car) out of a traffic jam by strategically moving other cars out of its path.
- Interactive GUI: Visual board display with a 6x6 grid where cars can move horizontally or vertically
- Multiple Solving Algorithms: Three different pathfinding algorithms to solve the puzzle:
- Depth-First Search (DFS): Explores the search space deeply before backtracking
- Greedy Algorithm: Uses heuristics to prioritize moves that appear to get closer to the goal
- A Algorithm*: Combines heuristic estimates with actual distance for optimal pathfinding
- Multiple Puzzle Configurations: 10 different predefined puzzle setups to solve
- Move Visualization: Displays the solution path and individual car movements
| File | Purpose |
|---|---|
Main.py |
Entry point; sets up Pygame GUI, button controls, and puzzle selection |
GameBoard.py |
Manages the 6x6 puzzle grid, car placement, and board state |
Car.py |
Base class for car objects with position and movement properties |
HorizontalCar.py |
Represents horizontally-oriented cars |
VerticalCar.py |
Represents vertically-oriented cars |
Solver.py |
Implements the three solving algorithms (DFS, Greedy, A*) |
- A puzzle board is loaded with cars in specific positions
- The solver algorithm explores possible moves (moving each car left, right, up, or down)
- The algorithm tracks visited states to avoid infinite loops
- Once a solution is found, the path is displayed as a sequence of moves
- The goal is achieved when the red goal car reaches the exit_Rush_Hour