News for hackers. Stuff that matters.
Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by ravenstine on Friday August 14, 2020 @03:10PM (#24162019)
If you've got a photoresistor and a servo, you can make a "robot" play the dinosaur game manually!

https://www.youtube.com/watch?v=L2NtMpQml-A

Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by jestanoff on Friday August 14, 2020 @06:54PM (#24164225)
I don't like the length of their solution, quite the same logic can be shortened to just a few lines of code

setInterval(() => {

  const { currentSpeed, horizon: { obstacles: [{ xPos, width, yPos } = {}] } } = Runner?.instance_;

  if (xPos < 25 * currentSpeed - width && yPos >= 75)
    document.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 32 }));
}, 100);
Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by truly_furqan on Friday August 14, 2020 @09:15PM (#24165105)
Thanks for mentioning this code. Actually, I've just tried your solution. But, the dinosaur dies quickly.

So, I think the code I mentioned in the article is more efficient.

Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by jestanoff on Saturday August 15, 2020 @05:32AM (#24167455)
May be it is something small as dividing the width by 2 and setting a lower milliseconds value for the setinterval so it runs the checks more often.

Essentially this is the same solution as in the post, just stripped down to the bare minimum of code, but I haven't tested it enough. There must be some edge case that it fails on

Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by nestorD on Friday August 14, 2020 @05:15PM (#24163368)
I have a t-shirt that features the Google T-Rex Game and I found that a large number of people do not recognisee the dinosaur nor know the game despite using chrome daily!
Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by oplav on Friday August 14, 2020 @03:02PM (#24161912)
TIL that pressing "down" makes the dinosaur duck.
Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by Gaelan on Friday August 14, 2020 @08:59PM (#24165029)
Here's a quick deobfuscated version (pretty printed, renamed variables, converted foo && (bar(), baz()) to if(foo) {bar(); baz()}).

https://gist.github.com/Gaelan/a0c5461055437dca9618a12f68949...

Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by Gaelan on Friday August 14, 2020 @09:07PM (#24165073)
Edit: after I did that, I discovered jsnice.org, which managed to do all the deobfuscation I did (including inferring variable names from usage!) automatically. I'm very impressed. I replaced the gist above with the JSNice output.
Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by truly_furqan on Sunday August 16, 2020 @06:02AM (#24176569)
That's cool. I appreciate that.
Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by superjan on Friday August 14, 2020 @02:53PM (#24161794)
Copy-pasting random javascript from the internet is not good security hygene.
Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by thdc on Friday August 14, 2020 @03:19PM (#24162112)
Especially when it's minimized like this. Are they trying to hide something? Why couldn't it be formatted in a more readable manner?

(it does look safe though)

Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by truly_furqan on Sunday August 16, 2020 @06:11AM (#24176613)
Great point!

But actually, I minified this code so that people can quickly try it out. I'll try to explain it in some other article.

Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by truly_furqan on Sunday August 16, 2020 @06:18AM (#24176641)
I completely agree with your concern.

But, I had to make it as simple as possible for non-programmers.

Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by 9214 on Friday August 14, 2020 @08:10PM (#24164726)
There's also a relatively old Common Lisp solution.

https://vitovan.com/dino.html

Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by truly_furqan on Friday August 14, 2020 @09:17PM (#24165117)
Hmm, nice one. Thanks for mentioning.
Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by koolba on Friday August 14, 2020 @04:46PM (#24163044)
I didn’t even know this Dino game existed and suddenly fear that a massive procrastination wave is unfolding.
Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by awesomeideas on Friday August 14, 2020 @02:20PM (#24161375)
Simulated paleontology is such an amazing field!
Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by pcthrowaway on Friday August 14, 2020 @02:09PM (#24161237)
now they just need to make this an offline chrome app so you can open it when you're offline
Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by citrusui on Friday August 14, 2020 @02:47PM (#24161719)
As long as you have Chrome, you can still play it offline. Just go to chrome://dino
Re:JavaScript Code Plays Google Dinosaur/T-Rex Game Automati... by bobbydreamer on Friday August 14, 2020 @07:47PM (#24164588)
New is edge browsers surfer