Skip to content

About

Rush Hour Puzzle Solver is a Python project with a Pygame GUI that solves the classic 6x6 sliding car puzzle. It implements DFS, Greedy, and A* algorithms to find a path for the red car to reach the exit, visualizing moves and supporting multiple predefined puzzle configurations.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Rush Hour Puzzle Solver

Overview

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.

Features

  • 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

Program Structure

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*)

How It Works

  1. A puzzle board is loaded with cars in specific positions
  2. The solver algorithm explores possible moves (moving each car left, right, up, or down)
  3. The algorithm tracks visited states to avoid infinite loops
  4. Once a solution is found, the path is displayed as a sequence of moves
  5. The goal is achieved when the red goal car reaches the exit_Rush_Hour

About

Rush Hour Puzzle Solver is a Python project with a Pygame GUI that solves the classic 6x6 sliding car puzzle. It implements DFS, Greedy, and A* algorithms to find a path for the red car to reach the exit, visualizing moves and supporting multiple predefined puzzle configurations.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages