Mastering Chrome Dino with AI

Techiral
3 min readJul 11, 2024

--

Dino Trying To Avoid Obstacles

Hey there, fellow gamers and AI enthusiasts! Remember when we cracked Flappy Bird with AI? Well, get ready for our latest adventure: Chrome Dino — that addictive game that appears when your Wi-Fi decides to take a break.

Building the Game from Scratch

Let’s kick things off by setting the stage. Picture a smoothly scrolling ground and our tiny, pixelated T-Rex buddy, ready to jump into action. After a few tweaks and tests, voilà! Our dino is bouncing around like a rubber ball, reacting to every tap of the spacebar.

To amp up the challenge, we’ve thrown in some diverse obstacles — tall cacti, short cacti, and pesky flying birds (because why make it easy, right?). Plus, we’ve got a nifty score counter ticking away, keeping track of our dino’s progress.

Enter the AI Revolution

Now, here comes the real magic — Artificial Intelligence. For this project, we’re harnessing the power of NEAT (Neuroevolution of Augmenting Topologies). Think of it as starting with a virtual dino army — 250 strong, each with its neural network brain. These dinos aren’t just mindlessly jumping; they’re learning and adapting through generations.

In the beginning (generation 1), our dinos are clueless — jumping randomly and often crashing into obstacles. But by generation 4, they start to grasp the basics. Jumping over cacti becomes more consistent, though still a bit clumsy. Fast forward to generation 19, and our dino squad is hopping like seasoned pros, gracefully dodging obstacles with precision.

The Neural Network Behind the Scenes

Here’s the tech talk: Each dino’s brain is fed with crucial game data — its current position, the location and type of upcoming obstacles, and the game’s speed. This data helps the neural network make split-second decisions: jump, duck, or stay put. It’s like teaching them to think strategically in real time.

Why This Matters

You might wonder, why bother teaching AI to play a simple browser game? Well, beyond the fun and gaming glory, projects like these push the boundaries of AI. They help us explore how neural networks can learn from experience, adapt to dynamic environments, and make decisions autonomously — skills crucial for AI applications in robotics, autonomous vehicles, and more.

Visuals and GitHub Link

Curious to see it in action? Check out this video where I walk you through the process and showcase our evolving dino AI in action.

And hey, if you’re itching to dive deeper or try this out yourself, head over to my GitHub repository. There, you’ll find all the code, from the game engine to the AI training scripts, ready for you to explore and experiment.

Conclusion

Mastering Chrome Dino with AI isn’t just about beating a game; it’s about exploring the potential of AI in a fun and engaging way. Whether you’re a gamer, a tech enthusiast, or both, this project highlights the exciting possibilities when AI meets gaming.

So, what’s next? Stay tuned for more AI adventures, and don’t forget to smash that like button and subscribe for more updates. Let’s keep pushing the boundaries of what AI can achieve — one game at a time!

--

--