Inspiration

An adaptive rival is compelling only if you can feel the difference on the next attempt without the first fight ever stuttering or waiting for a model.

What it does

Parry, dodge, and break the Warden's posture in a WebGL 2 duel. Win or lose, open the Nemesis Director with I to see the bounded fight trace and the next doctrine. Repeat a habit and try the rematch; the Director shows whether rules, an on-device model, or cloud Gemini supplied the doctrine. Keyboard and touch controls are available.

How we built it

Combat uses a deterministic core and can accept bounded local tactics from an available device model; it never calls cloud inference mid-fight. Between rounds, Firebase AI Logic's InferenceMode.PREFER_ON_DEVICE can use a ready model or fall back to attested Gemini. The Director validates the returned doctrine and shows its actual InferenceSource. Only gameplay counters and timing bins enter the prompt. reCAPTCHA Enterprise App Check guards requests, Remote Config selects the model, and anonymous Auth and Firestore can sync limited runs between duels. Airplane mode disables sync and cloud inference. The optional Swift iOS shell is in the repo.

Challenges we ran into

A result arriving after a player hits Duel again must not change a fight already in progress. The local doctrine is available immediately; starting the rematch cancels pending model work and keeps the chosen doctrine stable for that duel.

Accomplishments that we're proud of

A full hosted Mac Chrome duel recorded zero in-combat cloud calls. After the fight, an attested Firebase AI Logic request returned HTTP 200 and the IN_CLOUD doctrine Trace Echo Sentinel carried into duel two. The narrated demo shows the playable local-fallback path; the live hosted cloud result was verified separately.

What's next

Expand doctrine variety and replay-based regression tests, then verify native Apple Foundation Models availability and fallback behavior on supported iPhones.

Built With

  • apple-foundation-models
  • bun
  • cloud-firestore
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-hosting
  • firebase-remote-config
  • gemini-nano
  • swift
  • typescript
  • web-audio-api
  • webgl-2
Share this project:

Updates

Submission history