I Built a Game Where You Can Watch AI Think (And It’s Weirdly Satisfying)

Thank you for reading this post, don't forget to subscribe!

You know that feeling when you’re trying to learn something new and the teacher just says “trust me, it works”? Yeah, I hate that too.

So I built a game that does the opposite. It’s a little AI agent learning to navigate a grid, and you can see exactly what’s going through its digital brain at every single moment. No black boxes. No “just trust the algorithm.” Just pure, transparent learning happening right in front of your eyes.

Why Did I Make This?

Honestly? I was tired of AI feeling like magic.

Everyone talks about machine learning like it’s this mysterious wizard thing that only PhD students can understand. But it’s not! It’s just… math. Math that makes decisions based on experience. Like how you learn not to touch a hot stove, but nerdier.

I wanted to make something where you could literally watch an AI make mistakes, learn from them, and slowly get better. Like watching a baby learn to walk, except the baby is blue circle on a grid and instead of crying it just updates some numbers.

What Actually Happens

Picture this: You’ve got a little blue dot (our AI agent) trying to reach a green square (the goal). There are some red obstacles in the way. The agent has no idea what to do at first.

So what does it do? It flails around randomly. Bumps into walls. Takes the long way. Makes objectively terrible decisions.

But here’s the magic part — on the right side of the screen, you can see its “thought process”:

– “Hmm, I could go UP, DOWN, LEFT, or RIGHT…”

– “I think UP is worth about 2.5 points based on what I’ve learned”

– “But I’m in EXPLORING mode, so… let’s try LEFT randomly!”

– “Oh no, I hit a wall. That was bad. -50 points.”

– “Updating my memory: LEFT from here = bad idea”

It’s weirdly mesmerizing. Like watching someone do a crossword puzzle but they’re terrible at it and you can see all their wrong guesses.

The Cool Part (Exploration vs. Exploitation)

There’s this thing in AI called the “exploration vs. exploitation” problem, which sounds fancy but it’s basically:

Do I try new stuff (explore) or stick with what I know works (exploit)?

It’s like when you go to a restaurant:

Explore: Try that weird-sounding dish you’ve never had

Exploit: Order your favorite burger for the 47th time

Too much exploration and you’re just randomly guessing forever. Too much exploitation and you never discover anything better. The trick is balancing them.

In my game, you can literally control this balance with a keypress and watch how it changes the AI’s behavior. Set it to 100% exploration? The agent goes full chaotic energy, trying random stuff even when it knows the right path. Set it to 0%? It commits hard to the first strategy it finds, even if it’s terrible.

It’s like giving the AI different personalities and watching them solve the same puzzle.

What People Learn From This

I’ve shown this to a few friends (some tech folks, some not) and the reactions have been great:

Tech people: “Oh! So THAT’S what Q-learning actually looks like! I’ve read about it but never *seen* it.”

Non-tech people: “Wait, so AI is just… trying stuff and remembering what worked? That’s it?”

Yes! That’s basically it! Obviously there’s more complexity when you get into neural networks and GPT-level stuff, but the core idea is the same: try things, get feedback, update your strategy, repeat.

The “Transparency Mode” Button

My favorite feature is the transparency mode (press T in the game). It shows you the actual formula:

“`

Q(s,a) ← Q(s,a) + α[r + γ max(Q(s’,a’)) – Q(s,a)]

“`

Which looks scary, but then it translates it to:

> “I’m adjusting my confidence in this action because the outcome was different than expected.”

See? Math is just English with extra steps.

Breaking It Is Fun Too

Want to know the best way to understand something? Break it.

– Set the learning rate super high? The AI becomes impulsive, changing its mind constantly.

– Set it super low? It’s stubborn, barely learning anything new.

– Give it negative rewards for reaching the goal? It actively avoids success. You’ve created a lazy AI.

Somehow, watching an AI fail spectacularly because you gave it terrible settings is incredibly educational. You understand why these parameters matter because you’ve seen them go wrong.

It’s Not Just For Nerds

I built this thinking it would be for people learning AI/ML. But honestly? I think it’s for anyone who’s curious about how things work.

My friend’s 12-year-old kid played with it for 20 minutes, kept saying “why is it so dumb?” and then gradually started saying “oh wait, it’s getting better!” That’s the moment. That’s when you get it.

You don’t need to understand the math. You just need to watch the blue dot bump into walls a few times and then suddenly start taking smart paths. It clicks.

Why This Matters

We’re living in this weird era where AI is everywhere but nobody understands it. ChatGPT writes emails, algorithms recommend videos, AI approves loans and it all feels like black magic.

But it’s not magic. It’s just incredibly fast trial and error with good memory.

When you see it happen step-by-step, when you can pause it and go “okay, it chose LEFT because the number for LEFT was highest,” it demystifies the whole thing.

And honestly? I think we need more of that. More “here’s exactly what’s happening” and less “trust the algorithm.”

Try It Yourself

I put the code on GitHub (it’s like 400 lines of heavily commented Python). You need pygame and about 5 minutes.

Run it. Pause it. Step through it frame-by-frame. Crank up the exploration rate and watch it go bananas. Set the speed to max and watch it speedrun the learning process.

And if you’re a teacher or a parent or just someone who likes explaining things, show it to someone. Watch their face when they realize the AI is just… guessing and checking. Really fast guessing and checking, but still.

Final Thoughts

I’m not saying this little grid game will make you an AI expert. But it might make AI feel less like alien technology and more like… a pretty clever way to solve problems using math.

Plus it’s oddly satisfying to watch numbers go up when the AI does something smart. It sparks the same part of my brain that likes watching progress bars fill up.

If you build it, let me know what you think. Or if you break it in a hilarious way. Or if you show it to someone and they have that “ohhh!” moment.

Because that’s why I made this. Not for the code. For that moment when AI stops being mysterious and starts making sense.

*Built with Python, Pygame, and a desire to make AI less weird. MIT license. Go wild with it.*

https://github.com/KemalYaylali/pygame_ai

UPDATE to v2.0.0

https://github.com/KemalYaylali/pygame_ai/releases/tag/v2.0.0

By Kemal

A bioprocess engineer, modeler, machine learning dreamer.