329 Commits
Author SHA1 Message Date
Richard HarringtonandClaude Fable 5 028ca4b698 Disable programs input while the victory overlay is up
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>
2026-07-13 07:12:09 -04:00
Richard HarringtonandClaude Fable 5 d35d0dd5a1 Double wall and collision damage maxima
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>
2026-07-13 06:50:53 -04:00
Richard HarringtonandClaude Fable 5 26819b37bb Add death screen shake, permanent scorch marks, and a beefier burst
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>
2026-07-13 06:40:17 -04:00
Richard HarringtonandClaude Fable 5 f31892c8cf Rebuild shell explosion as a fading fireball with shockwave ring
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>
2026-07-13 06:36:29 -04:00
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 Harrington 4f51b9fdda Deal with all remaining linter warnings
- 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
2026-07-12 11:17:34 -04:00
Richard Harrington d791925a13 fix test typo found by linter 2026-07-12 10:48:41 -04:00
Richard HarringtonandClaude Sonnet 5 81a0dc48a9 Promote unused-binding/namespace/referred-var to clj-kondo errors
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>
2026-07-12 10:46:18 -04:00
Richard HarringtonandClaude Sonnet 5 d8c22bddd5 Add clj-kondo + cljfmt tooling, reformat codebase
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>
2026-07-12 10:20:09 -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 Harrington d5e1d7b0fc Couple of test fixes
- test command itself fixed

- glancing collision tests added
2026-07-11 20:45:35 -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 4160f91558 some paren fixes 2026-06-11 21:14:22 -04:00
Richard Harrington 417ffa7614 robot death, winners and ties 2026-06-11 15:22:25 -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 249fc5abf2 Add AGENTS.md 2026-06-10 21:56:23 -04:00
Richard Harrington c56a8f34d0 Remove obsolete Ring dev server entrypoint 2026-05-26 07:21:58 -04:00
Richard Harrington 71323ce5b3 Separate live and test robot manifests for safer default usage
Keep experimental or test-only programs out of normal play while
preserving deterministic fixtures for automated validation.
2026-05-26 07:21:58 -04:00
Richard Harrington 13a6713209 Remove obsolete server-era code after CLJS ownership is complete
Drop backend-only files and dependencies to reduce maintenance surface
and avoid confusion about the active runtime path.
2026-05-26 07:21:58 -04:00
Richard Harrington 2cef193ce8 Stabilize browser audio lifecycle for predictable gameplay feedback
Handle start/stop and reuse cases explicitly so sounds remain reliable
across resets and repeated matches.
2026-05-26 07:21:58 -04:00
Richard Harrington 783307d441 Port input and UI chrome to CLJS to remove jQuery dependency
Eliminate mixed event systems so interaction behavior is controlled from
one runtime and easier to evolve safely.
2026-05-26 07:21:58 -04:00
Richard Harrington 178129ed92 Shift the render loop into CLJS to retire legacy JS orchestration
Put update/draw timing under one CLJS flow to reduce split-brain behavior
and simplify future UI and engine integration work.
2026-05-26 07:21:58 -04:00
Richard Harrington b0cf308535 Introduce a CLJS engine driver with readable tick-level diagnostics
Move simulation control into the CLJS app layer so runtime behavior is
observable and debuggable as ownership shifts away from legacy JS.
2026-05-26 07:21:58 -04:00
Richard Harrington 3e68f0104e Add Node-based CLJS engine tests to protect shared logic
Run ClojureScript engine tests headlessly so portability changes can be
validated quickly without relying on browser-only checks.
2026-05-26 07:21:58 -04:00
Richard Harrington 25f73c6e62 Make core engine namespaces portable across Clojure and ClojureScript
Convert engine modules to .cljc to keep game rules in one place and
prevent JVM/CLJS logic drift during the frontend transition.
2026-05-26 07:21:58 -04:00
Richard Harrington ec43f5633c Load robot programs from public assets to decouple content from server code
Treat robot scripts as data files so the browser client can access the
same program set without backend-only source embedding.
2026-05-26 07:21:58 -04:00
Richard Harrington 1bf0d66c8e Standardize tests on clojure.test for cross-runtime execution
Use one native test framework so JVM and CLJS test paths stay aligned
and easier to maintain as engine logic becomes shared.
2026-05-26 07:21:58 -04:00
Richard Harrington d2e97a07d3 Establish a CLJS-first build and dev entrypoint
Move off Leiningen so browser work can iterate quickly with Shadow-CLJS
while preserving the existing game during migration.
2026-05-26 07:21:58 -04:00
Richard Harrington 914d9db23d Fix /init to return the created game id (not incremented next-id)
- capture current :next-id before swap!
- return captured id in /init response
- avoids off-by-one mismatch between /init id and /worlds/:id lookups
2026-05-24 21:23:51 -04:00
Richard Harrington 5885ecc7b2 tmp not exactly working, but closer! 2022-08-01 10:40:11 -04:00
Richard Harrington 3768178133 start restoring compojure (not entirely working yet) 2022-08-01 10:19:24 -04:00
Richard Harrington 8d4e942435 fix indentation in source_programs.clj 2022-07-30 15:49:15 -04:00
Richard Harrington e9eb478a54 got rid of core.match 2015-07-22 17:52:48 -04:00
Richard Harrington 90e31a4b22 whitespace 2015-07-22 17:38:45 -04:00
Richard Harrington 8923ee9ef7 standardizes routing; adds check for request method 2014-10-12 11:51:21 -04:00
Richard Harrington ca7b2dfb4b refactors get-programs using threading operator 2014-10-12 11:26:48 -04:00
Richard Harrington 5893e4b5e6 whitespace and other cosmetic changes 2014-10-12 11:25:32 -04:00
Frederik Andersen 595d5cde66 removed Compojure as a dependency, routing code changed 2014-10-08 18:48:49 +02:00
Richard Harrington 45a05fe236 changed shot distance slightly 2013-09-03 20:13:15 -04:00