A standardized benchmark for testing and comparing reinforcement learning algorithms on the Chrome dinosaur game.
DinoBench is a platform for:
- Benchmarking RL algorithms against a faithful recreation of the Chrome dinosaur game
- Comparing different approaches with standardized metrics
- Maintaining a global leaderboard of best performances
- Ensuring reproducibility through saved seeds
- Custom Game Environment: Accurate recreation of Chrome's dinosaur game using Pygame
- Standardized Interface: OpenAI Gym-compatible environment
- Benchmark Framework: Tools for fair comparison of different agents
- Reproducible Results: Seed tracking for replicating high scores
- Visualization: Watch your agents play in real-time
- Clone the repository:
git clone https://github.com/yourusername/dinoBench.git
cd dinoBench- Install dependencies:
pip install -r requirements.txtTry the game yourself:
python play_game.pyControls:
- SPACE/UP: Jump
- DOWN: Duck
- Q: Quit
Test the example agents:
python benchmark.pyTrain the example DQN implementation:
python train.py- Create a new Python file (e.g.,
my_agent.py) - Implement the
DinoAgentinterface:
from benchmark import DinoAgent
class MyAgent(DinoAgent):
def __init__(self):
# Initialize your agent
pass
def act(self, state):
"""
Args:
state: 84x84x1 grayscale image of game state
Returns:
action: 0 (do nothing), 1 (jump), or 2 (duck)
"""
# Your agent's decision logic here
return action
def name(self):
return "My Awesome Agent"- Run the benchmark:
from benchmark import DinoBenchmark
benchmark = DinoBenchmark()
my_agent = MyAgent()
benchmark.run_benchmark(my_agent, n_episodes=100)- Type: Box(84, 84, 1)
- 84x84 grayscale image of the game state
- Type: Discrete(3)
- Actions:
- 0: Do nothing
- 1: Jump
- 2: Duck
- +0.1: Surviving each timestep
- +1.0: Successfully passing an obstacle
- -10.0: Collision with obstacle
- Dinosaur can jump over or duck under obstacles
- Obstacles include:
- Small cacti
- Large cacti
- Cactus groups
- Birds at different heights
- Game speed increases with score
- Precise collision detection
- High Score: Best single-episode performance
- Average Score: Mean score over multiple episodes
- Standard Deviation: Consistency measure
- Median Score: Typical performance indicator
- Success Rate: Percentage of episodes above threshold
- All-Time High Scores
- Most Consistent Performance
- Best Average Score
- Recent Benchmark Runs
- All high scores include seeds
- Benchmark runs can be replicated exactly
- Performance statistics over multiple episodes
-
Random Agent (Baseline)
- Makes random actions
- Serves as minimum performance baseline
-
DQN Agent (Example Implementation)
- Deep Q-Network with CNN architecture
- Processes raw game images
- Learns through experience replay
- Fork the repository
- Create your feature branch
- Implement and test your agent
- Submit a pull request with:
- Your agent implementation
- Benchmark results
- Brief description of your approach
-
State Processing
- Consider extracting relevant features
- Distance to obstacles
- Obstacle types and patterns
-
Action Selection
- Timing is crucial for jumps
- Duck only for birds
- Avoid unnecessary actions
-
Training Strategies
- Start with simpler scenarios
- Gradually increase difficulty
- Use curriculum learning
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by Chrome's dinosaur game
- Built with PyTorch and Pygame
- Uses OpenAI Gym interface