Performance Report
Performance Report
Introduction
This report analyzes the performance of different pathfinding algorithms implemented in the
AI-controlled Snake Game. The goal of the AI is to navigate a snake through a grid, avoid obstacles,
and reach the food as efficiently as possible. The algorithms evaluated are BFS, DFS, IDS, UCS,
Greedy BFS, A*, and Random Movement.
Game Setup
- Grid Size: 20x20
- Levels Tested:
- Level 0: No obstacles
- Level 1: Low obstacle density
- Level 2: Medium obstacle density
- Level 3: High obstacle density
- Timer: 30 seconds per game
- Metrics Evaluated: Time Taken, Moves Taken, Success Rate, Path Optimality
Performance Comparison
| Algorithm | Avg. Time (ms) | Avg. Moves | Success Rate (%) | Path Optimality |
|-----------|--------------|------------|------------------|----------------|
| BFS | XX ms | XX moves | XX% | Optimal |
| DFS | XX ms | XX moves | XX% | Suboptimal |
| IDS | XX ms | XX moves | XX% | Optimal |
| UCS | XX ms | XX moves | XX% | Optimal |
| Greedy BFS| XX ms | XX moves | XX% | Sometimes suboptimal |
| A* | XX ms | XX moves | XX% | Optimal |
| Random | XX ms | XX moves | XX% | Worst |
Observations
1. BFS, IDS, UCS, and A* consistently find the shortest path.
2. DFS is inefficient because it explores deeper paths first, leading to unnecessary moves.
3. Greedy BFS is fast but can take a suboptimal path due to its heuristic.
4. Random Movement is unreliable and often fails to reach the food.
5. A* is the best algorithm overall, balancing speed and optimality.
Best Algorithm
A* Search performed the best in terms of speed, success rate, and path optimality.
Conclusion
- If efficiency is the priority, A* is the best choice.
- If shortest path is the only goal, BFS, UCS, and IDS work well but may take longer.
- Greedy BFS is a decent alternative if speed is more important than optimality.
- DFS and Random Movement should be avoided for AI-controlled pathfinding.
Submission Contents
- Modified `search_algorithms.py` with all implemented algorithms
- This report (`Performance_Report.pdf`)