Skip to content

Latest commit

ย 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ RetroSnake AI

RetroSnake AI transforms the classic Snake game into an intense battle between human reflexes and artificial intelligence. Players compete against an AI-controlled snake powered by A Pathfinding, heuristic survival logic, and real-time decision making โ€” creating a strategic and competitive arcade experience rather than a traditional snake clone.*


๐ŸŽฎ Screenshots

Main Menu

WhatsApp Image 2026-05-25 at 18 25 01

Gameplay

WhatsApp Image 2026-05-25 at 18 25 00

Pause / Settings Menu

WhatsApp Image 2026-05-25 at 18 24 59 WhatsApp Image 2026-05-25 at 18 24 59 (1)

Game Over Screen

WhatsApp Image 2026-05-25 at 18 41 15

๐Ÿง  About The Project

RetroSnake AI is not just another snake game.

This project was designed to combine:

  • Classic retro snake gameplay
  • Artificial Intelligence
  • Real-time pathfinding
  • Survival-based decision making
  • Android game development
  • Dynamic UI interactions

Unlike traditional snake games where enemies move randomly, the AI snake in RetroSnake intelligently calculates the safest and shortest possible route using the A* Pathfinding Algorithm along with additional survival heuristics to avoid self-destruction.

The project was fully developed in Kotlin using Android Studio and includes custom rendering, game loops, touch handling, AI movement systems, settings management, sound systems, and animated UI components.


โœจ Features

๐Ÿค– Intelligent AI Snake

  • Uses A* Pathfinding Algorithm
  • Dynamically recalculates paths
  • Avoids obstacles and collisions
  • Prevents self-trapping situations
  • Competes against player in real time

๐Ÿงฌ Advanced Survival Logic

Along with A* pathfinding, additional logic was integrated to improve AI survival:

  • Safe movement validation
  • Collision prediction
  • Escape route checking
  • Future path estimation
  • Heuristic-based danger analysis
  • Suicide prevention logic

This makes the AI behave more intelligently than traditional snake implementations.


๐ŸŽจ Retro Styled UI

  • Neon green retro theme
  • Smooth animations
  • Arcade-inspired visuals
  • Responsive game rendering
  • Custom drawn canvas components

โš™๏ธ In-Game Customization

Players can:

  • Change snake color
  • Change player name
  • Toggle music
  • Pause/resume gameplay
  • Access help/how-to-play screens

๐Ÿ”Š Sound System

Integrated:

  • Background music
  • Eating sound effects
  • Death sound effects

Using:

  • SoundPool
  • MediaPlayer

๐Ÿ“ˆ Multiple Difficulty Levels

Different levels modify:

  • Snake speed
  • AI aggressiveness
  • Gameplay intensity

๐Ÿ› ๏ธ Technologies Used

Technology Purpose
Kotlin Core Android Development
Android Studio Development Environment
A* Algorithm AI Pathfinding
Canvas API Custom Rendering
SoundPool Sound Effects
MediaPlayer Background Music
SharedPreferences Saving Settings
HTML Asset Page Home/Menu Integration

๐Ÿง  AI System Explained

The enemy snake uses the A* algorithm to calculate the most efficient path toward food.

The algorithm evaluates:

  • Current snake position
  • Food position
  • Obstacles
  • Snake body positions
  • Future movement possibilities

Heuristic Used

The project primarily uses:

  • Manhattan Distance Heuristic

Formula:

h(n) = |x1 - x2| + |y1 - y2|

This helps the AI efficiently estimate the shortest route on a grid-based map.


๐Ÿงฉ Project Structure

app/
โ”‚
โ”œโ”€โ”€ AStarPathfinder.kt      โ†’ AI pathfinding logic
โ”œโ”€โ”€ GameEngine.kt           โ†’ Core game mechanics
โ”œโ”€โ”€ GameView.kt             โ†’ Rendering + touch handling
โ”œโ”€โ”€ MainActivity.kt         โ†’ Android activity controller
โ”œโ”€โ”€ gamelevel.kt            โ†’ Difficulty management
โ”‚
โ”œโ”€โ”€ assets/
โ”‚   โ””โ”€โ”€ index.html          โ†’ HTML home screen
โ”‚
โ”œโ”€โ”€ res/
โ”‚   โ”œโ”€โ”€ drawable/           โ†’ UI assets
โ”‚   โ”œโ”€โ”€ raw/                โ†’ Sound files
โ”‚   โ””โ”€โ”€ values/             โ†’ Themes/colors/strings

๐ŸŽฏ Core Gameplay Mechanics

Player Snake

  • Controlled through touch gestures
  • Collects food to grow
  • Dies on collision

AI Snake

  • Searches optimal food path
  • Avoids dangerous routes
  • Competes with player

Collision Detection

Handles:

  • Wall collision
  • Self collision
  • AI collision
  • Head-to-head interaction

๐Ÿ”ฅ What Makes This Different?

Unlike common snake games such as:

  • Snake.io
  • Slither.io
  • Worms Zone

RetroSnake AI focuses heavily on:

  • Algorithmic intelligence
  • AI survival strategies
  • Real-time pathfinding
  • Educational AI implementation
  • Offline single-player AI competition

This project behaves more like an AI simulation than a casual snake clone.


๐Ÿ“š Learning Outcomes

Through this project:

  • Advanced pathfinding algorithms were implemented
  • Android game loops were developed
  • Real-time rendering systems were created
  • AI decision-making systems were explored
  • Mobile UI/game integration was achieved

๐Ÿš€ Future Improvements

  • Multiplayer mode
  • Machine Learning based AI
  • Online leaderboard
  • Procedural obstacles
  • Dynamic maps
  • Genetic Algorithm based learning AI
  • Reinforcement Learning integration

โ–ถ๏ธ How To Run

Clone Repository

git clone YOUR_REPOSITORY_LINK

Open In Android Studio

  • Open project folder
  • Sync Gradle
  • Run on Emulator or Android Device

โญ If You Like This Project

Give this repository a โญ on GitHub and support the project.

About

Classic Snake reinvented as a strategic human vs AI battle using A* Pathfinding, intelligent survival heuristics, and retro arcade gameplay.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages