Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A bot that plays the Google Chrome T-Rex game for you

License

NotificationsYou must be signed in to change notification settings

danpush/t-rex-game-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A bot that plays the Google Chrome T-Rex game for you. It can consistantly hit around 50,000 points. Highest I've gotten is 100,000, but I'm sure it can go much higher.

When I had started this project I thought this would be at least 200 lines of code, yet here I am hitting 6 figure scores where the bot itself is just 10 lines of code. Obviously I have to simulate the key inputs, and that's what takes up the other 50 lines.

I've been able to make it so short by finding a formula to calculate how far away I need to jump before an obstacle. I found this by just playing the game and logging the exact speed of the T-rex and various other variables that the game uses. Putting this into any graphing software you could see a clear correlation between the speed of the T-Rex and the distance from the next obsticle (at the time of jumping). Distance would always be around 20 * speed. From there all that was left to do was type it up!

HighScore

How To Use

  1. Open chrome and go to: chrome://dino/ (or disconnect your internet)
  2. Press "F12" and go to "Console"
  3. Copy and Pase the following text, then press enter.
functionkeyDown(e){Podium={};varn=document.createEvent("KeyboardEvent");Object.defineProperty(n,"keyCode",{get:function(){returnthis.keyCodeVal}}),n.initKeyboardEvent?n.initKeyboardEvent("keydown",!0,!0,document.defaultView,e,e,"","",!1,""):n.initKeyEvent("keydown",!0,!0,document.defaultView,!1,!1,!1,!1,e,0),n.keyCodeVal=e,document.body.dispatchEvent(n)}functionkeyUp(e){Podium={};varn=document.createEvent("KeyboardEvent");Object.defineProperty(n,"keyCode",{get:function(){returnthis.keyCodeVal}}),n.initKeyboardEvent?n.initKeyboardEvent("keyup",!0,!0,document.defaultView,e,e,"","",!1,""):n.initKeyEvent("keyup",!0,!0,document.defaultView,!1,!1,!1,!1,e,0),n.keyCodeVal=e,document.body.dispatchEvent(n)}setInterval(function(){Runner.instance_.horizon.obstacles.length>0&&(Runner.instance_.horizon.obstacles[0].xPos<20*Runner.instance_.currentSpeed-Runner.instance_.horizon.obstacles[0].width/2&&Runner.instance_.horizon.obstacles[0].yPos>75&&(keyUp(40),keyDown(38)),Runner.instance_.horizon.obstacles[0].xPos<20*Runner.instance_.currentSpeed-Runner.instance_.horizon.obstacles[0].width/2&&Runner.instance_.horizon.obstacles[0].yPos<=75&&keyDown(40))},5);
  1. Start the game!

License

This project is licensed under the MIT License. See theLICENSE.md file for details

Created August 2017 by Daniel Apushkinsky (Last Updated October 2020)

About

A bot that plays the Google Chrome T-Rex game for you

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp