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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
---
|
| 4 |
+
Here's a comprehensive Hugging Face Model Card for your Interactive PyQt5 A* Algorithm Game:
|
| 5 |
+
|
| 6 |
+
```markdown
|
| 7 |
+
---
|
| 8 |
+
language:
|
| 9 |
+
- en
|
| 10 |
+
tags:
|
| 11 |
+
- game
|
| 12 |
+
- pathfinding
|
| 13 |
+
- algorithm
|
| 14 |
+
- a-star
|
| 15 |
+
- pyqt5
|
| 16 |
+
- visualization
|
| 17 |
+
- educational
|
| 18 |
+
- interactive
|
| 19 |
+
- python
|
| 20 |
+
widget:
|
| 21 |
+
- video_path: demo.mp4
|
| 22 |
+
example_title: A* Algorithm Demo
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
# Interactive A* Pathfinding Algorithm Game
|
| 26 |
+
|
| 27 |
+
## Model Overview
|
| 28 |
+
|
| 29 |
+
An interactive educational game that visually demonstrates the A* pathfinding algorithm using PyQt5. This application provides a hands-on way to understand how one of the most popular pathfinding algorithms works through real-time visualization.
|
| 30 |
+
|
| 31 |
+
## What is A* Algorithm?
|
| 32 |
+
|
| 33 |
+
A* (A-Star) is a graph traversal and path search algorithm that finds the shortest path between nodes. It combines the strengths of Dijkstra's Algorithm (guaranteed shortest path) and Greedy Best-First Search (efficiency) by using both:
|
| 34 |
+
|
| 35 |
+
- **g(n)**: Actual cost from start node to current node
|
| 36 |
+
- **h(n)**: Heuristic estimated cost from current node to goal
|
| 37 |
+
- **f(n) = g(n) + h(n)**: Total estimated cost
|
| 38 |
+
|
| 39 |
+
## Features
|
| 40 |
+
|
| 41 |
+
### ๐ฎ Interactive Gameplay
|
| 42 |
+
- Set custom start and end positions
|
| 43 |
+
- Place and remove obstacles in real-time
|
| 44 |
+
- Visualize algorithm execution step-by-step
|
| 45 |
+
- Adjustable animation speed
|
| 46 |
+
|
| 47 |
+
### ๐จ Visual Elements
|
| 48 |
+
- **Green**: Start node
|
| 49 |
+
- **Red**: End node
|
| 50 |
+
- **Gray**: Obstacles/walls
|
| 51 |
+
- **Yellow**: Open set (nodes being considered)
|
| 52 |
+
- **Light Red**: Closed set (evaluated nodes)
|
| 53 |
+
- **Blue**: Final optimal path
|
| 54 |
+
|
| 55 |
+
### โ๏ธ Technical Features
|
| 56 |
+
- 20ร20 grid system with 8-directional movement
|
| 57 |
+
- Real-time cost display (g, h, f values)
|
| 58 |
+
- Manhattan distance heuristic
|
| 59 |
+
- Pause/Resume functionality
|
| 60 |
+
- Reset and clear options
|
| 61 |
+
|
| 62 |
+
## Quick Start
|
| 63 |
+
|
| 64 |
+
### Installation
|
| 65 |
+
```bash
|
| 66 |
+
pip install PyQt5
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
### Run the Game
|
| 70 |
+
```bash
|
| 71 |
+
python astar_game.py
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
### Usage Instructions
|
| 75 |
+
1. Select "Start Point" mode and click a grid cell to set start position
|
| 76 |
+
2. Select "End Point" mode and set destination
|
| 77 |
+
3. Use "Obstacles" mode to add walls
|
| 78 |
+
4. Click "Start" to run the algorithm
|
| 79 |
+
5. Watch the visualization and learn!
|
| 80 |
+
|
| 81 |
+
## Educational Value
|
| 82 |
+
|
| 83 |
+
This game is perfect for:
|
| 84 |
+
- ๐ Computer Science students learning algorithms
|
| 85 |
+
- ๐ฎ Game developers implementing pathfinding
|
| 86 |
+
- ๐ Anyone curious about how navigation algorithms work
|
| 87 |
+
- ๐ก Understanding heuristic search methods
|
| 88 |
+
|
| 89 |
+
## Algorithm Details
|
| 90 |
+
|
| 91 |
+
### Heuristic Function
|
| 92 |
+
Uses Manhattan distance: `h(n) = |xโ - xโ| + |yโ - yโ|`
|
| 93 |
+
|
| 94 |
+
### Cost Calculation
|
| 95 |
+
- **Movement Cost**: Euclidean distance between nodes
|
| 96 |
+
- **Total Cost**: f(n) = g(n) + h(n)
|
| 97 |
+
- **Node Expansion**: Always expands node with lowest f(n) first
|
| 98 |
+
|
| 99 |
+
### Key Properties
|
| 100 |
+
- **Complete**: Always finds a solution if one exists
|
| 101 |
+
- **Optimal**: Always finds the shortest path
|
| 102 |
+
- **Efficient**: Explores fewer nodes than Dijkstra's algorithm
|
| 103 |
+
|
| 104 |
+
## File Structure
|
| 105 |
+
```
|
| 106 |
+
astar-game/
|
| 107 |
+
โโโ astar_game.py # Main game implementation
|
| 108 |
+
โโโ requirements.txt # Dependencies
|
| 109 |
+
โโโ README.md # This file
|
| 110 |
+
โโโ demo.mp4 # Demonstration video
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
## Requirements
|
| 114 |
+
|
| 115 |
+
```txt
|
| 116 |
+
PyQt5>=5.15.0
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
## Compatibility
|
| 120 |
+
|
| 121 |
+
- **Python**: 3.6+
|
| 122 |
+
- **OS**: Windows, macOS, Linux
|
| 123 |
+
- **Dependencies**: PyQt5 only
|
| 124 |
+
|
| 125 |
+
## Try It Yourself!
|
| 126 |
+
|
| 127 |
+
### Example Maze Challenge:
|
| 128 |
+
```
|
| 129 |
+
S = Start, E = End, # = Obstacle
|
| 130 |
+
|
| 131 |
+
S . . # . . . . . .
|
| 132 |
+
. # . # . # # # . .
|
| 133 |
+
. # . . . # . . . .
|
| 134 |
+
. # # # . # . # # .
|
| 135 |
+
. . . # . # . # . .
|
| 136 |
+
# # . # . # . # . .
|
| 137 |
+
. . . # . . . # . .
|
| 138 |
+
. # # # # # # # . .
|
| 139 |
+
. . . . . . . . . E
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
Can you predict the path the algorithm will find?
|
| 143 |
+
|
| 144 |
+
## Contributing
|
| 145 |
+
|
| 146 |
+
Feel free to contribute by:
|
| 147 |
+
- Adding different heuristic functions
|
| 148 |
+
- Implementing other pathfinding algorithms
|
| 149 |
+
- Improving the UI/UX
|
| 150 |
+
- Adding level challenges
|
| 151 |
+
|
| 152 |
+
## License
|
| 153 |
+
|
| 154 |
+
This project is open source and available under the MIT License.
|
| 155 |
+
|
| 156 |
+
## Citation
|
| 157 |
+
|
| 158 |
+
If you use this in an educational setting or project, please credit:
|
| 159 |
+
|
| 160 |
+
```bibtex
|
| 161 |
+
@software{astar_pyqt_game,
|
| 162 |
+
title = {Interactive A* Pathfinding Algorithm Game},
|
| 163 |
+
author = {Your Name},
|
| 164 |
+
year = {2024},
|
| 165 |
+
url = {https://huggingface.co/your-username/astar-game}
|
| 166 |
+
}
|
| 167 |
+
```
|
| 168 |
+
|
| 169 |
+
## Related Algorithms
|
| 170 |
+
|
| 171 |
+
- Dijkstra's Algorithm
|
| 172 |
+
- Breadth-First Search (BFS)
|
| 173 |
+
- Depth-First Search (DFS)
|
| 174 |
+
- Greedy Best-First Search
|
| 175 |
+
- Jump Point Search
|
| 176 |
+
|
| 177 |
+
---
|
| 178 |
+
|
| 179 |
+
**Happy pathfinding!** ๐
|
| 180 |
+
```
|
| 181 |
+
|
| 182 |
+
This model card includes all the essential sections that Hugging Face expects:
|
| 183 |
+
|
| 184 |
+
1. **Metadata** (language, tags, widget)
|
| 185 |
+
2. **Overview** and algorithm explanation
|
| 186 |
+
3. **Features** and technical details
|
| 187 |
+
4. **Installation** and usage instructions
|
| 188 |
+
5. **Educational value**
|
| 189 |
+
6. **Technical specifications**
|
| 190 |
+
7. **Compatibility** information
|
| 191 |
+
8. **Interactive examples**
|
| 192 |
+
9. **Citation** template
|
| 193 |
+
10. **Related content**
|
| 194 |
+
|
| 195 |
+
The card is structured to be both informative for technical users and accessible for learners new to pathfinding algorithms. You can save this as `README.md` in your Hugging Face model repository.
|