Prototype of what I have been working on, and some questions in the comments

Hey, I've somewhat new to python, however I decided that I wanted to start off by doing something with OpenCV, and settled on trying to "automate" Chromes Dino game. After a few days, I have come up with this. It works pretty good most of the time, however I do have some things that I want to fix/add.

Code is here:

  1. When I call the function, my application runs much more slowly. You can actually see this in the video when the dinosaur jumps or ducks. It goes from around and update every 0.1s to 0.25, which is pretty severe. Does anyone know how I can fix this?
  2. The overall update rate isn't very good either. This is due to the ImageGrab() function I am using. I am wondering if there are any faster ways to capture a screen region that I will be able to implement into my code.
  3. All of the values for when to jump are manually put in by me. I have been looking into neural networks and genetic algorithms, and I'm wondering if you think it is possible for me to implement one into this program. The problem right now is that as the game speeds up, the dinosaur doesn't account for that when deciding to jump, and I was hoping that I could solve that problem by implementing a genetic algorithm. I was thinking somewhere along the lines of using the game time as fitness, and when deciding to jump, not only taking into account the distance to the closest cactus, but also how long the game has been going for.
    I have wanted to learn more about genetic algorithms, so if you have any information/suggestions, that would be amazing.

Thanks for any help, I really appreciate it!

/r/Python Thread Link -