Skip to content

When AI Fails at the Chrome T-Rex Game

Published: Ā atĀ 05:00 PM

There’s an old programming joke that goes: ā€œWhy spend 5 minutes doing it manually when you can spend an hour automating it?ā€ šŸ˜…

Well, I recently put this to the test in a rather unexpected way. In 2022, during a particularly boring afternoon, I had ā€œhackedā€ Chrome’s T-Rex game with about an hour of my time and a dozen lines of JavaScript. That code still works today, even with the version that includes pterodactyls.

Fast forward to today, and I thought: ā€œWith AI, I can do this in 60 seconds.ā€

Spoiler alert: NO.

So I decided to test various AI models with this prompt:

Create a JavaScript script that automates playing the Chrome T-Rex game by detecting upcoming obstacles and triggering an automatic jump to avoid them.

The results were… underwhelming:

I tried improving the prompt with more specific instructions:

Develop a JavaScript script that automates gameplay of the Chrome T-Rex game by automatically detecting approaching obstacles using in-game element analysis or visual cues, and programmatically triggering jump actions when obstacles are within a specified proximity to prevent collisions.

Ensure the script continuously monitors obstacle positions, calculates the optimal timing for jumps, and interfaces with the game’s event system to simulate game actions seamlessly. Include logic to adapt to varying obstacle speeds and game levels for reliable performance during an active game session.

Keep the code minimal.

Slightly better, but still not reliable. Sometimes it would jump, sometimes it wouldn’t, or it would land too early. In some cases, it would ā€œcheatā€ by landing on obstacles without triggering the Game Over, but the code was still incredibly complex.

I even provided the entire game code in the context window (despite it being freely available online and the models having web access). The result? Even more intricate code that still didn’t work. I finally gave up.

I use AI daily for development and have always found it to be an excellent productivity booster. So I was quite surprised (and admittedly frustrated) that I couldn’t achieve what I had done manually in 2022 with just a few lines of code.

This experiment taught me something valuable about AI’s current limitations:

  1. Over-engineering: AI models tend to overthink simple problems, creating complex solutions when simple ones work better
  2. Context blindness: Even with the full game code, the models couldn’t grasp the simple mechanics
  3. Prompt sensitivity: The quality of results varied dramatically with different prompt formulations
  4. The human touch: Sometimes, a human’s intuitive understanding of a problem beats AI’s analytical approach

My 2022 solution was simple: detect the obstacle’s position, calculate the timing, and trigger a jump. No complex algorithms, just basic geometry and timing. The AI models tried to implement sophisticated obstacle detection, collision prediction, and adaptive timing systems when the problem was fundamentally simple.

While AI is incredibly powerful for many development tasks, it’s not always the best tool for every job. Sometimes the simplest solution—written by a human who understands the problem intuitively—is still the most effective.


If anyone manages to find a prompt that actually solves this problem (and produces decent code), let me know! šŸ¦–