Ds 1
Ds 1
Submitted by
Submitted to K.VARSHITHA
Ms.Vedavathi. K
Assistant Professor
( 23261A05G0 )
CSE, dept. K.NAVADEEP
( 23261A05G1 )
K.JAYANTH
( 23261A05G2 )
TABLE OF CONTENTS
DATA STRUCTURE
● Language used: ALGORITHM USE CASE
EXIT LOOP:
• Once the loop ends ( the player quits or reaches the goal ),destroy the render and window.
• Quit SDL (SDL_Duit).
TIME COMPLEXITY
Update IF new
Calculate
player position is
Clear the new position ELSE IF key Set running IF event is
position valid (not out
screen (newX, is pressed: to false SDL_QUIT:
(playerX, of bounds and
newY)
playerY) not a wall):
Cleanup SDL
resources Delay for Print "You've
Present the Set running
Quit SDL (Destroy frame rate
renderer to false
reached the
window and control goal!"
renderer)
IMPLEMENTATION OF THE CODE
1. HEADER FILES AND CONSTANTS
• #include <SDL2/SDL.h> :This includes the core SDL2 library, which provides functions for
handling graphics, events, and window management.
• #include <SDL2/SDL_main.h> :This includes the SDL2 main library, which is necessary for
initializing SDL and handling the entry point of the application (for certain platforms).
• #include <stdio.h> : Standard library for input and output functions, like printf for debugging.
• #include <stdbool.h>: Includes support for boolean data types (true, false), which is useful
for logic control.
2. CONSTANTS DEFINATIONS
• WINDOW_WIDTH and WINDOW_HEIGHT: Set the dimensions of the window where the
game will be displayed (640x480 pixels).
• TILE_SIZE: Defines the size of each tile (32x32 pixels), which makes it easy to manage the
grid-based maze layout.
• MAZE_ROWS and MAZE_COLS: Define the number of rows and columns in the maze (15
rows and 20 columns in this case).
3. MAZE LAYOUT
4. PLAYER POSITION
• playerX and playerY: These variables track the player's position in the maze. The player
starts at the coordinates (1, 1), which is the second tile in the maze.
5. SDL INITIALIZATION
• SDL_Init(SDL_INIT_VIDEO): Initializes
SDL's video subsystem, which is required to
create windows and render graphics.
• The function returns true if all initializations are successful, otherwise returns false and
cleans up resources.
6. INPUT HANDLING
• SDL_PollEvent: Checks for events
such as user input. The function
returns true if an event is found and
processes it.
• Cleanup
Smart Video
Cities Games
APPLICATIONS
GPS and
Healthcare
Navigation
Network
Routing
CONCLUSION
The maze solver program is an excellent demonstration of fundamental concepts in computer
science, including algorithm design, data structures, and problem-solving techniques. By
implementing various maze-solving algorithms like Depth-First Search (DFS), Breadth-First
Search (BFS), and A*, we gain practical insights into how different strategies can be used to
explore paths and find solutions efficiently.
a. Understanding of Algorithms: DFS is effective for exploring any possible path, while BFS
is more suitable for finding the shortest path in unweighted mazes. A* and Dijkstra's
algorithms are best for solving mazes with weighted paths, optimizing for both cost and
efficiency.
b. Practical Applications: Maze-solving techniques are not limited to puzzles but are widely
used in real-world applications such as robotics, game development, network routing, and
GPS navigation.
c. Efficiency Considerations: Choosing the right algorithm is crucial for performance,
especially with larger or more complex mazes. Understanding the time and space
complexities helps in making informed decisions.
d. Learning Outcomes: Implementing these algorithms in a language like C provides a
deeper understanding of low-level memory management and optimization. This project
serves as a strong foundation for exploring more advanced topics in computer science, such
as artificial intelligence and pathfinding in dynamic environments.
The maze solver project not only enhances your coding skills but also equips you with essential
REFERENCES
● https://www.youtube.com/watch?v=zalhUp4ms6c
● https://github.com/edusporto/maze-solver-c/blob/master/maze-solver.c
● https://github.com/edusporto/maze-solver-c
THANK YOU