Prompt-to-AAA Engine Blueprint Compiler & 121.games Syndication Ecosystem
Document ID: YPG-AI-005 | Index: docs/README.md | Companion: VERTEX_AI_AND_MODEL_ROUTING.md
Primary Modules: src/services/genreBlueprintService.mjs, src/services/gameGeneratorService.mjs, src/routes/apiSyndicationRouter.mjs, src/services/gameSanitizer.mjs
1. Prompt-to-AAA Genre Blueprint Compiler
Rather than sending a flat generic instruction to Vertex AI (gemini-4-neon default / gemini-4-carbon 1-shot repair), src/services/genreBlueprintService.mjs classifies every incoming Studio prompt into one of 10 deterministic AAA game archetypes before synthesis (generateAndSaveGame, iterateAndSaveGame, autofixAndSaveGame) and injects a tailored engineering blueprint into buildEngineSystemPrompt().
1.1 The 10 Specialized AAA Archetypes
| Archetype ID | Label | Recommended Engine | Category | Signature Engineering Blueprint |
|---|---|---|---|---|
tactical-fps | Tactical 5v5 First-Person Shooter | threejs | 3d-webgl | Articulated FPS viewmodel + operative rigs, PointerLock + WASD/Arrow parity, recoil spray curves, optical scope, volumetric smoke, C4 plant/defuse, round buy menu. |
battle-royale | 3D Tactical Battle Royale | threejs | 3d-webgl | Third-person survivor + parachute + drivable buggy + orbital cargo transport airdrop rigs, TPS-to-4x/8x ballistic scope with projectile bullet drop, enterable compounds, shrinking Blue Zone. |
3d-build-shooter | 3D Grid-Building Action Shooter | threejs | 3d-webgl | Stylized hero + modular 4m x 4m x 4m destructible grid structures (Wall/Ramp/Floor/Cone), G architectural edit mode, weak-spot pickaxe harvesting, Launch Pad redeploy, violet storm. |
3d-spline-racer | 3D Spline Drift & Nitro Racer | threejs | 3d-webgl | Articulated suspension vehicle with 4 spinning/steering wheels, curving parametric 3D spline highway, slip-angle drift-to-nitro boost, rival AI racers, dynamic FOV warp. |
3d-flight-world | 3D Open-Sky Flight & Sanctuary Adventure | threejs | 3d-webgl | Articulated airship/glider rig, 360-degree open-sky floating sanctuaries, translucent hollow RingGeometry portals (zero washout), thermal updrafts, directional compass. |
6dof-space-combat | 6-DOF Deep-Space Starfighter Combat | threejs | 3d-webgl | 6-DOF swept-wing starfighter with recoiling twin cannons & afterburners, target lead reticle, lock-on homing missiles, exoplanet debris rings, multi-phase dreadnought bosses. |
run-and-gun-2d | 2D Kinetic Run-and-Gun & Action Platformer | phaser | phaser-2d | Articulated multi-part 2D container rig + ./assets/sprite.png + ./cover.png parallax, coyote-time/jump-buffer physics, multi-weapon loadout, Phaser 3.90 .explode() particles. |
verlet-grappler-2d | 2D Verlet Grappling-Hook Momentum Platformer | phaser | phaser-2d | Velocity-tilted acrobat rig + multi-node Verlet rope constraint chain, pendulum momentum conservation, slingshot release boost, floating tower checkpoints. |
orbital-roguelite | 360° Orbital & Twin-Stick Arena Roguelite | canvas2d | arcade-action | Rotating orbital shield/turret rig, timed parry bursts, mid-run 3-card roguelite upgrade draft, multi-archetype enemy waves, multi-phase bosses, 0.25x-0.5x additive HDR bloom. |
quantum-optics-puzzle | Quantum Optics & Deterministic Grid Puzzle | canvas2d | puzzle-strategy | Pre-baked crystalline circuit grid, smooth-easing prism mirrors, chromatic beam splitters, >= 6 verified-solvable levels, Undo (Z), Par-Star ratings, adaptive mobile board metrics. |
1.2 Mandatory Cross-Archetype Invariants Injected Into Every Prompt
Every blueprint block emitted by buildGenreBlueprintPrompt() reinforces five non-negotiable production invariants:
- Articulated Multi-Part 3D/2D Rig Hierarchy: Explicitly forbids bare
BoxGeometrycubes, plainfillRectboxes, or static programmer-art cutouts. - Input & Bridge Parity: PointerLock (where applicable) + 100%
WASD(KeyW/A/S/D) andArrow Keysparity +Space/R+YPG_KEY_EVENT/YourPlaygroundSDK.keyspolling + pointer/touch fallback. - Cosmic-Glass
HOW TO PLAYOverlay &?Toggle: Immediate live background render, translucent keycap tutorial card dismissing on first keypress/click,? HOW TO PLAYtop-HUD toggle, and non-overlapping<=560pxmobile HUD. - Locked 60 FPS Anti-Stutter Budget:
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.5)),0.5xhalf-resolution bloom,0per-framectx.shadowBlur,0per-framenew THREE.Vector3/Color/Eulerallocations, object pooling, dirty-checked DOM HUD mutations, anddt = Math.min(rawDt, 0.05). - Procedural WebAudio Synth & Spatial SFX: Self-contained procedural music + stereo-panned SFX unlocked on first user gesture and guarded behind
navigator.userActivation.hasBeenActiveinsidetry { ... } catch (_) {}.
2. Deterministic Static Quality Scorer (scoreGeneratedGameQuality)
After linear-time O(N) sanitization (sanitizeGameHtml) and V8 vm.Script compilation succeed, gameGeneratorService.mjs invokes scoreGeneratedGameQuality(sanitized.html, engineObj.id) to attach deterministic diagnostics (0..100 score, letter grade S–F, per-check breakdown, and actionable warnings) directly onto generation metadata (archetype, archetypeLabel, qualityScore, qualityDiagnostics).
| Check Key | Max Weight | Linear-Time Static Assertion |
|---|---|---|
howToPlayOverlay | 15 | Detects cosmic-glass HOW TO PLAY tutorial overlay markup outside injected SDK. |
helpToggle | 10 | Detects interactive ? help button (#btn-help / toggleTutorial / ? HOW TO PLAY). |
wasdAndArrowParity | 15 | Verifies both WASD (KeyW/A/S/D or lowercase 'w'/'a'/'s'/'d') and Arrow* bindings. |
ypgTelemetryAndBridge | 15 | Verifies YourPlaygroundSDK.ready / YPG_READY, reportScore/gameOver/YPG_SCORE, and YPG_KEY_EVENT/YPG_INPUT/YourPlaygroundSDK.keys wiring. |
zeroPerFrameShadowBlur | 15 | Flags any non-zero .shadowBlur = ... or ctx.filter = 'blur(...)' inside hot requestAnimationFrame/render/draw/animate/tick/update loops (while permitting shadowBlur = 0 and one-time offscreen pre-bakes). |
pixelRatioCap | 10 | Enforces setPixelRatio(Math.min(..., <= 1.5)) on Three.js and capped devicePixelRatio on 2D engines. |
zeroPerFrameLoopAllocs | 10 | Flags per-frame new THREE.Vector3/Color/Euler/Quaternion inside Three.js hot loops (or per-frame canvas gradients in 2D) and verifies clamped dt. |
audioContextGuard | 10 | Verifies procedural WebAudio AudioContext is guarded by navigator.userActivation.hasBeenActive or user-gesture unlock inside try/catch. |
3. Official Read-Only YourPlayground.games -> 121.games Syndication Feed
Implemented in src/routes/apiSyndicationRouter.mjs and mounted in src/app.mjs, the syndication API exposes a strictly read-only, CORS-enabled JSON catalog for https://121.games with zero cross-repository file mutations and zero raw .zip source exposure:
GET /api/syndication/121games: Returns all catalog games (Cache-Control: public, max-age=60,Access-Control-Allow-Origin: *), with optional read-only filters (?category=,?engine=,?featured=true,?q=).GET /api/syndication/121games/:slug: Returns a single canonical syndicated game manifest (404 GAME_NOT_FOUNDfor unknown or invalid slugs).- Read-Only & Zero-ZIP Enforcement: Mutating methods (
POST,PUT,PATCH,DELETE) return405 METHOD_NOT_ALLOWED; anyexport.zip/export/downloadpath returns403 ZIP_EXPORT_DISABLED(zipDownloadEnabled: false).
3.1 Canonical Syndication Fields Per Game
Every entry includes:
isBasedOn:https://www.yourplayground.games/games/<slug>canonicalUrl:https://www.yourplayground.games/games/<slug>runtimeEmbedUrl:https://www.yourplayground.games/runtime/<slug>/index.htmlcoverUrl: Absolute canonical URL (https://www.yourplayground.games/...)creatorStudioCtaUrl:https://www.yourplayground.games/studio?utm_source=121games&utm_medium=community&utm_campaign=create_your_gameembedSandbox:allow-scripts allow-pointer-locksdkContract:
{
"inbound": ["YPG_KEY_EVENT", "YPG_INPUT", "121_INPUT"],
"outbound": ["YPG_READY", "YPG_SCORE", "YPG_GAME_OVER", "121_READY", "121_SCORE", "121_GAME_OVER"]
}
4. Dual-SDK Compatibility (YourPlaygroundSDK + 121SDK)
Inside src/services/gameSanitizer.mjs (YPG_SDK_SCRIPT_TAG), every sanitized game automatically gains native dual-SDK postMessage interoperability while preserving all linear-time security invariants (0 external URLs, 0 prototype pollution vectors, allow-scripts allow-pointer-lock null-origin sandbox):
- Outbound Dual Emission:
sdk.ready()emits{ source: 'YourPlaygroundSDK', type: 'YPG_READY', payload }and{ source: '121SDK', sdkAliasOf: 'YourPlaygroundSDK', type: '121_READY', payload }.sdk.reportScore(score)emits bothYPG_SCOREand121_SCORE.sdk.gameOver(score)emits bothYPG_GAME_OVERand121_GAME_OVER.- Inbound Unified Controls:
- Accepts
YPG_KEY_EVENT,YPG_INPUT, and121_INPUT(action: 'keydown'|'keyup'|'press'|'tap'oreventType: 'keydown'|'keyup'), updatingwindow.YourPlaygroundSDK.keysand dispatching syntheticKeyboardEvents cleanly inside the sandboxed frame. - Window Global Alias: Exposes
window.YourPlaygroundSDK,window.PlaygroundSDK, andwindow['121SDK']pointing to the exact same hardened SDK singleton.