---
title: 'Chrome Dinosaur Game: Rebuild Its Speed Rule — REA'
url: https://rea.tools/examples/dino-lab/
---

[Home](https://rea.tools/)/Dinosaur speed lab

Inspect → rebuild → change

# Rebuild the dinosaur’s speed rule.

To recreate the game’s acceleration, first find the rule that controls
its speed. **REA returned the running script;**
we used its rule to build this mini-game with
adjustable speed.

## Play and change the speed

Press Play, then jump over the cactus. Move the speed slider to
try a slower or faster game; it switches to a fixed speed. Select
the recovered rule to start at 6 and gradually accelerate again.

Play the reconstruction

Speed 6.0
 Use the
recovered acceleration rule

Original rule: start at 6, then increase toward 13.

Move the slider to set your own speed. Space or Jump clears a
cactus.



Enable JavaScript to play the reconstruction. The code and
explanation above remain readable.

## Read the script REA returned

We inspected
[wayou’s Chromium-derived browser edition](https://wayou.github.io/t-rex-runner/)
with REA. It returned the loaded `index.js`, including
this branch in the game’s update function:

REA · selected script source

```
if (this.currentSpeed < this.config.MAX_SPEED) {
  this.currentSpeed += this.config.ACCELERATION;
}
```

The settings are `SPEED: 6`,
`ACCELERATION: 0.001` and `MAX_SPEED: 13`.
The game runs this branch on an update without a collision.

### Use the same rule in the new game

Reconstruction ·
dino-speed.js

```
function advanceSpeed(speed) {
  return speed < 13 ? speed + 0.001 : speed;
}
```

The mini-game uses this function for automatic acceleration.
Moving the slider supplies a fixed speed instead. Drawing, jump
physics and rectangle collision checks are new code for this
teaching game; its simulation advances at 60 updates per second.

[Download the speed rule](https://rea.tools/assets/dino-speed.js)
· [Read the game code](https://rea.tools/assets/dino-demo.js)

## Check the reconstruction

We called the original game’s update function with obstacles and
automatic scheduling disabled. Compare those recorded speeds with
a replay of the recovered rule.

| Updates | Original game | Reconstructed rule |
| --- | --- | --- |
| 0 | 6.000 | 6.000 |
| 1,000 | 7.000 | 7.000 |
| 4,000 | 10.000 | 10.000 |
| 10,000 | 13.001 | 13.001 |

Values rounded to three decimals. The branch checks before adding,
so the final increment can take speed just above 13.

## Try the analysis yourself

1. [Set up REA](https://rea.tools/get-started/) with your coding
   agent.
2. Follow the
   [browser connection steps](https://rea.tools/guides/browser/#prepare), using `https://wayou.github.io/t-rex-runner/` as
   the page URL.
3. Give your agent the page URL and local debugging endpoint, then
   copy this prompt.

Your coding agent

Use REA to inspect this dinosaur game. Why does it get
faster? Show the speed rule, then build a small version with
an adjustable speed.

Ask a follow-up:
**“Where is jump height calculated? Add a jump-height control to
the new version.”**

Source:
[inspected speed code](https://github.com/wayou/t-rex-runner/blob/5455bfa408ec6b707c7300ff194b7390733a766d/index.js#L565-L571), Chromium Authors.
[Copyright and BSD license](https://rea.tools/assets/licenses/dinosaur.txt). REA 4.1.0 inspected the running HTTP edition in Chrome 150.
