S ScienceFairProjects.info
Hard⏱ time3 hr$ cost0

Self-Playing Snake

Give the snake game a simple AI that chases food and avoids walls on its own.

Start building ↓
fig — working model Result first

The build

Step 01

Build the game

Make a basic snake game.

Step 02

Add a goal

Locate the food each step.

Step 03

Plan a path

Steer toward food while avoiding the body.

Step 04

Auto-play

Let the AI run the snake.

Working Principle

Each step the AI picks the direction that moves toward the food without hitting a wall or its own body.

The science behind it

A closer look

It's greedy pathfinding; smarter versions use search (like BFS) to avoid trapping themselves.

Take it further

Variables to test

  • 1 Upgrade to BFS pathfinding — fewer deaths?
  • 2 How long a snake can it survive?

More AI