100DaysOfCode: Day 93

Day 93’s project is chrome dinosaur game auto bot. The idea is to check the specific “area” to see if a tree exists (or any hurdle to that matter), and see if we can automate that.

Angela already gave us ideas to use pillow and pyautogui, with a bit of googling ,this is not all that hard. The idea is:

  • dinosaur coordinate does not change (much)
  • We use the pillow package to grab the front of dinosaur, change it to grayscale, then check the color. If there’s no tree, the color stays the same. If there’s a tree, then what we should do is press space
  • Pressing space is basically utilizing pyautogui functions.

The difficulties I encountered are:

  • How to get the coordinate of the dinosaur and the trees correctly (I eventually just take a screenshot and use paint), and fine tune the distance of the checking area
  • How to press space bar longer (instead of press, I use keyDown and sleep then keyUp)
  • How to handle multiple small trees (still not 100% over come this yet)

Overall, not super hard, and a fun game.

This entry was posted in 象哥的學習筆記 Study Notes and tagged . Bookmark the permalink.

Leave a Reply