Back to Blog
·Jan Tyl·3 min read

Snake AI Extreme Edition: a snake that is not guided by chance

The new Antigravity agent wrote a simple autonomous game for me in 16 seconds on my first try. It looks like a neon neural network from the retro future, but under the hood runs honest algorithms: BFS, tail chasing and flood fill.

Snake AI Extreme Edition: a snake that is not guided by chance

I'm testing the new Antigravity agent. On the first try, he wrote me a simple game in 16 seconds.

That's not so bad.

The result looks a bit like a neon neural network from the retro future: a terminal disguised as a mobile display, a green snake, an apple, particles, screen shakes and 8-bit sounds generated directly in Python.

But the most interesting thing is not the appearance. The most interesting thing is what happens under the hood.

Snake AI Extreme Edition jako neonová retro terminálová hra

The snake is not random

This snake doesn't follow by chance. Each step is calculated using classical algorithms.

BFS, Breadth-First Search, looks for the shortest safe path to the apple. When the path is clear, the snake goes straight for the target.

Tail chasing starts when the path to the apple would be risky. The snake prefers to follow its own tail and wait for a better position. It's a surprisingly elegant trick: instead of chasing a reward, it maintains space to live.

Flood fill is used in more difficult situations. The agent calculates in which direction it has the most free space so as not to get trapped.

These are all good old algorithms. No magic. No neural network. And yet the resulting behavior looks almost intelligent.

So is it AI?

It depends on how strict we want to be.

It's not a neural network. The name NEURAL NETWORK HAD-2000 is purely a business/arcadesticker because it sounds significantly better than BFS + Flood Fill had.

But at the same time, it is an agent that perceives the state of the environment, evaluates options, optimizes risk and acts autonomously. So in a practical sense, it does exactly what we want a small game agent to do.

Only instead of "guessing" something, he just calculates it.

What I enjoy about it

This is a small thing. Exercises. A pun.

But at the same time, it is beautiful to see how programming is changing. Previously, one would sit at a prototype like this in the evening, tweaking rendering, game looping, collisions, scores, and snake behavior. Today, all it takes is a good input, a few iterations, and something usable as a foundation is created in minutes.

Not because AI will replace thinking. Rather, because it removes the friction between the idea and the first functional form.

And then comes the fun part: deciding what to make of it.

A small terminal game? Algorithm tutorial? A retro mobile arcade? Or just a reminder that programming can be a bit of a game again?

It's the last one for me.

Just because an agent builds an autonomous snake in 16 seconds doesn't mean it's game over. It means that the start is suddenly almost free.

And that's good news for everyone who has more ideas than time.

Související články