gitflarePublicPartly agent-ready40
neon-drift
Real-time multiplayer arcade racer on Cloudflare Workers and Durable Objects.
- LicenseApache-2.0
- LanguageJavaScript
- Last landed
3efe3daOct 23, 2026
Add the Apache-2.0 licence
3efe3daconst args = process.argv.slice(2);const base = args[0] || 'http://localhost:8787';const opt = (n, d) => { const i = args.indexOf('--' + n); return i >= 0 ? args[i + 1] : d; };const N = +opt('bots', 4), SECONDS = +opt('seconds', 10);let room = opt('room', null);if (!room) room = (await (await fetch(base + '/api/quickplay')).json()).code;const wsUrl = base.replace(/^http/, 'ws') + '/ws/' + room;const bytes = [], rtts = [];let snaps = 0, disconnects = 0; function bot(i) { const ws = new WebSocket(wsUrl); let seq = 0, tick = -1, turn = 0, timers = []; ws.onopen = () => { ws.send(JSON.stringify(['j', 'bot' + i, null, null])); timers.push(setInterval(() => { if (Math.random() < 0.1) turn = Math.floor(Math.random() * 3) - 1; ws.send(JSON.stringify(['i', ++seq, turn, Math.random() < 0.05 ? 1 : 0, tick])); }, 33)); timers.push(setInterval(() => ws.send(JSON.stringify(['p', Date.now()])), 1000)); timers.push(setInterval(() => ws.send(JSON.stringify(['a', tick])), 100)); }; ws.onmessage = (ev) => { const s = String(ev.data); const m = JSON.parse(s); if (m[0] === 's') { snaps++; bytes.push(s.length); tick = m[1]; } else if (m[0] === 'w') tick = m[5]; else if (m[0] === 'o') rtts.push(Date.now() - m[1]); }; ws.onclose = () => { disconnects++; timers.forEach(clearInterval); }; return ws;} const socks = Array.from({ length: N }, (_, i) => bot(i));await new Promise((r) => setTimeout(r, SECONDS * 1000));const pct = (a, p) => (a.length ? [...a].sort((x, y) => x - y)[Math.min(a.length - 1, Math.floor(a.length * p))] : 0);const mean = (a) => (a.length ? a.reduce((x, y) => x + y, 0) / a.length : 0);const dis = disconnects;console.log(JSON.stringify({ room, snapshotHz: +(snaps / N / SECONDS).toFixed(1), bytesPerTick: Math.round(mean(bytes)), bytesMean: Math.round(mean(bytes)), bytesP95: pct(bytes, 0.95), rttMean: +mean(rtts).toFixed(1), rttP95: pct(rtts, 0.95), disconnects: dis }));socks.forEach((s) => s.close());process.exit(0);