Loading repository dataโฆ
Loading repository dataโฆ
NhanPhamThanh-IT / repository
๐ AI-powered Rush Hour puzzle solver with Pygame GUI. Features BFS, DFS, UCS & A algorithms to solve traffic jam puzzles. Compare AI performance metrics, play manually, or watch automated solutions. Educational tool for learning search algorithms.
An intelligent Rush Hour puzzle game implementation featuring AI search algorithms and an intuitive graphical interface built with Pygame. This project demonstrates various artificial intelligence search strategies to solve the classic sliding puzzle game where the goal is to move a red car (marked as 'X') out of a traffic jam.
The Rush Hour Puzzle Solver is an educational AI project that implements and compares different search algorithms to solve Rush Hour puzzles. The game features:
AI-Search-Problem/
โโโ ๐ README.md # Project documentation
โโโ ๐ LICENSE # MIT License
โโโ ๐ requirements.txt # Python dependencies
โโโ ๐๏ธ src/ # Source code directory
โ โโโ ๐ main.py # Main application entry point
โ โโโ ๐๏ธ assets/ # Game assets (images, sounds)
โ โ โโโ ๐ผ๏ธ logo.png # Game logo
โ โโโ ๐๏ธ config/ # Configuration files
โ โ โโโ ๐ __init__.py # Package initialization
โ โ โโโ ๐ config.json # Game configuration settings
โ โ โโโ ๐ settings.py # Settings loader
โ โโโ ๐๏ธ core/ # Core game logic
โ โ โโโ ๐ __init__.py # Package initialization
โ โ โโโ ๐ board.py # Game board implementation
โ โ โโโ ๐ map_loader.py # Map loading utilities
โ โ โโโ ๐ vehicle.py # Vehicle class definition
โ โโโ ๐๏ธ entities/ # UI entities
โ โ โโโ ๐ __init__.py # Package initialization
โ โ โโโ ๐ button.py # Button UI component
โ โ โโโ ๐ dropdown.py # Dropdown UI component
โ โโโ ๐๏ธ maps/ # Puzzle map definitions
โ โ โโโ ๐ map1.json # Beginner level map
โ โ โโโ ๐ map2.json # Easy level map
โ โ โโโ ๐ map3.json # Medium level map
โ โ โโโ ๐ map4.json # Hard level map
โ โ โโโ ๐ map5.json # Expert level map
โ โ โโโ ๐ ... # Additional maps (6-10)
โ โโโ ๐๏ธ rushhour/ # Game state management
โ โ โโโ ๐ state.py # Game state representation
โ โโโ ๐๏ธ scenes/ # Game scenes
โ โ โโโ ๐ __init__.py # Package initialization
โ โ โโโ ๐ home.py # Main menu screen
โ โ โโโ ๐ playing.py # Game playing screen
โ โ โโโ ๐ help.py # Help/instructions screen
โ โโโ ๐๏ธ solvers/ # AI search algorithms
โ โ โโโ ๐ __init__.py # Package initialization
โ โ โโโ ๐ base_solver.py # Base solver class
โ โ โโโ ๐ bfs_solver.py # Breadth-First Search
โ โ โโโ ๐ dfs_solver.py # Depth-First Search
โ โ โโโ ๐ ucs_solver.py # Uniform Cost Search
โ โ โโโ ๐ astar_solver.py# A* Search with heuristics
โ โโโ ๐๏ธ utils/ # Utility functions
โ โโโ ๐ __init__.py # Package initialization
โ โโโ ๐ helper.py # Helper functions
โโโ ๐๏ธ tests/ # Test files
โโโ ๐ test_map.py # Map loading tests
Clone the repository
git clone https://github.com/NhanPhamThanh-IT/AI-Search-Problem.git
cd AI-Search-Problem
Create a virtual environment (recommended)
python -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate
Install dependencies
pip install -r requirements.txt
Verify installation
python src/main.py
requirements.txt for complete listNavigate to the project directory
cd AI-Search-Problem
Start the game
python src/main.py
Game Flow
Maps are defined in JSON format with the following structure:
{
"size": [6, 6], // Board dimensions [rows, cols]
"vehicles": [
// Array of vehicles
{
"name": "X", // Vehicle identifier (X = main car)
"row": 2, // Starting row position
"col": 0, // Starting column position
"length": 2, // Vehicle length
"orientation": "H" // H = Horizontal, V = Vertical
},
{
"name": "A", // Other vehicles
"row": 0,
"col": 3,
"length": 2,
"orientation": "H"
}
// ... more vehicles
]
}
mapN.json in the src/maps/ directoryGame settings are stored in src/config/config.json:
{
"TITLE": "Rush Hour Game - Introduction to AI",
"WINDOW_SIZE": [900, 600],
"BG_COLOR": [30, 30, 30],
"SCENES": {
"MENU": "menu",
"PLAY": "play",
"HELP": "help",
"QUIT": "quit"
},
"MAPS": ["1", "2", "3", "4", "5", "Random"],
"ALGORITHMS": ["BFS", "DFS", "UCS", "A*"],
"CELL_SIZE": 60,
"MARGIN": 20,
"FPS": 60,
"TIME_LIMIT": 30
}
The game displays real-time performance statistics:
We welcome contributions! Here's how you can help:
git checkout -b feature/amazing-featuregit commit -m 'Add amazing feature'git push origin feature/amazing-featureThis project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2025 Nhan Pham Thanh
Permission is hereby granted, free of charge, to any person obtaining a copy
o