Salman Adnan

dino-game-bot

Dino Game Bot

When Chrome loses its connection it offers a game where a dinosaur jumps over cacti; this script plays it by itself. It never peeks inside the game: it watches pixels on the screen and presses space when something appears ahead of the dino. The screen-reading half is tested, but the bot was never run against the real game here, and the patch of screen it watches fits one setup only.

Solo

Solo work by Salman Adnan.

Vision Runner: a picture of how the bot plays. It never reads the game's code; it just watches a strip of pixels, and when a cactus crosses that beam the box locks on and the dino hops. Live and interactive: drag it to orbit, scroll or pinch to zoom. Open full screen
The real status dashboard for the Dino Game Bot, showing a demo event sequence.
Live screenshot of the dashboard UI; events shown are a fed demo sequence, not a live bot run.
10mspolling loop sleep after a jump
8rolling event log entries in the dashboard

Overview

A script that plays Chrome's offline Dino game by watching the screen and pressing space at the right moment, using screen capture and pixel inspection rather than reading any game state or the DOM.

The Dino game has one input (jump) and a simple visual language: obstacles approach from the right, and hitting one ends the run. That makes it a small, self-contained target for practicing screen-based automation, no game API to call and no memory to read, just pixels on screen and a keyboard event, exercising Selenium (to drive Chrome) alongside raw screen capture and pixel inspection (to "see" the game).

Key features

  • Launches Chrome and opens the built-in offline Dino game directly via `chrome://dino/`, starting it with a space keypress.
  • Watches a fixed screen region in a loop and jumps when it detects an obstacle.
  • Handles both day and night color schemes, since the game inverts its palette periodically.
  • Stops cleanly on a `q` keypress and quits the browser in a `finally` block so a stray exception can't leave Chrome running.
  • A live status dashboard (day/night mode, obstacle flag, jump count, run time, rolling event log) shown alongside the browser window, with a console fallback when no display is available.

Verification

Verified in an environment with a display but no Chrome or live game: the module imports without side effects, `check_day` and `check_obstacle` were smoke-tested against synthetic day/night images built in memory, `StatusTracker` was driven through a scripted sequence of detection events with its state asserted at each step, the tkinter dashboard was confirmed to construct and update against a live X display without blocking, the headless console fallback was confirmed by unsetting `DISPLAY`, and `requirements.txt` installs cleanly into a fresh virtual environment. Not verified here, and requiring a real machine with Chrome: actually launching the game and confirming it responds to jumps, whether the hardcoded screen coordinates still match a different setup, and whether the bot clears obstacles reliably end to end over a real run.

Tech stack

  • Python 3
  • Selenium 4.6+
  • Pillow (ImageGrab)
  • keyboard
  • tkinter

A challenge worth noting

The obstacle and game-area regions are absolute pixel boxes tuned for one specific screen resolution and window layout, with no logic to derive them from the actual browser window geometry, so the bot is only correct on the exact setup it was measured on. A related challenge is the day/night color inversion: the game periodically swaps its palette, so a single fixed color check for "obstacle present" would break every time the mode flipped. `check_day` runs first on every check to pick the right target color, at the cost of a second screen grab per loop iteration.

Book a call

Let's talk about what you're building.

Pick a slot below. No forms, no back-and-forth emails.