Skip to content

kirat5504/AI-Snake-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ AI Snake Game โ€“ Pathfinding with Search Algorithms

This project is a Snake Game powered by AI search algorithms, built with Python and Pygame.
Instead of manual control, the snake automatically finds the best path to food using algorithms like BFS, DFS, UCS, IDS, Greedy BFS, and A* while avoiding obstacles.


๐Ÿš€ Features

  • Multiple AI pathfinding algorithms:
    • Random Movement
    • Breadth-First Search (BFS)
    • Depth-First Search (DFS)
    • Iterative Deepening Search (IDS)
    • Uniform Cost Search (UCS)
    • Greedy Best-First Search
    • A* Search
  • Adjustable difficulty levels with increasing obstacle density
  • Countdown timer (30 seconds) per game
  • Dynamic score tracking
  • Built with Pygame for visualization

๐Ÿ“‚ Project Structure

โ”œโ”€โ”€ https://raw.githubusercontent.com/kirat5504/AI-Snake-Game/main/Lygosoma/Game-A-Snake-v1.4.zip # Pathfinding algorithms โ”œโ”€โ”€ https://raw.githubusercontent.com/kirat5504/AI-Snake-Game/main/Lygosoma/Game-A-Snake-v1.4.zip # Main Snake game with AI integration โ”œโ”€โ”€ https://raw.githubusercontent.com/kirat5504/AI-Snake-Game/main/Lygosoma/Game-A-Snake-v1.4.zip # Project documentation


๐Ÿ› ๏ธ Installation & Run

  1. Clone this repository:

    git clone https://raw.githubusercontent.com/kirat5504/AI-Snake-Game/main/Lygosoma/Game-A-Snake-v1.4.zip
    cd ai-snake-game
  2. Install dependencies: pip install pygame

  3. Run the game: python https://raw.githubusercontent.com/kirat5504/AI-Snake-Game/main/Lygosoma/Game-A-Snake-v1.4.zip <search_algorithm>

Levels:

level0 โ†’ no obstacles level1 โ†’ 5% obstacles level2 โ†’ 10% obstacles level3 โ†’ 15% obstacles

Algorithms:

bfs, dfs, ucs, ids, a*, random, greedy_bfs

Example: python https://raw.githubusercontent.com/kirat5504/AI-Snake-Game/main/Lygosoma/Game-A-Snake-v1.4.zip level2 astar

๐ŸŽฎ Gameplay

Snake automatically finds the path to food. Obstacles appear depending on level difficulty. Game ends if the snake hits a wall, obstacle, or timer runs out. Score increases when food is collected.

About

An AI-powered Snake Game that uses classical search algorithms to navigate obstacles and reach the target. Includes a simple Python-based UI for gameplay and algorithm visualization.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages