一个提示词,20 分钟,6221 行:让 DeepSeek 写个能玩的我的世界

先说结果:一个 html 文件,238.7 KB,双击就能玩。不用装软件,不用联网,整个文件里没有一张外部图片,也没有一段外部音频。从把需求发出去到能在浏览器里跑起来,20 分钟。

黄昏时分的程序化生成村庄,草方块、树、水面和云层都由代码绘制

起因:让孩子自己出题

孩子一直想玩我的世界,我不太想让他一上来就玩联机的,就说不如我们一起做一个。我心里更想让他看到的其实是另一件事:AI 能干什么、怎么用。这个光靠讲没感觉,得让他自己出题,然后看着东西一点点长出来。

我问他想要一个什么样的世界,他想了半天,说得还挺具体:

  • 要有草地方块,还有树,还有水
  • 不能有僵尸和怪物
  • 要有村民,但是不能打人
  • 要有矿物,钻石那种
  • 开局要有很多宝箱,越爽越好

这几条我基本是原话写进去的,没加工。我自己只补了一句:颜色要绚丽一点,别太卡通。

小孩想做一个我的世界游戏。可以简单一点,但是要精致一点,要复刻这个游戏,需要用什么技术或者方式?是 html 就可以,还是有更好的,我需要马上能玩,尽快做好,能让小孩玩,和我的世界类似就行,单人玩的,不要有怪物和僵尸,有村民不打人的,还要有各种方块类型,比如草地方块。树木,水等,各种矿物等,道具等。开局要有很多宝箱和奖励,越爽越好,宝箱里要有武器等。你先分析一下怎么做更好。

「是 html 就可以,还是有更好的」这句话我留在提示词里了。它自己给出的答案是单文件 HTML + 手写 WebGL2,不用框架,也不用引擎。理由挺实际:这台机器上不了外网,CDN 拉不到 Three.js,索性全自己写,反而没有了依赖这回事。

20 分钟,主体就出来了

用的是 DeepSeek 桌面版,没换模型,也没装插件。说实话我没抱太大期望,这类东西我看得多,通常做到能跑就得来回调半天。结果地形、树、水、矿、能挖能放、箱子能开、村民会走,都在了。规模是这样的:

项目数量 / 规格
方块类型69 种
物品111 种
合成配方36 条
宝箱44 个,木 / 金 / 钻石三档
村民12 个,另有 4 个练习靶
世界尺寸192 × 96 × 192,区块 16×16
外部依赖0
成品6221 行 / 238.7 KB

他打开之后先愣了几秒,然后从出生点旁边开始挖,一直挖。我在旁边坐着看了十几分钟,他把一整块草地挖成了一条沟。那天晚上十点他还没睡着,说想再挖两块矿,又问我明天能不能加个能骑的马。

村庄街景:木板房、石砖路、路灯,阴影是实时阴影贴图投的

画面:一开始就定了别太卡通

这句话直接改了美术路线。贴图不是 16×16 的马赛克,是 128×128 的程序化贴图:多倍频噪声、渐变、污渍、矿脉反光,再叠 mipmap 和各向异性过滤。全部由 Canvas2D 现场画出来,文件里没有任何图片素材。

同一处村庄的黄昏与夜晚对比,夜晚是月光补偿后的亮度

水面是单独一套算法:菲涅尔反射、波动法线、深度吸收。太阳低的时候,水上会拉出一条亮带。夜里也不是一片黑,有月光环境光补偿,能看清路,又不刺眼。

20 分钟之后的活

那个 20 分钟是「能玩」,不是「做完」。做出来之后又改了几天,修的都是很显眼的问题:

  1. 手持物品不显示:WebGL 精灵方案失效,改成 DOM 覆盖层
  2. 村民只有一条腿:双腿横向偏移 ±0.115,再前后摆动
  3. 血量爱心渲染成字母 b:SVG 必须用 createElementNS + setAttribute,不能 innerHTML
  4. 报 this.game.sfx is not a function:改成全局 sfx 单例
  5. 开局送的 axe_diamond 根本不存在:换成 axe_iron
  6. 战利品表里的 torchless 不存在:换成 lantern
  7. 镐子图标破碎:二次贝塞尔对称重绘
  8. 夜晚全黑:加月光环境光补偿
  9. 删区块报 m.bufs is not iterable:opaque 和 water 两份缓冲都要处理

技术栈很朴素

层用什么说明
渲染WebGL2区块网格化、面剔除、顶点 AO、2048² 阴影贴图、HDR + Bloom + ACES
贴图Canvas2D128×128 程序化生成,运行时拼成图集
物品图标Canvas2D111 个图标全是代码画的
音效WebAudio振荡器实时合成,没有音频文件
存档localStorage存种子和世界改动

源码拆成 12 个模块,用 build.mjs 拼成一个 html。模块划分和渲染管线的细节我写在另一篇里了:零依赖 WebGL2 体素引擎:6221 行单文件怎么搭起来。

高空俯视:村庄、森林、雪山和海面在同一个 192×192 的世界里

这件事我觉得值得记的地方

  • 会说需求比会写代码更值钱。孩子那五条里有两条是「不要什么」,这比「要什么」更能定方向,也省掉了后面反复删功能的时间。
  • 能验证的比看起来好看的更重要。截图、控制台报错、物品图标缺失数,这些都是机器能查的,不需要靠感觉判断。
  • 时间要分开算。20 分钟是首版能玩的时间,后面几天是把它修到不别扭的时间,两个数都该说。
