Typing a lineup and pressing return while the victory overlay was
showing started a new battle underneath it. The input is now disabled
when the overlay appears, dimmed while disabled, and re-enabled (and
refocused) by the restart flow.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
MAX-WALL-DAMAGE 15 -> 30, MAX-COLLISION-DAMAGE 25 -> 50, quadratic
falloff unchanged. First tuning step toward shorter battles: headless
sims show contact-heavy matchups (hunter vs hunter-lead) dropping from
~8 to ~3-7 game-minutes, while shell-dominated duels are unaffected
(~3-4 min). Robots that decelerate into every destination still take
almost nothing from their gentle bumps; if that still feels wrong in
live playtesting, the agreed fallback is switching the falloff from
quadratic to linear (see resources/ai-specs/polishes-jul-12-spec.md).
Both test suites reference the constants symbolically and stay green.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Robot deaths now kick the arena canvas (never the page) with a
decaying-sinusoid shake (6px, 300ms), leave a permanent ash-gray
mottled scorch mark at the death site drawn beneath everything for the
rest of the battle, and the burst itself grows: 50 particles (was 30),
1.2s total (was 0.9s), plus a delayed white echo ring behind the
existing colored one.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The one-frame solid white disc becomes a 500ms wall-clock animation
(same presentation-state pattern as death animations, so fast-forward
doesn't shrink it): a warm radial-gradient fireball — white core
through yellow/orange to a fully transparent rim — that grows fast for
the first third and fades in place, plus a thin shockwave ring that
outruns it. The disc's transparent edge peaks exactly at BLAST-RADIUS
so the graphic still shows the true damage zone, and explosions now
spawn at the shell's actual detonation point (dest-x/dest-y).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Robots now keep their full palette color at all damage levels (matching
the legend swatches). Damage reads from a center-bright radial gradient
whose rim darkens with damage (capped at 35%), plus damage marks that
escalate through tiers: dents, then jagged cracks, then cracks with
dark blotches and notches bitten out of the silhouette. Bodies are
composed on an offscreen sprite canvas so notches can erase through
the silhouette without damaging what's underneath on the main canvas.
Spec for this and the rest of the polish pass:
resources/ai-specs/polishes-jul-12-spec.md
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Fix docstring placement
- Use :else as catch-all expression in cond
- Change :use/:only to :require/:refer
- Update deprecated function names from clj-time.core
- Do not :refer :all
Escalates these three linters from warning to error in
.clj-kondo/config.edn so they block commits going forward, and cleans
up the 27 pre-existing instances: unused bindings get an underscore
prefix (Clojure's intentional-unused convention), unused requires and
refers are removed outright. Verified with the full test suite (82
tests, 163 assertions, all passing).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Wires up clj-kondo linting and cljfmt formatting via deps.edn aliases,
a pre-commit hook, and VS Code settings (format-on-save, trim trailing
whitespace) so style issues get caught before they land. Applies
cljfmt's fixes across the existing codebase and removes stray trailing
whitespace so the tree starts from a clean baseline.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Replace the Tier 1 canvas-text victory overlay with a styled HTML
overlay in the terminal-vintage look: winner name in the winner's
color (white TIE for ties), a minimal leaderboard (swatch, name,
ALIVE/DESTROYED, ticks survived; winner first then by ticks survived),
a PLAY AGAIN button wired to the existing restart flow, and a subtle
CRT scanline layer. The overlay fades in only after Slice E's death
animation finishes, so the battle-ending explosion plays out first.
Engine hook (slightly bigger than the plan's one-liner): the world map
had no tick counter — the tick count lived only in app state — so
world.cljc gains a :tick key (0 at init, incremented per
tick-combined-world, defaulting to 0 for hand-built worlds) and robots
record :died-at-tick when marked dead, guarded so later ticks don't
overwrite it. Covered by new JVM tests and a CLJS smoke test.
The Tier 1 canvas fillText block is removed; Enter-to-restart is
preserved, and the click-canvas restart is superseded by the button
(the overlay covers the canvas). restart-game! hides the overlay.
Verified headlessly: winner and tie scenarios, ordering, Play Again
returning focus to the form, 45s natural battle with zero console
errors, both suites green. Spec updated (Slice F resolutions,
addendum, Tier 2 completion note).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
When a robot's :alive? flips false, its spot erupts: a 150ms white
flash disc, an expanding ring in the robot's color (explode-shell's
visual language), and 30 sparks fanning outward over up to 900ms.
- Animation state is a death-animations atom in canvas.cljs, keyed by
robot idx; the engine is untouched. app.cljs diffs alive->dead per
frame and spawns the burst at the robot's last position (the death
sound already fires on the same transition from Slice B).
- Particles are deterministic per (robot-idx, particle-number) and
store only velocity + max age; position/alpha/size are pure
functions of age (ease-out drift, quadratic fade, 3px->1px shrink).
Ticking advances a single wall-clock age per animation, so the
animation runs at the same speed regardless of fast-forward.
- Body-to-particles transition, judged from screenshots per the locked
process: immediate vanish (a) anchored fine thanks to the colored
ring, but lacked punch, so the white-flash beat from option (c) was
layered on. Shipped (a) + flash.
- Plan gap: the RAF loop stops at :result, which froze the
battle-ending death's animation. Added a game-over-step wind-down
loop that keeps drawing until animations finish; restart clears the
animation atom.
Verified via kill-injection screenshots (single death and a 4-robot
battle-ending kill). Spec updated (Slice E resolutions + addendum).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Robots now render as one of three body shapes chosen by idx mod 3,
echoing the shape variety visible in the original 1981 game. Collision
detection is untouched — still circle-circle at ROBOT-RADIUS.
A single body-path helper builds each shape's canvas path and serves
both the body fill and the clip region for Slice C's damage marks, so
marks stay inside any silhouette. The diamond's vertex radius is
inflated 1.2x for visual parity (equal-radius diamonds read half the
size of squares). Gun stub and gun line are unchanged across shapes;
the stub fits inside every silhouette. Mark centers get per-shape
offset bounds so the clip rarely swallows one.
Verified via injected-damage screenshots across all three shapes.
Spec updated (Slice D resolutions + addendum).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Robots now wear their damage: body color desaturates linearly with
:damage (hex palette converted to HSL once; display color emitted as a
CSS hsl() string, grey at zero), and short dark scratch marks
accumulate one per 20 damage lost.
Mark geometry is a pure function of (robot idx, mark number) via a
fract(sin) hash, so marks never re-roll frame to frame and existing
marks stay put as damage keeps dropping. This deviates from the spec's
suggested (idx, damage) seed, which would have re-rolled every mark on
each damage change — noted in the spec addendum.
The Tier 1 hit flash (white body on the frame damage drops) is
preserved and composes with desaturation.
Verified by injecting damage tiers 90/70/45/25/5 into a running battle
and screenshotting close-ups. Spec updated (Slice C resolutions +
addendum).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add the four Tier 1 event sounds and a sound on/off toggle:
- :shell-explosion decodes the parked concuss5.{ogg,mp3} asset.
- :robot-collision, :wall-crash, :robot-death are synthesized at page
load via OfflineAudioContext (no new assets): the two contact thuds
share a filtered-noise + sine-drop recipe with different cutoffs and
pitches; the death sound layers a metallic clang (inharmonic
partials), a swept noise burst, a deep pitch drop, and a low rumble
over 1.6s.
- Volume mix via a static sound-volumes map applied through a per-play
GainNode into the Slice A master gain.
- Event detection is a pure presentation-layer diff (play-battle-sfx!):
the engine's existing :touching-walls / :colliding-with sets and
:alive? flag carry all the transition signals, so the plan's optional
:last-damage-cause engine hook was not needed.
- Sound toggle: speaker button overlaid top-right of the canvas plus a
"4" keyboard shortcut (manual's Option 4), persisted to localStorage,
default on; play! short-circuits when off. Toggling also bootstraps
the AudioContext, being a user gesture.
Verified headlessly: toggle via button and key, persistence across
reload, full battle with zero console errors. Spec updated (Slice B
resolutions + addendum).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Replace the 40-element pooled-HTMLAudioElement shell-fire sound in
app.cljs with a new robotwar.audio namespace built on the Web Audio API:
- AudioContext constructed lazily on the first Enter keypress (autoplay
policy), with a master GainNode ready for Slice B's volume mixing.
- Sound files fetched as ArrayBuffers at page load; decoding is deferred
until the context exists, since decodeAudioData requires a context and
detaches its input buffer (decode exactly once).
- play! creates a fresh AudioBufferSourceNode per playback (unlimited
polyphony) and no-ops silently if the buffer isn't ready.
- ogg-with-mp3-fallback canPlayType check preserved.
Spec updated with resolved TACTICAL items and a Slice A addendum.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Canvas rendering of alive-only robots and the victory overlay were already
in place; this pass adds the remaining Step 7 pieces:
- restart-game! reverses start-transition (canvas + legend inline opacity
back to 0, instruction-box height cleared), clears :world/:tick-count,
and refocuses the input.
- Enter (via the document-level on-keydown) and canvas click trigger
restart when a :result is present.
- on-program-input-keydown rejects submits with fewer than 2 valid
program names and surfaces the error in a new #inputError paragraph
(fixed min-height to avoid layout shift on show/clear).
Tier 1 spec extended with Addendum A.31-A.37 documenting the state
found on entry, the routing of the Enter trigger through the document
handler, and the manual-verification gap in this pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Cast a ray from the firing robot along the direction stored in RADAR,
returning a signed distance: negative if the closest alive non-self
robot's disc is hit first, positive to the arena wall the ray exits
otherwise. Ray-vs-disc and ray-vs-wall math live in physics.cljc as
pure helpers. The register write stores mod-360 direction; the read
does the geometry against current world state, so scans reflect
end-of-tick positions.
Spec updated with Step 6 execution addendum (§A.25-A.30) covering the
chosen quadratic formulation, the "write is not a triggering side
effect" pattern, and the reader-conditional paren-count gotcha
encountered when threading a new extend block into #?(:clj ... :cljs ...).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replace the old axis-by-axis square collision logic and the (dec damage)
placeholder with a single per-tick pair pass driven from
tick-combined-world. Detects overlap via 2 × ROBOT-RADIUS circle-circle,
separates along the contact normal, swaps normal-component velocities
when approaching, and applies quadratic-falloff damage on the tick a
pair transitions into contact. First-contact tracking uses each robot's
new :colliding-with set of counterparty idxs. Adds JVM + CLJS tests for
head-on, glancing, stationary, first-contact-only, circle-vs-square,
separation, velocity-swap, non-approaching, and dead-robot exclusion.
Removes the now-dead update-robots helper and updates the spec's Step 5
addendum with the tactical choices and gotchas encountered.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
move-robot now clamps position to [0, ROBOT-RANGE-X] x [0, ROBOT-RANGE-Y],
zeros the perpendicular velocity on any touched wall (slide behavior),
and applies quadratic MAX-WALL-DAMAGE * (v_perp / V-MAX)^2 damage only on
the tick a wall is newly touched. Robots track :touching-walls to detect
first-contact transitions across ticks. desired-v-x/y are left alone --
the brain is on the hook to notice via X/Y polling.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>