← Groundhog Blog

Shipping Playable Worlds with AI Agents

Lessons from building browser-native interactive experiments alongside coding agents: tight feedback loops, deterministic physics, and visual self-verification.

Retro-futuristic delta-wing interceptor gliding above a luminous wireframe horizon.

Static mock-ups lie. You can spend hours tweaking a colour palette or writing a tidy entity-component architecture, only to discover in the first five seconds of play that the turn rate feels sluggish, the camera lags behind the ship, or the HUD obscures the horizon.

Building small, playable browser worlds with AI agents taught me that tight verification loops matter even more for interactive media than for backend services.

Separate Simulation from Presentation

The single highest-leverage pattern when collaborating with coding agents on canvas or WebGL prototypes is keeping the simulation step pure and deterministic:

export interface CraftState {
  x: number;
  y: number;
  vx: number;
  vy: number;
  heading: number;
}

export function stepCraft(state: CraftState, thrust: number, turn: number, dt: number): CraftState {
  const heading = state.heading + turn * dt;
  const ax = Math.cos(heading) * thrust;
  const ay = Math.sin(heading) * thrust;
  return {
    x: state.x + state.vx * dt,
    y: state.y + state.vy * dt,
    vx: (state.vx + ax * dt) * 0.992,
    vy: (state.vy + ay * dt) * 0.992,
    heading,
  };
}

When physics, scoring, and collision checks live in pure TypeScript modules, an agent can write fast Node unit tests to verify invariants—no NaN velocities, bounded arena coordinates, deterministic replays—before a single pixel is rendered.

Visual Self-Verification Closes the Gap

Unit tests confirm the maths; screenshots confirm the craft. Whenever an agent touches layout, shaders, or HUD typography, we require a desktop and mobile capture pass:

  • Desktop (1440×900): Check sightlines, contrast, frame pacing, and whether the primary canvas dominates the viewport without clutter.
  • Mobile (390×844): Verify touch targets, safe-area padding, and zero horizontal overflow.

Reviewing real rendered artefacts catches subtle layout regressions—overlapping badges, clipped typography, or muddy contrast—that text-only diffs completely miss.

Small Worlds, High Craft

You don’t need a sprawling engine to build something memorable on the open web. A crisp WebP hero, a disciplined typography scale, a fixed-timestep loop, and a fast static bundle on the edge are enough to ship an experience that loads in milliseconds and feels genuinely alive.