说明数据来自本机一次生成(DeepSeek 桌面版 + 无头 Chrome 验收),世界种子不同,宝箱数量和品质分布会变。无头 SwiftShader 只有 1~2 FPS,不代表真实性能。

The result first: one HTML file, 238.7 KB, double-click and play. No install, no network connection, and not a single external image or audio file inside. From sending the prompt to running in a browser: 20 minutes.

A procedurally generated village at dusk; grass, trees, water and clouds are all drawn by code

How it started: let the kid write the spec

My kid had been asking for Minecraft. I didn't want him starting with the online version, so I suggested we build one instead. What I actually wanted him to see was something else: what AI can do and how you use it. Explaining that doesn't land — he had to set the requirements himself and then watch the thing grow.

I asked what kind of world he wanted. He thought for a while and gave a fairly specific list:

  • Grass blocks, trees, and water
  • No zombies, no monsters
  • Villagers, but they must not attack
  • Ores, the diamond kind
  • Lots of chests right at the start — the more rewarding the better

I copied those almost verbatim, no polishing. The only thing I added was: make the colors vivid, don't make it cartoonish.

My kid wants to make a Minecraft game. It can be simple but should look polished, and it should replicate the game. What tech or approach do we need? Is plain HTML enough, or is there something better? I need to play it right away — get it working fast enough for a kid: single player, no monsters or zombies, villagers that don't attack, various block types such as grass blocks, trees, water, various ores, items. Lots of chests and rewards at the start, the more satisfying the better, with weapons in the chests. Analyze the best approach first.

I left the line 「is plain HTML enough, or is there something better」 in the prompt. Its answer was a single HTML file with hand-written WebGL2 — no framework, no engine. The reasoning was practical: this machine can't reach the internet, so Three.js can't be pulled from a CDN. Writing it all by hand removed dependencies entirely.

Twenty minutes to a playable body

This was DeepSeek Desktop, same model throughout, no plugins. I honestly didn't expect much — I've seen plenty of these demos, and usually getting one to actually run takes half a day of back-and-forth. This time terrain, trees, water, ores, mining and placing, chests that open, villagers that walk around — all present. At this scale:

ItemCount / spec
Block types69
Items111
Crafting recipes36
Chests44, in wood / gold / diamond tiers
Villagers12, plus 4 practice targets
World size192 × 96 × 192, 16×16 chunks
External dependencies0
Output6,221 lines / 238.7 KB

He stared at it for a few seconds, then started digging next to the spawn point and didn't stop. I sat there for a good ten minutes while he turned a patch of grass into a trench. That night he was still awake at ten, saying he wanted to mine a couple more ores, and asked whether I could add a rideable horse tomorrow.

A village street: plank houses, stone-brick paths, lanterns, with real-time shadow-map shadows

Looks: the one rule was 'not cartoonish'

That single sentence changed the art direction. Textures aren't 16×16 mosaics but 128×128 procedural maps: multi-octave noise, gradients, stains, ore glints, with mipmaps and anisotropic filtering on top. Canvas2D draws all of them at load time; there is no image asset in the file.

The same village at dusk and at night; the night frame uses moonlight ambient compensation

Water has its own pass: Fresnel reflection, animated normals, depth absorption. When the sun is low it draws a bright band across the surface. Night isn't pitch black either — moonlight ambient compensation keeps the road visible without glare.

The work after the first 20 minutes

Those 20 minutes bought 'playable', not 'finished'. I spent the next few days fixing things that were plainly broken:

  1. Held item invisible: the WebGL sprite approach failed, switched to a DOM overlay
  2. Villagers had one leg: offset both legs by ±0.115 and swing them front-to-back
  3. Health hearts rendered as the letter 'b': SVG needs createElementNS + setAttribute, not innerHTML
  4. 'this.game.sfx is not a function': moved to a global sfx singleton
  5. The starting axe_diamond didn't exist: swapped for axe_iron
  6. The loot table referenced a non-existent torchless: swapped for lantern
  7. Pickaxe icon was torn apart: redrawn symmetrically with quadratic Béziers
  8. Night was pitch black: added moonlight ambient compensation
  9. Chunk deletion threw 'm.bufs is not iterable': both the opaque and water buffers need handling

The stack is plain

LayerWhatNotes
RenderingWebGL2Chunk meshing, face culling, vertex AO, 2048² shadow map, HDR + Bloom + ACES
TexturesCanvas2D128×128 procedural generation, assembled into an atlas at runtime
Item iconsCanvas2DAll 111 icons drawn by code
AudioWebAudioReal-time oscillator synthesis, no audio files
SavelocalStorageStores the seed and world edits

The source is split into 12 modules and concatenated into one HTML file by build.mjs. Module breakdown and rendering pipeline details are in a companion piece: A Zero-Dependency WebGL2 Voxel Engine in One File.

Aerial view: village, forest, snowy peak and ocean inside one 192×192 world

What's actually worth noting

  • Specifying well beats coding. Two of his five items were 'no X', which pins down direction far better than 'yes X' and saves the back-and-forth of removing features later.
  • Verifiable beats impressive. Screenshots, console errors, a count of missing item icons — a machine can check those, no gut feeling needed.
  • Split the timeline. Twenty minutes got the first playable build; the next few days made it not awkward to use. Both numbers deserve saying.
NotesNumbers come from one local run (DeepSeek Desktop, verified with headless Chrome). Chest counts and tier distribution vary with the world seed. Headless SwiftShader runs at 1–2 FPS and says nothing about real performance.
返回文章列表