I Taught Claude Code to Play Tetris... It Broke the World Record

Dr. Violet Howard shows Claude Code, an AI agent, learning to play games in a browser. It taught itself Tetris and scored over 40 million points, breaking the world record. The agent reads game code, writes control scripts, and improves through trial and error.
Chapters
Did you guys know that I'm actually a Tetris world champion? No, I'm just kidding. This is my Cloud Code agent playing both of these at the same time. You know what's crazy is I looked up what is the Tetris world record score, and apparently it's 40 million, which as you can see, both of my agents have just surpassed at the exact same time. And I'm pretty sure at this point I could go to sleep and I could wake up and they would still both be playing Tetris. So I've been playing around with browser automation inside of Cloud Code to do things like filling out forms or searching through Best Buy results or downloading reports that might not have an API accessible. So like in this example, just opened up that tab, it's going to flip to the next page with the form submission, and then it's going to go ahead and fill out those fields as you can see and shoot that off. Or in this example, it just opened up two tabs, and I'm trying to resize these real quick so you can actually see. You can see that these are Best Buy tabs, and it's going to search in one of them for laptops and in the other one for iPads. There you go, iPads, laptops, hit search, and now it's going to be able to pull some specs for me if maybe I was in the market for a new iPad or laptop. And I noticed as I started playing with these more that when you run scripts like this, it has to learn. So it goes in there, it takes a screenshot, it comes back and it thinks, and then it updates its script and it tries again. So I started wondering if I could basically teach it to play games. So what I did is I had it build me 3 games. And so today what I'm gonna show you guys is me training the AI to play the game and learn and get better each time. So we've got 3 different games. The first one's the easiest. The last one is kind of the toughest. And the last game I actually play against the AI live. So it's gonna be pretty cool. Okay, so here is the first game that it built me. It's a pretty simple, just, you know, block runner game. So the block is running, I hit space, and I'm able to jump over these obstacles, and each time I get a new point. So obviously I'm gonna just be able to do this forever, but I'm gonna let myself die so that we can come into Cloud Code and I could say, hey, I want you to open up the block game in a browser and try playing it. If you fail, understand what you did wrong and fix yourself so that next time you do better, and keep doing this until you score at least a 10. So it read through the game and now it's building that bot to actually go play the game. Now this is the easiest one, and really what it should be able to do is understand exactly how many pixels away it needs to activate the jump. So I imagine that this should be able to get to 10 pretty quickly. So we should be seeing this browser pop up any second now. Here it is. Let's move it into view. Let's see how good this bot does. Okay, it didn't jump at all. Okay, now it's jumping too early. It's trying again. Okay, this is not going very well. All right, so close out of the tab, and now it's going to debug and update the script. I'm clearly having way too much fun with Claude Code. It says I'm going to run the block game. Here's bot attempt number 2. So here's the tab. Let me move this into view, and let's see if it does any better this time. Okay, it's still jumping quite early. Once again, another early jump. Okay, this is pretty pathetic. Now it does look like it's trying something different because now it's triggering 2 jumps. There's Our first score. There's our second score. There's 3. There's 4. And maybe it's on to something. It's doing like a double jump. Come on, you can get to 10. There's 8. There's 9. There's 10. Wow. Okay, it literally got exactly 10. The bot scored 10 on attempt 6. It worked. The strategy evolved through self-correction. You can see it's analyzing like the pixels of the distances that it needed to do jumps. So that was the second time. I could probably get this to do one more iteration and build this bot so that it would literally never lose. But let's move on to game number 2. Okay, so game number 2 is a classic. It is Tetris. I can rotate the blocks, I can move them down slowly, or I could hit space to hard drop them. And wow, I've got a line. But this is actually really cool to me because I literally one-shot prompted all these games and I said, hey, I want to build some games and then I want to have you be able to test them. Give me some ideas. It threw out some ideas and I said, yep, go build them. And it just built them all. So this is super cool. Obviously I'm not going to play this. Let's go ahead and just die. And now let's see if Claude Code can play this well. All right. So now I said your next task is to open up a browser for Tetris and play the game as fast as you can, because I don't want to watch it just slowly drop blocks. I want to see it rotate them and slam them down and just do it as fast as it can. So once again, it's going to read the code base to understand how the game works. And then it's going to go ahead and write a script for a bot that's going to play Tetris. Oh my gosh. There's no way. Did you guys see the bot just score like 16,000? Well, that was kind of crazy. Okay, so now I'm saying, hey, can you open up two different tabs and get them to get to 25,000 points? You don't have to hard drop every piece immediately, but you just have to do it quickly. That was so crazy. I was not expecting that. All right, so here are the Tetris tabs. Here's number 1, here's number 2. Let me get these lined up. Okay, so now the tabs are both running. We've got 2 going simultaneously and they're doing better at not dropping as fast so we can actually see what's going on. This, this guy right over here put a vertical line in a horrible spot. All right, drop a comment real quick. Which one do you think is gonna win? Claude Code number 1 or Claude Code number 2? You can see though, like, there are some things that it messes up on. Like, this should have been placed down here, and sometimes it just doesn't rotate. Like, same thing over here. But it looks like they're kind of getting near the top now. So this one on the left-hand side has died, and it got about a fourth of what it did earlier when it was literally speedrunning through everything, which is kind of interesting. Okay, and now they're both dead, and they didn't even get past 6,000, which is kind of interesting to me. It said that the 2-second delay is actually making it worse, so I'm going to go back to the instant hard drops. Okay, so both of them just got over 25,000. One got 47 and one got 38. And now I'm saying, okay, cool, but now let's hit 80,000. All right guys, I think I cracked it. We are just pushing now 4 million. You know what's crazy is I looked up what is the Tetris world record score, and apparently it's 40 million, which as you can see, both of my agents have just surpassed at the exact same time. I genuinely don't think that they're gonna lose anymore, so I'm gonna go ahead and call it a day. We're gonna close out of those sessions and they definitely crushed the 80,000 mark. All right, so I'm gonna go ahead and clear out of the session and we're gonna move on to the last test, which honestly is not gonna be as fun as that one we just did. But this one is me playing against the AI in real time. All right, so I'm just gonna say, let's play checkers. That is the last game that it built for me. So hopefully it knows to spin up that browser and we'll play against each other. And I'm fully, fully, fully expecting to lose. So it's going to start up the game server and then it's going to launch the checkers bot. All right, here we go. So I am gold and the AI is red. I haven't played checkers in, I don't even know how long, so I have no strategy going into this, but we're just going to go ahead and get started here. What I do know though is when you get to the other side, then you can go backwards. So I, like I said, no strategy. I'm not feeling great about this game. Yeah, yeah, I think I lost already. Oh, that was brutal. Well, it's 4 on 4. I maybe could still make a comeback. Oh my gosh, oh my gosh, I thought I outsmarted it, but then I realized that you can't outsmart the AI, so Okay, I just lost. I don't really feel too bad about myself though, because the thing just scored 46 million in Tetris. But anyways, that is going to do it for this video. I just wanted to show you guys what I thought was kind of a cool use case, but really think about the practicality of what this actually means. Cloud Code can now do anything that you would do on a computer with enough training. And once you build some skills around those scripts, I think that this is going to be super, super cool. And I'm definitely going to be diving more into some computer use automations. And if you're curious on how I did this, literally what I did is I opened up a new session. I came in here into plan mode and I said, hey, I want you to be able to use my computer. I want you to be able to use the browser, do some research, figure out the best method, and then go ahead and just install what you need to install. It ended up using Playwright's CLI. So that's why you saw all those bash commands. Super seamless, super simple. And you guys already saw that in action. So if you wanna play around with it, go tell it to figure out how to install the Playwright CLI and it will just do it for you. So if you guys enjoyed or you learned something new, please give it a like. It definitely helps me out a ton. And as always, I appreciate you guys making it to the end of the video. I'll see you on the next one. Thanks everyone.










