Make the page playable: interactive board, live solver, and a usable run picker
Three things the build was quietly missing. The interactive board was never mounted. The contract has `interactive.init` and `interactive.Controls`, the demo implemented both, and the shell's `split-play` beat rendered only the replay — so the beat titled "you and the model get the same word" showed one board. PlayYourself now renders the visitor's attempt from the same seed as the run beside it, generically: it knows only the contract, so any demo shipping an interactive mode gets it and one that does not renders nothing rather than an empty pane. solver.worker.ts was dead code — nothing constructed it, which is how CI caught it: `new Worker(` appeared nowhere in the bundle. It is wired now behind "what would the best player guess?", and it answers in 92ms from a real worker on boards no recording covers. That is the difference between a demo and a video. It also surfaces the moment the solver picks a word that CANNOT win, which is the counterweight visible in one line instead of explained in a paragraph. The CI check that found it was itself wrong: it grepped every bundled file for `blob:`, which React's own code contains in a scheme check, so it failed on a risk that was not present. It now greps for worker construction from a blob, which is the thing production CSP actually blocks in silence. And the run switcher was thirty buttons carrying four distinct labels. Split into arm and seed, holding the seed across an arm change — comparing two agents means comparing them on the same hidden word, and silently jumping seeds would break that while looking fine. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019mt6sHQHEnEYrJZvoMCJSB
This commit is contained in:
+52
-1
@@ -18,6 +18,7 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
@@ -47,6 +48,7 @@ ARMS = {
|
||||
"base-off": {"label": "Out of the box", "thinking": False},
|
||||
"base-on": {"label": "Allowed to think", "thinking": True},
|
||||
"solver": {"label": "Best-known play", "thinking": None},
|
||||
"cautious": {"label": "Never wastes a guess", "thinking": None},
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +107,53 @@ def call_model(messages: list[dict], thinking: bool) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def cautious_turn(game: Game) -> dict:
|
||||
"""Only ever guesses a word that could still be the answer.
|
||||
|
||||
This arm exists because the reward's counterweight is a claim about a
|
||||
trade-off, and a trade-off with only one policy on the board is a claim
|
||||
nobody can check. It never spends a turn on a word that cannot win, so it
|
||||
takes `consistency` outright — and it pays for that in turns, because it
|
||||
cannot buy information with a guess that has no chance. Weight the reward
|
||||
one way and it beats the entropy solver; weight it the other and it loses.
|
||||
That is the whole argument, made with two recorded runs instead of a claim.
|
||||
"""
|
||||
pool = answers()
|
||||
alive = [w for w in S.consistent_candidates(game.history) if w not in {g for g, _ in game.history}]
|
||||
if not alive:
|
||||
guess = "tares"
|
||||
else:
|
||||
# Most informative CANDIDATE, not first alphabetically. Same objective as
|
||||
# the solver, restricted action set — which is the honest contrast. A
|
||||
# policy that opens on whatever sorts first looks incompetent rather than
|
||||
# cautious, and would make the trade-off it exists to demonstrate look
|
||||
# like a straw man.
|
||||
index = np.array([pool.index(w) for w in alive])
|
||||
best, best_bits = alive[0], -1.0
|
||||
for word in alive:
|
||||
counts: dict[int, int] = {}
|
||||
row = S.pattern_matrix()[pool.index(word)]
|
||||
for j in index:
|
||||
code = int(row[j])
|
||||
counts[code] = counts.get(code, 0) + 1
|
||||
total = len(alive)
|
||||
bits = -sum((c / total) * math.log2(c / total) for c in counts.values())
|
||||
if bits > best_bits:
|
||||
best, best_bits = word, bits
|
||||
guess = best
|
||||
return {
|
||||
"reply": f"[{guess}]",
|
||||
"reasoning": None,
|
||||
"call": {
|
||||
"promptTokens": None,
|
||||
"completionTokens": None,
|
||||
"reasoningTokens": None,
|
||||
"durationMs": None,
|
||||
"finishReason": "generated",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def solver_turn(game: Game) -> dict:
|
||||
"""The reference player, recorded in the same shape as a model turn.
|
||||
|
||||
@@ -145,6 +194,8 @@ def capture(arm: str, seed: int) -> dict:
|
||||
while not game.over and len(turns) < MAX_GUESSES * 2:
|
||||
if arm == "solver":
|
||||
result = solver_turn(game)
|
||||
elif arm == "cautious":
|
||||
result = cautious_turn(game)
|
||||
else:
|
||||
result = call_model(messages, bool(config["thinking"]))
|
||||
|
||||
@@ -183,7 +234,7 @@ def capture(arm: str, seed: int) -> dict:
|
||||
return {
|
||||
"runId": f"{arm}-s{seed}",
|
||||
"seed": seed,
|
||||
"model": MODEL if arm != "solver" else "entropy-solver",
|
||||
"model": {"solver": "entropy-solver", "cautious": "candidate-only-solver"}.get(arm, MODEL),
|
||||
"capturedAt": time.strftime("%Y-%m-%d"),
|
||||
"rewards": score(episode),
|
||||
"metrics": metrics(episode),
|
||||
|
||||
Reference in New Issue
Block a user