feat(website): explain REA with Calculator and a playable dinosaur lab

This commit is contained in:
N0zoM1z0
2026-10-09 11:06:05 +08:00
parent 5160d9b717
commit 11b9f0346c
13 changed files with 1716 additions and 219 deletions
+332
View File
@@ -0,0 +1,332 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Dinosaur speed lab — REA</title>
<meta
name="description"
content="Read the dinosaur game’s speed rule with REA, rebuild it, then change the speed and play."
/>
<meta name="theme-color" content="#ffffff" />
<link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml" />
<link rel="stylesheet" href="../../assets/styles.css" />
<script src="../../assets/main.js" defer></script>
<script type="module" src="../../assets/dino-demo.js"></script>
</head>
<body id="top">
<a class="skip-link" href="#main">Skip to content</a>
<header class="site-header">
<div class="container header-inner">
<a class="brand" href="../../" aria-label="REA home"
><span class="brand-name">REA</span
><span class="brand-caption">Reverse Engineer Anything</span></a
>
<nav class="navigation" aria-label="Main navigation">
<a href="../../showcase/">Showcases</a
><a class="nav-start" href="../../get-started/">Get started</a
><a href="../../guides/">Guides</a><a href="../../faq/">FAQ</a>
</nav>
<a
class="nav-github"
href="https://github.com/morluto/rea"
aria-label="REA on GitHub"
title="REA on GitHub"
>
<svg
width="22"
height="22"
viewBox="0 0 16 16"
aria-hidden="true"
focusable="false"
>
<path
fill="currentColor"
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.65 7.65 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"
/>
</svg>
<span class="nav-github-count" hidden aria-hidden="true"></span>
</a>
</div>
</header>
<main id="main" class="container">
<div class="page-heading">
<p class="breadcrumb">
<a href="../../">Home</a><span>/</span>Dinosaur speed lab
</p>
<p class="eyebrow">Inspect → rebuild → change</p>
<h1>Rebuild the dinosaur’s speed rule.</h1>
<p class="lede">
REA found how the running game increases its speed. This small
reconstruction lets you keep that rule or choose a new speed and play.
</p>
</div>
<div class="article-layout">
<nav class="contents" aria-label="On this page">
<p>On this page</p>
<ul>
<li><a href="#play">Play and change the speed</a></li>
<li><a href="#rule">Read the recovered rule</a></li>
<li><a href="#check">Check the reconstruction</a></li>
<li><a href="#inspect">Try the analysis</a></li>
</ul>
</nav>
<article class="article" aria-label="Dinosaur speed reconstruction">
<section class="article-section" id="play">
<h2>Play and change the speed</h2>
<p>
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.
</p>
<figure class="dino-demo dino-lab-demo" data-dino-demo>
<p class="figure-title">Play the reconstruction</p>
<div class="dino-stage">
<svg
class="dino-fallback"
viewBox="0 0 600 180"
role="img"
aria-label="A small dinosaur running toward a cactus. Recovered speed: starts at 6, increases by 0.001 per update while below 13."
>
<path
d="M0 150H600 M55 113v-30h17V65h27v24H85v17H72v16H62v13h-7v-22m-5-8v-8h-8v-9h-6v22h19m14 15v15h8v-7h-4v-8 M420 150v-48h10v48m-10-15h-12v-22h7v15h5m10-4h12v-22h-7v15h-5"
fill="currentColor"
/>
<text
x="300"
y="65"
text-anchor="middle"
fill="currentColor"
font-size="18"
>
6 → 10 → 13
</text>
</svg>
<canvas
width="600"
height="180"
tabindex="0"
aria-label="Dinosaur mini-game. Use the Jump button or press Space while the game is focused."
hidden
></canvas>
</div>
<div class="dino-controls" hidden>
<div class="dino-buttons">
<button class="button" type="button" data-dino-start>
Play
</button>
<button type="button" data-dino-jump>Jump ↑</button>
<button type="button" data-dino-reset>Restart</button>
</div>
<label class="dino-speed-label"
>Speed <output data-dino-speed>6.0</output
><input
type="range"
min="2"
max="18"
step="0.1"
value="6"
data-dino-slider
/></label>
<label class="dino-auto-label"
><input type="checkbox" data-dino-auto checked /> Use the
recovered acceleration rule</label
>
</div>
<p class="dino-status" data-dino-status role="status">
Original rule: start at 6, then increase toward 13.
</p>
<figcaption>
Move the slider to set your own speed. Space or Jump clears a
cactus.
</figcaption>
<noscript
><p class="caption">
Enable JavaScript to play the reconstruction. The code and
explanation above remain readable.
</p></noscript
>
</figure>
</section>
<section class="article-section" id="rule">
<h2>What REA found</h2>
<p>
We inspected
<a href="https://wayou.github.io/t-rex-runner/"
>wayou’s Chromium-derived browser edition</a
>
with REA. It returned the loaded <code>index.js</code>, including
this branch in the game’s update function:
</p>
<div class="code-block">
<div class="code-header">
<span>REA · selected script source</span>
</div>
<pre><code>if (this.currentSpeed &lt; this.config.MAX_SPEED) {
this.currentSpeed += this.config.ACCELERATION;
}</code></pre>
</div>
<p>
The settings are <code>SPEED: 6</code>,
<code>ACCELERATION: 0.001</code> and <code>MAX_SPEED: 13</code>.
The game runs this branch on an update without a collision.
</p>
<h3>Use the same rule in the new game</h3>
<div class="code-block">
<div class="code-header">
<span>Reconstruction · dino-speed.js</span
><button
class="copy-button"
type="button"
data-copy="lab-speed-rule"
aria-label="Copy reconstructed speed rule"
>
Copy
</button>
</div>
<pre><code id="lab-speed-rule">function advanceSpeed(speed) {
return speed &lt; 13 ? speed + 0.001 : speed;
}</code></pre>
</div>
<p>
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.
</p>
<p>
<a href="../../assets/dino-speed.js" download
>Download the speed rule</a
>
· <a href="../../assets/dino-demo.js">Read the game code</a>
</p>
</section>
<section class="article-section" id="check">
<h2>Check the reconstruction</h2>
<p>
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.
</p>
<div class="table-scroll">
<table class="speed-check-table">
<thead>
<tr>
<th>Updates</th>
<th>Original game</th>
<th>Reconstructed rule</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>6.000</td>
<td data-speed-updates="0">6.000</td>
</tr>
<tr>
<td>1,000</td>
<td>7.000</td>
<td data-speed-updates="1000">7.000</td>
</tr>
<tr>
<td>4,000</td>
<td>10.000</td>
<td data-speed-updates="4000">10.000</td>
</tr>
<tr>
<td>10,000</td>
<td>13.001</td>
<td data-speed-updates="10000">13.001</td>
</tr>
</tbody>
</table>
</div>
<button class="button" type="button" data-speed-check hidden>
Run the speed check
</button>
<p class="caption" data-speed-check-status role="status">
Values rounded to three decimals. The branch checks before adding,
so the final increment can take speed just above 13.
</p>
</section>
<section class="article-section" id="inspect">
<h2>Try the analysis yourself</h2>
<ol>
<li>
<a href="../../get-started/">Set up REA</a> with your coding
agent.
</li>
<li>
Follow the
<a href="../../guides/browser/#prepare"
>browser connection steps</a
>, using <code>https://wayou.github.io/t-rex-runner/</code> as
the page URL.
</li>
<li>
Give your agent the page URL and local debugging endpoint, then
copy this prompt.
</li>
</ol>
<div class="agent-terminal">
<div class="terminal-header">
<span class="terminal-title"
><span class="terminal-dots" aria-hidden="true"
><i></i><i></i><i></i></span
>Your coding agent</span
><button
class="copy-button"
type="button"
data-copy="lab-analysis-prompt"
aria-label="Copy dinosaur analysis prompt"
>
Copy
</button>
</div>
<p class="terminal-prompt">
<span class="prompt-symbol" aria-hidden="true">›</span
><span id="lab-analysis-prompt"
>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.</span
><span class="terminal-cursor" aria-hidden="true"></span>
</p>
</div>
<p>
Ask a follow-up:
<strong
>“Where is jump height calculated? Add a jump-height control to
the new version.”</strong
>
</p>
<p class="caption">
Source:
<a
href="https://github.com/wayou/t-rex-runner/blob/5455bfa408ec6b707c7300ff194b7390733a766d/index.js#L565-L571"
>inspected speed code</a
>, Chromium Authors.
<a href="../../assets/licenses/dinosaur.txt"
>Copyright and BSD license</a
>. REA 4.1.0 inspected the running HTTP edition in Chrome 150.
</p>
</section>
</article>
</div>
</main>
<footer class="site-footer">
<div class="container footer-inner">
<p>REA · Reverse Engineer Anything</p>
<div class="footer-links">
<a href="https://github.com/morluto/rea">Source</a
><a href="https://github.com/morluto/rea/blob/main/LICENSE"
>MIT license</a
><a href="https://discord.gg/GkcryMnJDM">Community</a>
</div>
</div>
</footer>
<p class="sr-only" id="copy-status" role="status" aria-live="polite"></p>
<a class="back-to-top" href="#top" aria-label="Back to top"
><span aria-hidden="true">↑</span> Top</a
>
</body>
</html>