Pac-Man BFS AI is a grid-based game where the player controls Pac-Man, avoiding ghosts while collecting pellets. The ghosts use a Breadth-First Search (BFS) algorithm to find the shortest path to Pac-Man.
- Grid-Based Movement: Pac-Man moves using arrow keys within a 20x12 grid.
- BFS AI for Ghosts: Ghosts dynamically find the shortest path to Pac-Man using the BFS algorithm.
- Scoring System: Players gain points by collecting pellets placed randomly on the grid.
- Game Over Mechanic: The game ends if a ghost reaches Pac-Man.
- Reset Functionality: Players can reset the game anytime to start fresh.
- Arrow Keys: Move Pac-Man up, down, left, or right.
- Reset Button: Restart the game.
- React.js: UI framework
- Framer Motion: Animations
- JavaScript: Game logic and state management
- BFS explores all possible moves level by level.
- Guarantees the shortest path from the ghost to Pac-Man.
- Ghosts update their position every 300ms based on the BFS pathfinding.
A grid-based visualizer demonstrating the A* pathfinding algorithm. Users can set a start and end point, and the algorithm finds the shortest path while avoiding obstacles.
- Dynamic Grid: A 25x60 grid where users can define obstacles.
- A Algorithm Implementation*: Uses heuristics (Manhattan Distance) for optimal pathfinding.
- Step-by-Step Visualization: Animates the pathfinding process in real-time.
- Diagonal Movement Support: Allows both cardinal and diagonal movements.
- Calculates
g(n)
(distance from start node) andh(n)
(estimated distance to target). - Uses
f(n) = g(n) + h(n)
to determine the best path. - Explores nodes in order of lowest
f(n)
value, ensuring optimal path selection.
- React.js: UI framework
- Framer Motion: Smooth animations
- JavaScript: Algorithm implementation and state handling
- Clone the repository:
git clone https://github.com/bunnysunny24/Searching_techniques.git
- Navigate to the project directory:
cd your-project-folder
- Install dependencies:
npm install
- Run the application:
npm start
- Open
http://localhost:3000/
in your browser.
- Improved AI for Ghosts: Implement A* for more dynamic ghost movement.
- Customizable Grid Size: Allow users to modify the grid dimensions.
- Obstacle Placement in Pac-Man: Add walls for more complex paths.
This project is open-source and available under the MIT License.