加载中…
加载中…
A small neural network that plays Chrome's T-Rex game. Watch it play live,
with its network drawn next to it:
NeuroDino Space. The
code that trained it: github.com/ahm3texe/NeuroDino.
The paper describes all three models and how they were tested:
paper/neurodino-en.pdf
(Turkish original: paper/neurodino.pdf).
This is v3. The earlier models are in v2/ and v1/.
A multilayer perceptron written with NumPy, no ML framework:
Missing obstacles give 0. Distances are in game pixels, the speed in pixels per frame at 60 fps, and "the next obstacle" is the nearest one ahead of the dino.
| # | Name | Value |
|---|---|---|
| 0 | Obj1 Dist | 1 − min(1, frames to reach the next obstacle / 50): 1 is about to hit |
| 1 | Obj1 Act | 1 if the next obstacle is the highest bird (y < 75), which flies over a running dino |
| 2 | Obj1 W | min(1, its width / 75) |
| 3–5 | Obj2 Dist, Act, W | The same for the obstacle after it |
| 6 | Speed | Game speed / 13, the top speed |
| 7 | Gap | 1 − min(1, frames between the two obstacles / 15) |
| 8 | DinoY | min(1, height above the ground / 30) during a jump |
| 9 | DinoVel | Vertical velocity / 10 within [−1, 1] during a jump, negative while rising |
| 10 | Air | 1 while jumping |
| 11 | Duck | 1 while ducking |
The reference implementation is
neurodino/sensors.py.
import numpy as np
from huggingface_hub import hf_hub_download
from safetensors.numpy import load_file
w = load_file(hf_hub_download("ahm3texe/neurodino", "model.safetensors"))
def act(inputs):
"""The 12 inputs above in, 'jump', 'duck' or 'run' out."""
hidden = np.tanh(w["weights_ih"] @ inputs + w["bias_h"])
logits = w["weights_ho"] @ hidden + w["bias_o"]
return ["jump", "duck", "run"][int(np.argmax(logits))] # = argmax of the softmax
Compute the inputs after the obstacles have moved for the frame, as the
website and watch_model.py do. Duck in the air is a fast drop. To watch it
play, run watch_model.py from the GitHub repository.
The logs are training_log.csv (v1), training_log_v2.csv and
validation_v2.csv; v3's pipeline is in the repository's
training/.
On the website's engine, four-hour games:
| Games | Ended before top speed | Lasted 4 hours | Crashes at top speed | |
|---|---|---|---|---|
| v1 | 200 (test) | 113 | 85 | 2 |
| v2 | 200 (test) | 0 | 190 | 10 |
| v3 | 200 (test) | 0 | 198 | 2 |
| v2 | 1,000 new | 0 | 960 | 40 (1 every ~100 h) |
| v3 | 1,000 new | 0 | 997 | 3 (1 every ~1,300 h) |
Neither v2 nor v3 had played the test games (seeds 1–200) or the new ones
before. Every game is in the repository's
evaluation/.
| File | Contents |
|---|---|
model.safetensors |
weights_ih (56×12), bias_h (56), weights_ho (3×56), bias_o (3), float64 |
best-brain.json |
The same weights in the format the website loads |
config.json |
Sizes, activations, action and input names, input constants |
training_log.csv |
v1's training: best, average and record score of every generation |
training_log_v2.csv, validation_v2.csv |
v2's training and validation |
v2/, v1/ |
The earlier models' weights, in the same two formats |
MIT. The game it learned on is Chromium's T-Rex runner (BSD-3-Clause), ported to Python; not affiliated with Google.