20 Commits
Author SHA1 Message Date
Richard HarringtonandClaude Fable 5 b763b795ab Replace damage desaturation with body gradient and escalating marks
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>
2026-07-13 06:31:15 -04:00
Richard HarringtonandClaude Fable 5 861a5bd8a9 Tier 2 Slice F: DOM victory overlay with leaderboard + Play Again
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>
2026-07-11 22:16:28 -04:00
Richard HarringtonandClaude Fable 5 2a8d419245 Tier 2 Slice E: particle-based robot death animation
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>
2026-07-11 22:10:16 -04:00
Richard HarringtonandClaude Fable 5 74a7b1f981 Tier 2 Slice D: per-robot body shapes (square / circle / diamond)
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>
2026-07-11 22:04:39 -04:00
Richard HarringtonandClaude Fable 5 a4b2846676 Tier 2 Slice C: visual damage — desaturation + procedural marks
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>
2026-07-11 22:02:21 -04:00
Richard HarringtonandClaude Fable 5 e154efd61e Tier 2 Slice B: battle sound effects + persistent sound toggle
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>
2026-07-11 21:56:42 -04:00
Richard HarringtonandClaude Fable 5 b014ef7e95 Tier 2 Slice A: migrate audio to the Web Audio API
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>
2026-07-11 21:50:51 -04:00
Richard HarringtonandClaude Fable 5 4de943f2a1 Lock down all open decisions in the Tier 2 spec
Resolve every TO DECIDE item so an agent can implement the whole plan
without human input. Human-locked: all-synthesized SFX (no downloaded
assets), toggle UI (top-right button + '4' key, localStorage), continuous
desaturation + discrete damage marks, square/circle/diamond shape palette,
implementer-judged death transition via screenshots, death extras deferred,
terminal-vintage victory style with ticks-survived stat and minimal
leaderboard. Remaining judgment calls relabeled TACTICAL with their
recommendations kept as defaults.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 21:26:54 -04:00
Richard Harrington 5e3c9478f8 Added some things to look over in the future
A few minor issues came up in an AI review, not going to deal
with them now. Put them in a spec.
2026-07-11 20:47:17 -04:00
Richard HarringtonandClaude Opus 4.7 19255ccbb6 Implement Step 7 of gap-closing: restart UX + input validation
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>
2026-07-11 19:47:51 -04:00
Richard HarringtonandClaude Opus 4.7 4dfba97c87 Implement Step 6 of gap-closing: RADAR register
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>
2026-07-11 19:30:41 -04:00
Richard HarringtonandClaude Opus 4.7 65a15af7c6 Implement Step 5 of gap-closing: circle-circle robot collisions
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>
2026-07-11 15:32:27 -04:00
Richard HarringtonandClaude Opus 4.7 2bf983686b Implement Step 4 of gap-closing: wall blocking + damage
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>
2026-07-11 15:17:24 -04:00
Richard Harrington 81f75d5828 add legend 2026-06-11 21:52:49 -04:00
Richard Harrington 029787eaac update spec for step 3.5
Add a legend with damage percentages for each robot.

Arguably belongs in Tier 2 polish, but will be really
helpful for telling what's going on during development.
2026-06-11 21:38:47 -04:00
Richard Harrington 39c4ead560 Refactor: store shells as {id shell} map throughout, remove shell-map hack 2026-06-10 22:49:29 -04:00
Richard Harrington d69d002d26 Implement Step 2 of gap-closing: shells that do damage 2026-06-10 22:49:29 -04:00
Richard Harrington 163266c4d6 gap-closing Step 1: Add plumbing for robots to get damaged and die 2026-06-10 22:49:29 -04:00
Richard Harrington 56bac570d1 Made two-step spec for closing implementation gap 2026-05-26 07:21:58 -04:00
Richard Harrington 32a55d10e5 Reorganize and update docs, readmes, resources 2026-05-26 07:21:58 -04:00