Inspiration

The inspiration for this project came from our fascination with the Chrome Dino Game and a desire to automate it in a fun and creative way. Instead of creating a complex learning-based AI, we focused on building a simple yet effective automation script to navigate the game’s obstacles. By leveraging Chrome’s DevTools Protocol, we were able to automate the game directly within the browser, making it a unique approach to solving a classic game.

What it does

The Dino Automation Bot detects incoming obstacles in the Chrome Dino Game and automatically makes the Dino jump or duck based on their position and height. The bot uses JavaScript automation commands to simulate keyboard events (such as pressing the spacebar or down arrow) and effectively control the game in real-time. It can handle different speeds and varying obstacle types, such as low cacti or high-flying pterodactyls, ensuring the Dino survives as long as possible.

How we built it

Browser Automation Setup: We used the pychrome library to connect to Chrome’s DevTools Protocol, allowing us to interact with the game’s internal state and control it programmatically. Game State Extraction: By accessing variables in the Chrome Dino game’s internal JavaScript, we retrieved details like obstacle positions, heights, and the game’s current speed. Automation Logic: Instead of a learning-based AI, we implemented a straightforward logic that calculates the appropriate timing to jump or duck based on the Dino’s speed and the distance to obstacles. Keyboard Event Simulation: The bot sends keyboard events (e.g., spacebar for jumping, down arrow for ducking) to the browser, simulating player inputs whenever obstacles are detected within a specific range.

Challenges we ran into

Handling Browser Automation: Integrating the pychrome library to control Chrome’s internal state and reliably access game variables was a challenging task. Accurate Timing and Response: Fine-tuning the timing of jumps and ducks to adapt to different speeds without missing an obstacle required a lot of trial and error. AI Learning Overcomplicated the Problem: Initially, we explored implementing a learning-based AI, but found that it added unnecessary complexity for a simple game. By focusing on a rule-based automation approach, we were able to streamline development and make the bot more stable and efficient. Error Handling: Unexpected changes in the game state or errors in JavaScript evaluations required implementing robust exception handling to ensure the bot could recover gracefully.

Accomplishments that we're proud of

Successfully automating a classic game using a simple and direct approach without overcomplicating it with machine learning. Implementing a browser automation script that can react in real-time and play the game as effectively as a human. Achieving a stable automation system that adapts to different speeds and obstacle patterns using basic logic and game state evaluation.

What we learned

Chrome DevTools Protocol: Gained an understanding of how to use Chrome’s DevTools Protocol for automation and scripting. Real-Time Game Control: Learned to simulate keyboard inputs and interact with a game’s state in real time. Python and JavaScript Integration: Combined Python automation with in-browser JavaScript code execution, bridging two different languages for a seamless solution.

What's next for Dino Automation Bot

Additional Obstacle Handling: Further refine the logic to handle edge cases, such as multiple obstacles appearing close together. Enhanced UI for Customization: Develop a simple interface for users to adjust bot parameters like jump timing, reaction distance, and speed thresholds. Multi-Game Support: Expand the project to automate other simple web games using similar automation techniques.

Built With

Share this project:

Updates