- App
- Nav
- Grid
- Tile
- Select
- PlayButton
- Footer
- PathFindingContext
- SpeedContext
- TileContext
- usePathFinding
- useSpeed
- useTile
- constants
- helpers
- resetGrid
- animatePath
- PathFinding Algorithms
- BFS
- DFS
- Dijkstra
- Maze Generation Algorithms
- Recursive Division
- Binary Tree
The Pathfinding Visualizer is a web application that allows users to visualize various pathfinding algorithms and maze generation techniques. It provides an interactive grid where users can place start and end points, walls, and see the algorithms in action. I chose Vite as a tool to work with React because it provides fast and efficient development experience for web apps. It found it easy to configure, providing a simple and intuitive configuration system.
App.tsx
- The main component that wraps the entire application with necessary providers and renders the main layout including the navigation bar, grid, theme switch, and footer.
Nav.tsx
- The navigation component that includes UI elements for selecting a maze, pathfinding algorithm, speed, and a play button to run the visualizer.
Grid.tsx
- The grid component that renders the grid of tiles. It handles mouse events for placing walls and updating the grid state.
Tile.tsx
- The tile component that represents a single cell in the grid. It handles mouse events and updates its appearance based on its state.
Select.tsx
- A reusable select component that displays a dropdown menu with options.
PlayButton.tsx
- A button component that starts the pathfinding visualization.
PathFindingContext.tsx
- Provides the state and functions related to pathfinding algorithms and the grid.
SpeedContext.tsx
- Provides the state and functions related to the speed of the visualization.
TileContext.tsx
- Provides the state and functions related to the start and end tiles.
usePathFinding.ts
- A custom hook that provides access to the pathfinding context.
useSpeed.ts
- A custom hook that provides access to the speed context.
useTile.ts
- A custom hook that provides access to the tile context.
constants.ts
- Defines constants used throughout the application, including algorithm options, maze options, tile styles, and speed settings.
helpers.ts
- Provides helper functions for common tasks such as creating a new grid and checking if a tile is a start or end tile.
resetGrid.ts
- Resets the grid to its initial state.
animatePath.ts
- Animates the pathfinding process by updating the grid state over time.
Pathfinding Algorithms:
bfs.ts
- Implements the Breadth-First Search algorithm for finding the shortest path in an unweighted graph.
dfs.ts
- Implements the Depth-First Search algorithm for exploring nodes by going as deep as possible along each branch before backtracking.
dijskstra.ts
- Implements Dijkstra's algorithm for finding the shortest path in a weighted graph.
Maze Generation Algorithms
recursiveDivision.ts
- Implements the Recursive Division algorithm for generating mazes by recursively dividing the grid into smaller sections.
binaryTree.ts
- Implements the Binary Tree algorithm for generating mazes by randomly carving passages in a grid.
- Install Dependencies
- npm install
- Start the dev server
- npm start
- Build for Production
- npm run build
- Run tests:
- npm test