You are on page 1of 11

Project Report

Data Structures and Algorithm

Group Members:
Saad Ali - AD-CS01016
Kashan Ashraf - AD-CS01030
Faizan Afzal - AD-CS01006

Submitted To: Respected Sir Abdul Salam


1. Project Title:
Pathfinding Visualization with Pygame

2. Abstract:
This project focuses on creating an interactive visualization of pathfinding
algorithms using Pygame. The primary goal is to develop a user-friendly tool that
allows users to understand and observe the A* pathfinding algorithm in action.

3. Introduction:
Pathfinding is a fundamental concept in computer science and robotics. This
project aims to provide a visual representation of the A* algorithm, a widely used
pathfinding algorithm, using the Pygame library for graphical rendering.

Below are the objects we used in it :

Selection :
Roomba:

Map:
4. Objectives:
Implement A* algorithm for pathfinding.
Develop an interactive graphical interface using Pygame.
Visualize the algorithm's execution in real-time.
Allow users to interactively create obstacles and observe path recalculations.

5. Methodology:
The project utilizes Pygame for graphical rendering and interaction. The A*
algorithm is employed for pathfinding on a grid-based map.

6. System Architecture:
6.1. Pathfinder Class:
Handles initialization and cleanup of the grid.
Implements the A* algorithm for pathfinding.
Provides methods for drawing the active cell and creating/updating the path.
6.2. Roomba Class:
Represents the Roomba sprite that follows the generated path.
Manages the creation of collision rectangles and updates Roomba's position.
6.3. Main Game Loop:
Initializes Pygame and sets up the game window.
Handles user input to create new paths.
Updates the screen with the background, grid, and Roomba's path.
6.4. Grid and Map:
The grid is represented by a matrix of 0s and 1s.Background is loaded from
'map.png', and sprites are loaded from 'selection.png' and 'roomba.png'.
7. Implementation Details:
Detailed code snippets and explanations can be found in the attached source
code.
(1)

(2)
(3)

(4)
(5)

(6)
(7)

(8)
8. Results:
Screenshots:

Initial Stage:
Half Way Stage:

Final Stage:
The A* algorithm successfully finds the optimal path.

Real-time visualization aids in understanding the pathfinding process.


9. Challenges and Solutions:
Challenges:
Fine-tuning Roomba's movement along the path.
Ensuring accurate collision detection.
Solutions:
Implemented vector-based movement for smoother Roomba traversal.
Adjusted collision rectangles to accurately match grid positions.

10. Conclusion:
The project successfully implements a grid-based pathfinding visualization tool
using Pygame. It provides a user-friendly platform for understanding the A*
algorithm and lays the foundation for future enhancements.

12. References:
Pygame Documentation: https://www.pygame.org/doc/
A* Algorithm Overview: https://en.wikipedia.org/wiki/A*_search_algorithm
13. Acknowledgments:
Special thanks to the Pygame development community for their valuable
contributions.

You might also like