I Prompted Meta Muse Spark 1.3 to Build a 3D Roguelike Dungeon Crawler — Clean Permadeath Loop in 736 Lines (One-Shot)


Most AI models tasked with building a roguelike dungeon crawler make one of two catastrophic architectural mistakes: either they hardcode room layouts into an array, or they botch the permadeath restart loop by leaking WebGL geometries, event listeners, and enemy arrays until the browser tabs slow to a crawl. I prompted Meta Muse Spark 1.3 (xhigh reasoning effort) to engineer DUNGEONFALL, a complete 3D roguelike dungeon crawler in a single self-contained HTML file using Three.js from CDN. It delivered a 736-line, 45.2 KB playable build in a single pass—complete with procedural room partitioning, corridor carving, billboarding enemy health bars, loot magnets, and an explicit scene teardown lifecycle that prevents state leaks across deaths.
What I asked for
The prompt evaluated whether Muse Spark 1.3 could write non-trivial procedural graph generation while maintaining clean game-state management across death cycles.
You are an expert Three.js game developer.
Create a complete 3D roguelike dungeon crawler in ONE SINGLE HTML FILE.
IMPORTANT:
- Output ONLY one file: index.html
- All HTML, CSS, and JavaScript in this single file, no external assets, no frameworks.
- Use Three.js from CDN.
- Must run by double-clicking index.html.
DUNGEON GENERATION:
- Procedurally generate a multi-room dungeon layout (at least 8-10 rooms connected by corridors) using an algorithm you implement yourself (e.g. randomized room placement + corridor carving).
- Each playthrough must generate a genuinely different layout (verify this isn't hardcoded).
- At least one room type variation: a "treasure room" and a "boss room" distinct from normal rooms.
GAMEPLAY:
- Top-down or first-person 3D movement (your choice, but must be true 3D, not a 2D sprite grid).
- Simple melee combat against enemies with health bars.
- Player has one life — on death, the game ends and offers a "New Game" button that generates a brand-new dungeon layout.
- At least one collectible item type that affects player stats (e.g. a potion that increases health).
Report whether the permadeath/regeneration loop actually works correctly across multiple playthroughs, or whether state leaks between runs.
Interactive Demo
Double-click or interact with the live game below. Use WASD or arrow keys to move, Space or left-click to attack with your sword, and E to consume health potions (+40 HP).
Interactive Demo
W A S D / Arrow Keys to drive
The demo runs completely self-contained within an isolated iframe—no build steps, Node servers, or external asset pipelines required.
DUNGEONFALL 3D Roguelike Permadeath Combat and Minimap
Procedural Room & Corridor Generation
Instead of falling back to a fixed 2D array or hardcoding room placements, Muse Spark 1.3 implemented an AABB collision-checked room distributor across a 52×52 grid. The engine attempts up to 400 placements with 2-tile safety padding to generate 8 to 11 non-overlapping rectangular chambers.
Once rooms are placed, the algorithm establishes the starting chamber at index 0, then calculates Euclidean distance to find the farthest room in the graph, designating it as the Boss Lair (order[0]). The second most distant chamber becomes the Treasure Vault (order[1]). The model links the rooms sequentially using randomized horizontal and vertical L-corridors (carveH and carveV) carved 2 tiles wide, followed by two random cross-cycle connections to prevent the dungeon from devolving into a boring linear tunnel.
Real Permadeath & Resource Teardown Lifecycle
The most impressive architectural feat in DUNGEONFALL is how thoroughly Muse Spark 1.3 engineered the permadeath reset routine. In typical LLM-generated Three.js prototypes, clicking "New Game" pushes new objects to scene while old listeners and geometries linger, leading to duplicate input triggers, frame rate degradation, and memory leaks.
Muse Spark 1.3 solved this systematically with an explicit cleanup lifecycle:
function disposeGroup(gr) {
if (!gr) return;
gr.traverse(function(o) {
if (o.geometry) o.geometry.dispose();
if (o.material) {
(Array.isArray(o.material) ? o.material : [o.material]).forEach(function(m) {
m.dispose();
});
}
});
}
function cleanupRun() {
if (G && G.floaters) G.floaters.forEach(function(f) { if (f.el.parentNode) f.el.remove(); });
[dungeonGroup, entityGroup, fxGroup].forEach(function(gr) {
if (gr) { scene.remove(gr); disposeGroup(gr); }
});
dungeonGroup = entityGroup = fxGroup = null;
document.getElementById('boss-panel').style.display = 'none';
document.getElementById('boss-warn').style.display = 'none';
document.getElementById('msglog').innerHTML = '';
for (var k in keys) keys[k] = false;
camShake = 0; swingT = 0; bossWarnT = 0; minimapT = 0;
}
By decoupling UI listeners via bindUIOnce() and invoking disposeGroup on every active Three.js group upon death, the game can be replayed tens of times sequentially without a single dropped frame or orphaned event listener.
Combat, Mob AI, and Health Bar Billboarding
Combat relies on directional sword swings with cooldowns (atkCd), accompanied by camera shake, 3D particle bursts, and floating damage numbers that rise and fade in world-to-screen projected coordinates.
Enemies come in three distinct tiers:
- Goblins (42 HP, 9 DMG, 4.6 speed): Fast green swarming mobs that pursue the player once within a 24-unit radius.
- Brutes (85 HP, 14 DMG, 3.6 speed): Heavy orange bipedal tanks that absorb significant punishment and hit hard.
- Dungeon Lord Boss (260 HP, 22 DMG, 4.2 speed): A massive horned demon surrounded by decorative skull pillars and a glowing red runic summoning ring. Entering its chamber triggers an onscreen warning banner, a low sawtooth boss awakening hum, and an active top-screen boss health bar.
Each mob features an overhead health bar billboard that copies the camera quaternion (e.mesh.userData.bar.quaternion.copy(camera.quaternion)), smoothly dynamically scaling and shifting from green to yellow to red as their hitpoints drop.
Loot Magnet Mechanics and Room Architecture
In an insightful comment left directly in the source code, the model noted:
// NOTE: no collider for items — an earlier build added a chest blocker (r=1.2) wider than the pickup range, making chests (and coins under crates) unreachable.
To ensure player quality of life, the model implemented a 5-unit proximity loot magnet. Whenever a player walks near dropped coins, potions, or weapons, items accelerate smoothly toward the player's coordinates, preventing loot from getting stuck behind pillar colliders or wall edges. Opening chests awards permanent stat increases (+5 Attack, +20 Max HP), while picking up potions increments the quick-drink hotkey counter (E).
Real-Time Minimap & Web Audio Sound Effects
Top-right canvas rendering (150×150 px) projects a live overhead schematic of the dungeon grid. It renders unexplored corridors in dark slate, the player's entrance in blue, standard rooms in light gray, the Treasure Vault in gold, and the Boss Lair in crimson. Living enemy dots (magenta for the boss, red for minions) and active item pickups are tracked in real time alongside a pulsing green dot indicating the player's current location.
All sound effects are synthetically produced on the fly through the Web Audio API without requiring any external MP3 or WAV files:
- Sword hit: High-frequency square wave beep with exponential volume decay.
- Boss roar / warning: 90 Hz low sawtooth wave drone.
- Potion gulp / menu select: Triangle wave chime.
What impressed me
- Zero-leak permadeath loop on the first attempt: The model didn't just write a game; it correctly managed Three.js memory lifecycles, traversing every group to invoke
.dispose()on geometries and materials, and clearing screen-space floating text elements. - Intelligent dungeon graph generation: Distance-sorting rooms from the start point to guarantee that the Treasure Vault and Boss Lair are placed at the deepest reaches of the complex, while introducing loop corridors to prevent dead-end traps.
- Unprompted loot attraction physics: Adding magnetic item lerping when within 5 units prevents the frustrating edge case of loot landing inside collision boundaries.
What needs work
- Line-of-sight pathfinding: While mobs navigate toward the player using vector collision displacement, they do not run full A* pathfinding. If the player turns around a deep corridor corner, mobs can temporarily bundle up against exterior corridor walls before sliding around the corner.
- Corridor decoration: While chambers feature flickering torches, broken crates, pillars, and runes, connecting hallways are purely functional corridors without wall torches or traps.
- Enemy attack animations: Mobs bob up and down and flash white upon taking damage, but lack a dedicated attack windup animation prior to dealing damage.
Try it yourself
Here is the cleaned, reusable prompt to test this benchmark against any frontier AI coding model:
You are an expert Three.js game developer.
Create a complete 3D roguelike dungeon crawler in ONE SINGLE HTML FILE.
REQUIREMENTS:
- Output ONLY one file: index.html with all HTML, CSS, and JavaScript self-contained.
- Use Three.js from CDN (cdnjs r128). No other external assets, libraries, or frameworks.
- PROCEDURAL DUNGEON: Procedurally generate 8-11 non-overlapping rooms connected by 2-tile wide corridors on a grid. Place the Entrance at room 0, and place a Treasure Vault and a Boss Lair in the furthest chambers from the entrance. Include at least 2 loop corridors to avoid purely linear layouts.
- GAMEPLAY & COMBAT: Top-down isometric 3D follow camera. WASD movement and Space/Click melee combat. Include 3 enemy tiers (Goblins, Brutes, Boss) with billboarding health bars and contact/melee damage.
- LOOT & STATS: Collectible gold coins, health potions (drinkable via E key), and treasure chests that upgrade player Max HP and Attack. Implement proximity loot attraction so items do not get trapped behind colliders.
- PERMADEATH & REGENERATION: When player HP reaches 0, show a Game Over screen with run statistics and a "New Game" button. Ensure the restart routine completely purges old scene geometries, materials, particles, and listeners to prevent memory leaks or double-input bindings across successive runs.
- AUDIO & UI: Synthesize all sound effects (attack, hit, boss roar, potion) using Web Audio API. Include a live 2D canvas minimap showing rooms, corridors, player position, and enemy dots.


