ivanseidel / IAMDinosaur

🦄 An Artificial Inteligence to teach Google's Dinosaur to jump cactus
MIT License
2.8k stars 533 forks source link

Game wont refresh #50

Closed GritPixel closed 7 years ago

GritPixel commented 7 years ago

I got the program to run on Ubuntu. It opens, detects the game, I press "s" then it brings chrome to focus and the Dino runs. The Dino hits the cactus but the program does not recognise this. It just sits on the game over screen. Even in the terminal "GameStatus: PLAYING". It does not change to "OVER". Help would be appreciated : /

huan commented 7 years ago

Yes, I also have this issue.

After looking the code, it seems the following code gameOverOffset is not right anymore:

// Read Game state
// (If game is ended or is playing)
GameManipulator.readGameState = function () {
  // Read GameOver
  var found = Scanner.scanUntil(
    [
      GameManipulator.offset[0] + GameManipulator.gameOverOffset[0],
      GameManipulator.offset[1] + GameManipulator.gameOverOffset[1]
    ],

    [2, 0], COLOR_DINOSAUR, false, 20
  );

I guess it's because the position of the GAME OVER is changed in the new version of Chrome?

My system is:

huan commented 7 years ago

@GritPixel I changed

--- a/GameManipulator.js
+++ b/GameManipulator.js
@@ -28,8 +28,9 @@ var GameManipulator = {
   gamestate: 'OVER',

   // GameOver Position
-  gameOverOffset: [190, -82],
+  gameOverOffset: [190, -75], 

The above change fixes this issue for me.

Will send a PR later to make it compatible with different Chrome Browsers.

himahuja commented 7 years ago

Sir, I had to change back the coordinates to [190, -82] for it to work for me. I am on a mac, and maybe this is system dependent. Great job with this though.