Inspiration
Live streaming on Twitch is the ultimate interactive medium, yet for most viewers, participation is still confined to a narrow chat column. When a streamer is deep in a 10-hour raid or fighting a grueling boss in Elden Ring, viewer chat messages easily become lost in the noise, leading to "dead air" and passive lurking.
We asked ourselves: What if Twitch chat didn't just comment on the game, but could actively reshape the broadcast reality in real time?
With OpenAI Codex, natural language becomes executable mechanics. We envisioned ChaosForge Live — a zero-latency, zero-eval interactive engine that listens to live Twitch chat, compiles viewer chaos ideas (!forge) into validated Abstract Syntax Trees (AST) in under 2 seconds, and broadcasts interactive 2D physics directly onto the streamer’s OBS screen. To celebrate Twitch culture, we injected the legendary Meme Chaos Pack (Bonk Doge, Popcat, Vine Boom SFX, and Neon Floating Reactions), turning every livestream into an electrifying spectator arena.
What It Does
ChaosForge Live creates an uninterrupted 45-second interactive cycle across three dedicated surfaces:
- Virtual OBS Demo Stage (
/#stage):- Built-in Twitch chat listener and 1-Click 500-Viewer Crowd Simulator for judges to instantly experience realistic chat hype without needing an active Twitch broadcast.
- Built-in interactive mini-game allowing streamers/judges to fly a ship and test entity collisions in real time.
- Transparent OBS Browser Source (
overlay.html—1920×1080):- A crystal-clear browser source with Center 60% Safe Zone (
1152 × 648 px): entities spawn at the edge ring, automatically dimming to 70% opacity if crossing the center to prevent obscuring gameplay crosshairs or webcam feeds. - 2D Canvas rendering at 95+ FPS with zero bitmap dependencies.
- Custom Web Audio API synthesizers producing 8-bit retro arcade tones and meme sound effects (Bonk, Bruh, Vine Boom) without external audio files.
- A crystal-clear browser source with Center 60% Safe Zone (
- Streamer Control Deck (
/#deck):- Real-time round orchestration with Spacebar Panic Clear (< 60ms): an instant kill-switch wiping all entities and muting sound within one frame.
- 2-Streamer Raid Room (
TW26): Streamers can connect across rooms and "Raid" rival streams by firing chaos cartridges directly onto each other's screens. - Saved Cartridges Library: Deploy pre-built classics like Bonk Doge Hammer Storm, Popcat Chorus Hype, and Laser Boss.
How We Built It
We built ChaosForge Live from the ground up using OpenAI Codex as our lead architect and pairing partner:
- OpenAI Codex Structured Outputs (
json_schema): We strictly forbadeeval(). Codex generates a deterministic JSON AST schema defining entity types (duck | ball | star | boss | doge | popcat), gravity vectors, collision modes (bounce | wrap | shield | float), spawn zones, and Web Audio SFX envelopes. - Sub-300ms Deterministic Local AST Synthesizer (
shared/synthesize.js): Built for offline resilience and hackathon judge evaluation. When API keys are omitted or networks fluctuate, our local synthesizer parses clause-level negations (e.g.,doge but without bonk sound), guaranteeing valid AST responses in < 100ms with zero crashes. - High-Performance 2D Canvas Physics (
client/overlay/): Pure Canvas vector mathematics rendering smooth 60–95 FPS animations with adaptive font-scaling in the 340×352px poll box (handling full 160-character ideas without truncation). - Twitch IRC WebSocket Engine (
client/chat/irc.js): Direct WebSocket connection (wss://irc-ws.chat.twitch.tv:443) supporting both anonymousjustinfanread and OAuth token channels. - Architectural Standards: 100% of the project's 76 code files strictly obey the ≤ 250 physical lines-of-code budget, ensuring single-responsibility modularity and clean readability.
Challenges We Ran Into
- Broadcaster Safety vs. Viewer Freedom: Giving Twitch chat direct control of a broadcast screen is dangerous. We solved this by creating a 4-Layer Broadcast ToS Guard:
- Layer 1: Static multi-language regex & zero-width character filter (
shared/safety.js), immediately diverting toxic prompts to a safe Rescue Rubber Ducks fallback. - Layer 2: Pre-poll sanitization in
round.addIdea(), keeping malicious inputs out of public broadcast polls. - Layer 3: Closed-world AST whitelist (
shared/ast-validate.js) that strictly renders fixed geometric sprites and synth audio, making remote code execution or arbitrary image rendering mathematically impossible. - Layer 4: Streamer Mod Approval queue and Spacebar Panic Clear (< 60ms).
- Layer 1: Static multi-language regex & zero-width character filter (
- Clause-Level Negation in NLP: Simple keyword matching often fails when viewers say
avoid reverse gravityorpopcat without boom sound. We engineered a clause-splitter that isolates negative and avoidance keywords (avoid,without,never,prevent,no,don't) before scanning positive mechanics. - OBS Poll Layout Without Ellipsis: Long viewer prompts (up to 160 chars) were getting cut off by standard line-clamps. We developed dynamic typography scaling (
data-len="sm|md|lg"), auto-adjusting font-sizes so all 3 poll options remain 100% legible in a bounded340 × 352 pxbox.
Accomplishments That We're Proud Of
- Pure Zero-Eval Security: 0% crash rate, 0% code injection risk, with 45/45 automated unit tests passing across all AST schemas, physics, and sanitizers.
- Instantaneous Twitchcon-Ready Experience: Judges can clone the repo, run
npm start, and test the complete Twitch experience within 30 seconds using the 1-Click 500-Viewer Crowd Simulator. - Authentic Twitch Culture: Seamless integration of classic memes (Bonk Doge, Popcat, Vine Boom, floating SKILL ISSUE! neon badges) that Twitch streamers and viewers immediately adore.
- Full Rigor & Clean Code: Built strictly within a 250-line modular budget per file, documented thoroughly with complete test coverage.
What We Learned
- Codex Excels at Strict Contracts: By constraining Codex to output exact
json_schemaASTs rather than raw JavaScript or HTML, we eliminated hallucinations while giving viewers boundless creative expression. - Live Streamers Prioritize Control Above All: A delay of even 200ms on a panic button can ruin a competitive game. Prioritizing the sub-60ms Spacebar clear made ChaosForge broadcast-ready for top-tier esports streamers.
What's Next for ChaosForge Live
- Twitch Extension & Channel Points Bits Integration: Allowing viewers to spend Channel Points or Twitch Bits to trigger instant Boss Raids or golden Meme shields.
- Game State Telemetry (Valorant / LoL API): Syncing chaos spawns to in-game deaths, aces, or clutch situations.
- TwitchCon Stage Live Showcase: Presenting ChaosForge Live live on the Codex Booth stage at TwitchCon San Diego!
Built With
- browser-source
- html5
- javascript
- meme-culture
- node.js
- obs-studio
- openai-codex
- structured-outputs
- twitch
- twitch-irc
- twitchcon
- web-audio-api
- websockets
- zero-eval
Log in or sign up for Devpost to join the conversation.