// 04 RESTRICTED
twiddler
A rhythm game for fingertips. The big screen shows the track and the gesture being called; a phone is only the touchpad, joined by QR code and a four-letter room code and linked straight to the screen over WebRTC. Ten note types (taps, swipes, circles, figure eights, scrubs, pinches, spreads, twists, holds and drawn shapes) are graded on timing, accuracy, tempo and flow, over a backing track synthesized in the browser. The TWIDDLER game in carterbox was ported from it.
How it keeps time
- Each phone opens two data channels:
ctl, reliable and ordered, for touches, lifts and game state; andmov, unordered with no retransmits, for finger positions, where a late sample is worth nothing. The signaling WebSocket stays behind as a relay when a direct link cannot form. - A phone stamps each sample on its own clock. The screen maps that onto its own from ping round trips, trusting the fastest recent one, and believes a stamp up to half a second old.
- The backing track is scheduled against the judge's clock and pulled earlier by the output latency, plus a stored offset for TVs and Bluetooth speakers.
- The gesture maths is pure functions with no DOM, so the same file grades in the browser and under Node. Sixteen tests check that the ideal stroke for every gesture grades excellent, a messy one still passes, a circle drawn the wrong way misses, a second finger cannot double the lap count, and the four drawn shapes are never read as each other.
- Room codes leave out I, L and O, which misread on a TV.
Stated honestly
Version 0.1.0, with two tracks at 96 and 120 bpm. It runs on a laptop on the same Wi-Fi as the phones and is not deployed.