AI learns to play Google Chrome Dinosaur Game || Can you beat it??



oh my god yep let's do this here in Australia the internet leaves a lot to be desired therefore I have had the absolute pleasure of becoming very well acquainted with this dinosaur game for those of you who are fortunate enough not to know Google Chrome has a hidden dinosaur game which you can play when the internet is down so I decided to conquer this game in the name of all of those who feel the frustration of experiencing the Aussie Internet now as per usual first I need to make the game okay first up we need to add the player dino-dude and at this stage in the game is just a rectangle who can jump mmm there she is solid game Evan but that's look good doesn't even work all right after I fixed that bug it's time to add some obstacles for the Dino to jump over and with some heavy reference from the game I added some small cactuses okay once I was happy with that I added some other obstacles and once they were looking good I need to add some collision logic so that when you jump and hit a cactus you die simple stuff and yeah I I did that okay let's make it look pretty I drew up some sprites and chucked them in I also fine-tune the collisions so that they fit the sprites and match the original game okay finally I scaled everything up and wait for it the hats a bird and if you're really good you could duck under him oh you know okay game is done let's get to the bit you guys have been waiting for the AI each generation contains 500 players each controlling a dinosaur classic genetic algorithm so the players which do the best live on to reproduce and the same thing for the next generations and rinse and repeat until you have a bloody beast the first few generations is just the players holding down the jump button which is a decent strategy if you suck and as you can imagine at this point it's just about luck they don't care about where the obstacles are they're just hoping they match up with their jumping cycles this continues for quite a few generations now we're talking this guy finally has the patience to wait until the next obstacle is close enough before jumping if you look at the neural network at the top you can see that it uses the distance to the next object to calculate when to jump alright let's speed this up because these games get long now this guy's pretty good but not foolproof there are two ways in which this guy can die first since the game is constantly speeding up the player can jump too late and get hit the second way is the bird basically there are three levels of birds the highest flying bird cannot be jumped over so the AI needs to learn to duck which is inevitably what kills this player what is interesting about generation 8 is you can see the genetic algorithm at work each player is slightly mutated from its parents of the previous generation this can be expressed as jumping slightly earlier or later that's why you see the players slightly separate when they jump I don't know I find it interesting but I'm a nerd okay at this point I left and crushed some lunch and when I came back this had happened yet we missed most of the evolution but thankfully since I'm a genius programmer I included a module to replay the highlights of the evolution showing the best player of the generation let's check it out you've already seen generation 1 through 8 so we can skip them the next solid evolution highlight was until generation 25 when the AI finally learned to duck which means the only way it can die is from the game speeding up this player jumps way too late so it didn't last very long the players slowly evolved to perfect this overtime and the best game happened at generation 40 this guy is a solid player I'm going to skip forward in the game because otherwise this game goes for like 16 minutes which I know your guys attention span does not account for so this is like 6 minutes in and the game is already moving at ridiculous speed skipping forward again to about 10 minutes in okay one more time skip we're at 15 minutes it's just stupid quick at this point each obstacle is only on the screen for like a couple of frames but it's still managing to jump over some side I get a lot of messages from people who are inspired to learn to code but have no idea where to start having not studied coding at all in your life and hearing terms like algorithms and neural networks can be daunting at first but fret no more a good place to start learning the logic and theory behind coding is brilliant org they have a bunch of courses teaching you the fundamentals of computer science for those of you who are new to the field each course is interactive and breaks up complicated concepts into bite-sized chunks to make sure you actually absorb the information a strategy which I wish was used for my three-hour university lectures I'm gonna start doing some tutorials explaining how my a ice learn and think in the following weeks I will try to make them pretty simple and low-level but I'll be expecting at least a basic understanding of coding and algorithms after all I will be explaining the genetic algorithm to you and contrary to popular belief that is in fact an algorithm so an understanding of what an algorithm is and to basic knowledge would be rather helpful head over to free org slash code bullet to check out a bunch of their free courses and the first 200 people who use this link will get a whopping 20% off the annual subscription so if you want to learn some computer science and support yours truly at the same time then it would mean a lot if you could go and check them out you

32 thoughts on “AI learns to play Google Chrome Dinosaur Game || Can you beat it??

  1. Hey guys
    I know its been like 2 months
    but the source code is finally on github
    check it out here: https://github.com/Code-Bullet/Google-Chrome-Dino-Game-AI
    sorry again about the lateness
    enjoy

  2. I got to a score of 90k when I just glitches Google Dino game by starting the game then instantly putting the computer to sleep on my laptop

  3. You can only go up to 1 million on this game and when you hit it you don't complete it your score simply starts again at zero.

  4. There's only one thing gameplay-wise that I think is different in your version than in the real game, which is the space between objects, in your game, the objects get further apart the faster you go to make it possible, but in the chrome version, a technique I call jump-ducking is needed in late game, pretty much it means you are travelling so fast that if you jump over an obstacle, the other obstacle is too close to be able to jump again, but when you are in the air you can duck to send you straight back down and when done correctly it can make the game possible, I think it would be cool if you could recreate that and have an AI master the ability to jump-duck, just an idea though it's probably stupid, anyway I spent way too much time writing this essay comment so I'll end your suffering by ending it here. 🙂

  5. I found all music from the video. But I also found that one guy is a patent scam, so it’s probably not his music(and I couldn’t find original), and for the other sound I also found a few authors (Mirror Mirror by Diamond Ortiz (probably original) and Molly Hemsley I am Trouble). And the worst thing that Shazam and other resources show scammers songs not original ones. Shame on you Code Bullet, for not crediting song authors!

Leave a Reply

Your email address will not be published. Required fields are marked *