A modern React application that compares A* and Beam Search algorithms for solving Sudoku puzzles with real-time visualization and performance analytics.
- 🧠 Real Python AI Algorithms: Uses actual A* and Beam Search implementations
- 🎨 Modern UI: Beautiful dark/light mode with glass morphism effects
- 📊 Real-time Visualization: Watch algorithms solve puzzles step-by-step
- 📈 Performance Analytics: Compare algorithm efficiency and success rates
- 🎯 Multiple Difficulties: Easy, Medium, Hard, and Impossible levels
- 🔄 Live Step Tracking: See each move highlighted on the puzzle grid
- Node.js 18+
- Python 3.8+
- npm or yarn
-
Clone and install dependencies: ```bash npm install ```
-
Set up Python environment (optional but recommended): ```bash python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt ```
-
Run the development server: ```bash npm run dev ```
-
Open your browser: Navigate to
http://localhost:3000
The application uses a hybrid approach:
- Frontend: Modern React with TypeScript and Tailwind CSS
- Backend API: Next.js API route (
/api/solve) that calls Python scripts - Python Algorithms: Real A* and Beam Search implementations in
/algorithms/ - Fallback: JavaScript simulation if Python execution fails
algorithms/astar_solver.py- A* algorithm implementationalgorithms/beam_search_solver.py- Beam Search algorithm implementationalgorithms/solver_api.py- API bridge between React and Python
```typescript // Call the Python algorithms const response = await fetch('/api/solve', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ grid: sudokuGrid, algorithm: 'astar' // or 'beam' }) }) ```
- ✅ Optimal solutions guaranteed
- ✅ High success rate
- ❌ Higher memory usage
- ❌ Slower execution time
- ✅ Fast execution
- ✅ Memory efficient
- ❌ May not find optimal solution
- ❌ Lower success rate on hard puzzles
If you get Python execution errors:
- Ensure Python 3.8+ is installed and in your PATH
- Try changing
python3topythoninapp/api/solve/route.ts - Check that the algorithms folder has proper permissions
The app automatically falls back to JavaScript simulation if Python fails, so the UI will always work.
- Create new Python solver in
/algorithms/ - Update
solver_api.pyto handle the new algorithm - Add algorithm option to the React frontend
- Modify animation timing in
components/sudoku-game.tsx - Adjust step highlighting in the
getCellClassNamefunction - Update color schemes in
app/globals.css
- Python algorithms run server-side for security
- Results are cached for identical puzzles
- Visualization speed can be adjusted in the code
- Memory usage scales with puzzle difficulty
MIT License - feel free to use and modify!