Phase 2 — Brainstorm (Iteration 2)

Phase 2 — Brainstorm (Iteration 2)

Chosen concept

Add a toggleable Study Mode to the existing four-way race. The 4-up race remains the default "compare" view; toggling Study / Pseudocode on focuses a single algorithm and walks its pseudocode line by line, synced to its grid, with plain-English narration — a true program-counter view. The other three algorithms appear as small thumbnails to switch focus.

The key idea: one shared pseudocode skeleton

All four algorithms share the same control-flow skeleton and differ on only a few lines. We show one template and mark the divergent lines per algorithm — so the same artifact serves both R8 (pseudocode execution) and R7 (difference-highlighting):

push start to frontier
while frontier not empty:
  node ← remove "best" from frontier     ← BFS: oldest · Dijkstra: min g · Greedy: min h · A*: min g+h
  if node is goal: reconstruct path; stop
  mark node visited
  for each neighbor:
    skip if wall or visited
    cost ← g[node] + weight(neighbor)     ← BFS ignores weight (counts steps)
    if new or cheaper:                      ← BFS/Greedy: only if unseen (no re-open)
      update g, set parent, push to frontier

Decisions (locked)

Alternatives considered and rejected

Alternative Why rejected
Parallel pseudocode strips under all four grids Four live line-walks at once overwhelms; not true line-by-line
Ride-along slow-mo (race continues while focused one slow-walks) Busier; non-focused panels "jump" an expansion at a time — distracting
Separate pseudocode per algorithm (4 distinct listings) Misses the teaching gold: the algorithms are almost identical; a shared skeleton makes differences obvious
Real compilable source (JS/Python) Distracts from concept with language noise; pseudocode teaches better
Editable pseudocode / breakpoints Scope creep; not needed to teach

Scope boundaries

In scope (iteration 2):

Out of scope (deferred):

Security-relevant boundaries

Unchanged from iteration 1: fully offline, single file, no network/auth/storage/secrets, no new external input — only additional internal UI state. Discipline held: pseudocode and narration lines are built with textContent only (never innerHTML); no eval/new Function. The divergent-line annotations are static strings in code, not user-derived.