All MicroEvals
Educational 3D game inside a CPU (Three.js)
Create MicroEval

Educational 3D game inside a CPU (Three.js)

Ability to generate a complete 3D game in a single self-contained HTML file with Three.js from a long, detailed prompt. Evaluate: working code with no console errors, completeness (all levels, Codex, quiz and Lab Mode), accuracy of CPU architecture concepts, visual quality (bloom, circuit traces, particles), gameplay and fun, performance (60 FPS) and adherence to the prompt specifications.

Prompt

Create a complete 3D game in ONE SINGLE self-contained HTML file using Three.js. The player controls a tiny electron-ship navigating inside a processor (CPU) at microscopic scale. The game must be FUN and EDUCATIONAL: by the end, the player should truly understand how a CPU executes instructions. Golden rule: every game mechanic represents a real computer architecture concept, and the game explains that concept at the right moment, briefly, without breaking the fun. Target audience: teenagers and curious adults with no prior knowledge. Language for all in-game text: English. ===================================================================== 1. TECHNICAL REQUIREMENTS (mandatory) ===================================================================== - Everything in a single .html file (inline HTML + CSS + JS). - Three.js loaded via importmap from a CDN (r160 or later, ES modules), including EffectComposer and UnrealBloomPass. - ZERO external assets: geometry, textures, sounds and music must be procedural (Three.js geometries, CanvasTexture, Web Audio API). - 60 FPS on an average laptop: InstancedMesh, object pooling, few lights. - Responsive to window resizing. - Code organized in commented sections (Config, Scene, Player, Enemies, Levels, Educational Content, HUD, Audio, Main Loop). - All educational content lives in a single JS object (CONTENT) so it is easy to review and edit. - Deliver the COMPLETE code, with no "..." or omitted parts. ===================================================================== 2. VISUAL STYLE ===================================================================== - "Tron + motherboard" style: near-black background, glowing traces in cyan, magenta and lime green, strong bloom. - Floor = silicon die with procedural copper traces (straight and 45°), vias and transistor blocks. - Light pulses travel along the traces on every beat of the global CLOCK. - Exponential fog, third-person camera with lerp, banking on turns and screen shake on impacts. - Particles: ship trail, sparks, bit explosions (0s and 1s as sprites). ===================================================================== 3. THE PLAYER ===================================================================== - Electron-ship: glowing sphere with an orbiting ring and a light trail. - Controls: - W/A/S/D or arrow keys: move - Mouse: camera (pointer lock on click) - Left click: fire a "correction pulse" - Shift: OVERCLOCK (more speed, more heat) - Space: vertical boost - E: pick up / deliver packet - Tab: open the CODEX (in-game encyclopedia, pauses the game) - Esc: pause | M: mute - HUD: Voltage (health), Temperature, Clock (GHz), Score, Combo and IPC. ===================================================================== 4. CORE MECHANIC: THE INSTRUCTION CYCLE ===================================================================== The player lives the real FETCH -> DECODE -> EXECUTE -> WRITEBACK cycle: 1. FETCH: instruction packets spawn at the fetch portal. The player grabs one. 2. DECODE: when passing through the Decoder, the packet "opens" and shows the opcode and operands (e.g., ADD R1, R2, R3). Skipping decode is impossible (closed gate), reinforcing that every instruction must be decoded. 3. EXECUTE: deliver it to the correct unit: - ADD / SUB / AND / OR / XOR -> ALU (blue) - FADD / FMUL (floating point) -> FPU (orange) - LOAD / STORE -> Load/Store Unit, which queries the CACHE (green) - JMP / BEQ (branches) -> Branch Unit (purple) 4. WRITEBACK: the result becomes a smaller cube that must be carried to the destination register (R0 to R15) specified in the instruction. - In the ALU, the player sees the operation happen with real binary numbers (e.g., 0101 + 0011 = 1000), animated bit by bit with the carry. - Instruction delivered to the wrong unit = "pipeline stall": freezes for 0.5 s with a glitch effect and explains why it was wrong ("FMUL uses the FPU, not the ALU"). - Fast, correct deliveries increase combo and IPC. PIPELINE (from level 3): the player can carry up to 3 instructions at once, one per stage. If an instruction depends on the result of another (e.g., ADD R1... followed by SUB R4, R1...), delivering out of order causes a "data hazard" and a stall. The game highlights the dependency with a glowing line between the packets. TEMPERATURE: - Overclocking and shooting generate heat. Above 80% the screen turns reddish; at 100% THERMAL THROTTLING kicks in (clock reduced for 3 s), explaining that real CPUs lower their frequency to avoid damage. - Cool down at HEAT SINKS or with the "Thermal Paste" power-up. ===================================================================== 5. MAP / PROCESSOR ZONES ===================================================================== Each zone has a holographic sign with its name and a 1-sentence explanation shown the first time the player enters. 1. FETCH / DECODE: entry portal with light conveyor belts. 2. REGISTERS: 16 cubicles (R0 to R15). Explanation: "the fastest memory in the CPU, located inside the core itself". 3. ALU: circular arena with rotating 3D AND/OR/XOR logic gates as obstacles. Touching a gate shows its truth table. 4. FPU: tall towers with spinning rings, platform jumping. 5. CACHE L1/L2/L3: concentric rings. L1 is small and very fast, L3 is large and slower. On a LOAD, the game rolls HIT or MISS: - L1 hit: the data is right there. - Miss: the player must go to the next level, and ultimately to RAM. Show the "cost" in cycles on the HUD (illustrative values, e.g., L1 ~4, L2 ~12, L3 ~40, RAM ~200), with a note that they are approximations. 6. BRANCH UNIT + PREDICTOR: a fork with two bridges. The predictor "guesses" a path based on history (if the same branch was taken before, it tends to repeat). Correct guess = bonus. Wrong guess = "branch misprediction": instructions already loaded from the wrong path dissolve (pipeline flush). 7. MEMORY CONTROLLER -> RAM: long, dark, slow tunnel to RAM, showing in practice why accessing main memory is expensive. 8. CORES: advanced levels feature 2, 4 and 8 cores linked by interconnect bridges, illustrating parallelism. ===================================================================== 6. ENEMIES AND HAZARDS (each tied to a real concept) ===================================================================== - BUGS: red insects that steal packets (Codex trivia: the moth found in the Harvard Mark II computer in 1947). - MEMORY LEAK: purple goo that grows and slows the ship down. Explanation: a program that allocates memory and never frees it. - COSMIC RAY: beam with a 1 s warning; if it hits, it flips a bit in the packet and changes the opcode (bit flip / soft error). The Codex explains ECC memory. - MALWARE: black drone that shoots (level 3+). - RACE CONDITION: two ghost clones competing for the same packet. Explanation: two processes accessing the same data at the same time. - SHORT CIRCUIT: traces that become electrified in rhythm with the clock. ===================================================================== 7. POWER-UPS (also explained) ===================================================================== - Thermal Paste: resets temperature to zero. - Hyper-Threading: ship clone for 10 s carrying another instruction (explains SMT: one core running two threads). - Speculative Execution: shows the optimal path for 5 s (explains that the CPU executes ahead what it will probably need). - Prefetch: brings the next data into L1 before you ask for it. - Firewall: shield that blocks 3 hits. - Turbo Boost: overclock without heating for 8 s. ===================================================================== 8. EDUCATIONAL LAYER (essential) ===================================================================== a) CONTEXTUAL TIPS: the first time something appears, a short bubble (max. 2 lines) explains the concept, with 1.5 s of slow motion. Never repeat the same tip. b) CODEX (Tab key): encyclopedia UNLOCKED as the player encounters each element. Each entry has: - Name and a spinning 3D icon - "What it is" (1 simple paragraph) - "In the real world" (concrete example, e.g., "Your phone runs billions of cycles per second") - "In the game" (how it appears in the mechanics) At least 20 entries: clock, transistor, logic gate, binary, register, ALU, FPU, decoder, instruction cycle, pipeline, hazard, cache, hit/miss, RAM, branch predictor, speculative execution, multicore, hyper-threading, thermal throttling, bit flip/ECC, memory leak, race condition, IPC. Progress bar "Codex: 12/23". c) BOOT QUIZ between levels: 3 multiple-choice questions about the concepts seen in the level. Correct answers give bonus points and a power-up in the next level. Wrong answers show the correct explanation (no harsh penalty). Bank of at least 30 questions, drawn without repetition. d) LAB MODE (in the menu): free area with no enemies and no timer where the player writes a mini program of 3 to 5 instructions (e.g., LOAD, ADD, STORE) by choosing from menus, and watches the ship execute it step by step, with register values changing in an on-screen table. e) BINARY CONVERTER: on the HUD, register values can be shown in decimal, binary or hexadecimal (B key toggles). f) ACCURACY: all educational text must be correct, simplified without becoming wrong. When a number is illustrative, say "approximately". Do not invent historical facts. ===================================================================== 9. PROGRESSION AND LEVELS ===================================================================== Each level is a "program" with an instruction goal and a main concept: 1. "Hello World" (tutorial): fetch, decode, ALU, registers. Only ADD and SUB. 2. "Calculator": FPU, LOAD/STORE, cache, first bugs. 3. "Browser with 40 tabs": pipeline and hazards, memory leaks, malware. 4. "Rendering in 4K": multicore, branches and predictor, cosmic rays. 5. BOSS "KERNEL PANIC": geometric virus (icosahedron that shatters and reassembles) at the center of the die. 3 attack phases (rotating lasers, summoning bugs, a blue-screen wave spreading across the floor). To damage it, the player runs a real "PATCH" mini program: deliver instructions in the correct order to 4 terminals (e.g., LOAD address, XOR key, STORE, JMP) and then shoot the exposed core. Wrong order = the boss regenerates, showing why order matters. - Between levels: BOOT screen with typed terminal text, summary (points, average IPC, grade S/A/B/C), quiz and unlocked Codex entries. - Each level raises the clock: music, hazards and timer get faster. ===================================================================== 10. HUD AND INTERFACE ===================================================================== - Monospaced font, terminal/datasheet aesthetic. - Top left: Voltage and a thermometer with gradient. - Top right: score, animated combo, IPC. - Top center: current instruction in assembly (e.g., ADD R1, R2, R3), pipeline stage and cycle timer. - Side panel: register table R0 to R15 with live values. - Bottom-right minimap with colored zones and a blinking destination. - Floating 3D arrow pointing to the destination. - Title screen: spinning chip, "NANONAUTA" title with glitch effect, buttons "START BOOT", "LAB" and "CODEX". - Game Over: "SEGMENTATION FAULT (core dumped)" + 1 random Codex fact + Restart button. - High score and Codex progress saved in localStorage. ===================================================================== 11. AUDIO (Web Audio API, procedural) ===================================================================== - Synthwave music: bass on the clock beat, arpeggio that intensifies with the combo. - SFX: pickup, correct delivery (chord), error (low buzz), shot, explosion, overheating alarm, special sound when unlocking a Codex entry. ===================================================================== 12. "JUICE" ===================================================================== - 50 ms hit-stop when destroying enemies. - Floating points on delivery (+100 x3). - Funny logs in the corner: "warning: unused variable 'sanity'", "Stack Overflow consulted successfully", "Compiling... sorry, it's Rust". - FOV widens during overclock. - Easter egg: typing "sudo" grants 5 s of invincibility (and unlocks the Codex entry "sudo: the superuser"). ===================================================================== 13. DELIVERY ===================================================================== Deliver only the final, complete HTML, ready to open with a double click. Before delivering, check: no console errors, all zones reachable, all levels playable from tutorial to boss, quiz and Codex working, and accurate educational text.

A system prompt was added to support web rendering

Drag to resize

Response not available

Drag to resize
Drag to resize
Drag to resize
Drag to resize