Skip to main content
# gym-chrome-dino

An OpenAI Gym environment for Chrome Dino / T-Rex Runner Game

This environment utilizes
[a forked version](https://github.com/elvisyjlin/t-rex-runner)
of _Chrome Dino_, also called _T-Rex Runner_,
extracted from chromium offline error page.
See [here](https://github.com/wayou/t-rex-runner).


## Installation

You can install `gym-chrome-dino` from PyPI by either

```bash
pip install gym-chrome-dino
```

or

```bash
git clone https://github.com/elvisyjlin/gym-chrome-dino.git
cd gym-chrome-dino
pip install -e .
```


## Usage

You can get started as follows:

```python
import gym
import gym_chrome_dino
env = gym.make('ChromeDino-v0')
```

To create a headless (without opening browser) environment

```python
env = gym.make('ChromeDinoNoBrowser-v0')
```

### Observations, Actions and Rewards

* The observation is a RGB numpy array with shape of (150, 600, 3).
* The available actions are 0: _do nothing_, 1: _jump_, and 2: _duck_.
* A positive reward 0.01 is given when the dinosaur is alive; a negative penalty -1.0 is given when the dinosaur hits an obstable, which might be a cactus or a bird.

For the DeepMind DQN recipe, where we give 4-stacked resized grayscaled frames (80, 160, 4) to the agent, we provide a wrapping method `make_dino()`. It also comes with a timer wrapper, which reports the interval between `env.step()`.

```python
from gym_chrome_dino.wrappers import make_dino
env = make_dino(env, timer=True, frame_stack=True)
```

### DinoGame

An instance of `DinoGame` is created when the environment is made. There are some useful methods for fine control of the training environment. The `DineGame` can be accessed as follows:

```python
env.unwrapped.game
```

`DinoGame` provides a `get_score()` method to get the score of current game.

```python
score = env.unwrapped.game.get_score()
```

By default, the acceleration of the game is set to zero. If you want to restore the original acceleration value, please do `set_acceleration(True)`. On the other hand, `set_acceleration(False)` sets the value to zero.

```python
env.unwrapped.game.set_acceleration(True)
```


## Example

Here is a simple example to use `gym-chrome-dino`.

```python
import gym
import gym_chrome_dino
from gym_chrome_dino.utils.wrappers import make_dino
env = gym.make('ChromeDino-v0')
env = make_dino(env, timer=True, frame_stack=True)
done = True
while True:
if done:
env.reset()
action = env.action_space.sample()
observation, reward, done, info = env.step(action)
```


## WebDriver

`gym-chrome-dino` runs the game on [chromedriver](http://chromedriver.chromium.org) via `selenium` because it is a proper way to monitor and to play _Chrome Dino_. As a result, the latest chromedriver executable file will be downloaded to the current working directory where your program is.

Metadata

Release files for gym-chrome-dino 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gym-chrome-dino 0.0.3
File Size Uploaded Provenance Actions
gym_chrome_dino-0.0.3.tar.gz 8.0 kB Without provenance Details for gym_chrome_dino-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gym-chrome-dino 0.0.3
File Interpreter ABI Platform Actions
gym_chrome_dino-0.0.3-py2.py3-none-any.whl Python 3, Python 2 none any Details for gym_chrome_dino-0.0.3-py2.py3-none-any.whl

Total release size: 21.8 kB

Release files / gym_chrome_dino-0.0.3.tar.gz

Download URL gym_chrome_dino-0.0.3.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
44a6861d7cc7afa7086cc67a149b76f036983aac0295a6a087113731d0e1ebda
BLAKE2b-256 checksum
How to use checksums
510ebc1d5173d66a090d2c774cda4759ac7bba5807c5e9bbb38801e61eeb7627
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.9.1 setuptools/20.7.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.2

Release files / gym_chrome_dino-0.0.3-py2.py3-none-any.whl

Download URL gym_chrome_dino-0.0.3-py2.py3-none-any.whl
Size 13.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
fac655990d39a16bfafc59958748bfa1a62a637569827036b34d8ac6a0f70244
BLAKE2b-256 checksum
How to use checksums
aae141accd699e9e6a1dc3f44c176696baf07272e17e7d0eabc4cb8149648ba5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.9.1 setuptools/20.7.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.2

Security for gym-chrome-dino 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page