深度·Simon Willison·Simon Willison·2026.10.20·阅读原文 ↗

Battle Drones:vibe coded 的 RTS 与音频联机

我最新的 vibe coded 游戏实验是一款《命令与征服》风格的 RTS(即时战略)游戏 Battle Drones。与之前的实验不同,这款是真的好玩——而且我是靠跟 Claude 说一句「Make it a LOT more fun」做到的。它还支持附近设备之间通过音频同步游戏状态的多人模式。

我最新的 vibe coded 游戏实验是一款《命令与征服》风格的 RTS(即时战略)游戏,名叫 Battle Drones(点此试玩)。与我之前的实验不同,这款是真的好玩。

说来有点不好意思,我是靠告诉 Claude「Make it a LOT more fun」(把它做得好玩得多)才走到这一步的。它还支持附近设备之间通过音频同步游戏状态的多人模式!下面是我目前做出来的东西,以及一路学到的一些东西。

Battle Drones

我最初的目标是做一款能在手机上玩的 RTS 游戏,风格对标《命令与征服》。我对 1995 年的原作有美好的回忆(也很喜欢《红色警戒》),想找回一点当年的魔力。

经过 12 轮大版本迭代(以及 coding agent——主要是 Claude Code——提交的 321 个 commit),我现在拥有了一个运行在浏览器里的游戏:手机和桌面都能玩,有多种游戏模式、多张地图(包括一个随机地图生成器),甚至支持两台在彼此麦克风范围内的设备联机对战。(更新:还支持在线多人模式;音频联机让人头疼!)

下面是 Battle Drones 在桌面浏览器中运行的视频演示:

Video poster frame

目前的功能包括:

  • 9 种建筑、7 种地面载具、6 种空中载具、3 种步兵单位——全部是 3D 模型,可在此浏览

  • 战争迷雾

  • 攻击空中和地面载具需要使用不同的武器

  • 六张地图,横跨五种生态地貌——温带、沙漠、极地、火山、热带

  • 一个随机地图生成器

  • 遭遇战模式(Skirmish)——红蓝双方在一张旋转对称的地图上对抗

  • 背水一战模式(Last Stand)——一名玩家尽可能抵挡更多波次的敌人

  • 范围效果武器:Barrage、EMP、Drop Pod、Sky Hammer

  • 补给箱空投(Crate drops),附带额外资源

  • 随事件变化的游戏内音乐——战斗打响时会变得更激烈

  • 不同的游戏内 AI 人格(Balanced、Rush、Air Swarm、Boom、Skyforce、Ironclad)

  • AI 对战 AI 模式,可以围观这些人格互相较量

  • Goliath——一台巨型践踏机甲,长着激光眼和手臂加农炮,还能建立新基地

  • Mutators(变异规则),为游戏添加额外规则或花样

  • 一个“每日行动(Daily Op)”挑战

  • 军衔与成就(勋章)

  • Agent 对战 Agent 模式,两个 LLM 可以在 Battle Drones 里互相对战

  • 一种多人模式:两台靠近的手机通过音频消息通信——是我早前 Chirp Pong 实验的延伸

我是怎么做出这个游戏的

Battle Drones 重度依赖 vibe coding——我几乎没有 review 过它的代码,而且它是用一种我自己都几乎没用过的语言(TypeScript)写的。不过我做了大量试玩测试,项目自开始以来也经历了非常多次迭代。

下面是这个项目到目前为止的大致历程,包括关键 prompt 和对话记录链接。

v1:初始原型

一切始于今年 7 月,用的是 Claude Fable 5:

We are going to build a mobile friendly RTS game - command and conquer style - called Battle Drones, in which two armies of drones (both flying and ground-based) battle for territory and resources

Let's start with a MVP design, ask me some questions

这是一份共享对话记录。我给 Claude Code for Web 配了一个带 OpenAI API key 的环境变量,让它用 OpenAI 的图像生成 API 来生成素材,于是有了一些基础贴图。

你可以在此试玩 v1——它长这样:

Game screen. Down the right are text icons to build Fab, Airpad, Turret, Harv, Sting, Flak, Scout, Wasp, Raptor. There is a blocky fog of war on a 2D battlefield. There are some gems, an HQ building being attacked by badly rendered tanks, and some blue vehicles dotted around. It's not very visually impressive but it does look like a basic RTS.

它能被认出是一个 RTS,有建造机制,能选中并指挥单位,还有一个基础 AI 可以对战。

这第一个版本只能算概念验证,而且一点都不好玩。

Claude 在这些早期版本里用了 Phaser 2D 游戏框架。我直到好几轮迭代之后才意识到这一点!

v2:完整贴图

第二个版本(点此试玩 v2)为所有载具加上了贴图,并加入了“AI 对战 AI”模式,这样我不用自己亲自操控也能观看游戏进行。

事实证明,Claude 在 prompt OpenAI 的图像模型生成贴图方面相当能干。你可以在 public/assets/sprites 目录里浏览 v2 的贴图。

Four flying units, three turrets, a harvester and an airpad all have proper sprites now. The scrap field has a new design which doesn't look great but is at least using a graphic.

v3:多样地形

它还是不够好玩,画面也很无聊。这时已经到了 10 月,我升级到了 Claude Opus 5.5。我对它说:

Massively improve this game. Make the graphics and gameplay better (keep it mobile friendly). Render new graphics using the latest OpenAI GPT image API (lookup details) with the API key in the environment variable. Add new unit types and balance the gameplay better. Also add new buildings and better, more varied terrain.

这一 prompt 带来了五张新地图,配上了风格各异的生成背景贴图,可在此查看。Opus 还重新生成了贴图,视觉上好看了不少。你可以在此试玩 v3——它长这样:

The map is now an ice map with snow and ice and broken ice - it looks really good. The vehicles and buildings have all had a cosmetic upgrade too. This is starting to look like a real game.

这开始有点真正游戏的感觉了!不过它还是不太好玩——我发现自己很快就觉得无聊。

v4:好玩更新

到目前为止,我的 Battle Drones 实验一直在印证我此前的判断:coding agent 能做出看起来像游戏的东西,但做不出真正让人玩得下去的游戏。

我在一次晚餐时跟人分享了这个理论,随后心想,我应该给模型一个正经的机会来证明我是错的。于是我在手机上给 Opus 5.5 发了这样的 prompt:

This game isn't fun enough yet. Make it a LOT more fun.

这次我跑在 Ultracode 模式下,Claude Code(这里是 Claude Code for Web)会运行“动态工作流”,官方文档的描述是:

动态工作流是一个同时编排多个子代理的 JavaScript 脚本。

这一下启动了好几个小时的工作。我晚上启动,直到第二天上午很晚才拿到可玩的结果。但结果非常惊艳。

你可以在此试玩 v4——它长这样:

The lava map. Uplink satellites are being taken, crystals look better, Elite text is shown above a unit, there is an arrow marked Fight to jump to a fight, the AI vs AI mode has a speed controller - plenty of new features here.

我让 Claude 自己撰写了发布说明——要点如下:

现在每场遭遇战和每日行动都会以一个选择开局,给落后的一方一条翻盘的路径,并把双方军队引向地图中央。此外还有两种新玩法。

战斗持续更久、局势反转更多。在普通难度下的 1,200 场 AI 对战 AI 测试赛中,25 分钟后仍未分出胜负的对局比例从 14% 降到了 0.9%;曾落后 800 以上 scrap 的一方最终获胜的比例从 24% 升到了 46%。

Claude 花这么久,部分原因是它跑了一千多场模拟试玩,并用结果重新平衡了现有单位、加入新单位、引入新功能。

v5:Battle Drones 走进 3D

在 Ultracode 的“Make it a LOT more fun”大获成功之后,我决定更大胆一点:

Port this game to three.js with 3D models for all of the buildings and vehicles and landscapes

这又是一个通宵任务。我一觉醒来,就看到了这个 v5 版本:

Now it is in 3D - the battlefield is at a slight angle, the buildings and vehicles are all 3D models, the rocks and trees look a bit 3D as well.

新的 3D 模型完全是 Claude 用 TypeScript 代码构建出来的。

v6(试玩 v6)增加了更多视觉打磨。v7(试玩 v7)加入了机器人步兵(troopers、rocket squads、snipers)和“Condor”运兵机。

v8:Archipelago

我开始感到内疚——自己对这款游戏实际设计的投入太少了:过去几个版本真的就是我在说“让它更好玩”“加点视觉打磨”。

我注意到 AI 很少使用 v7 新增的步兵和运兵机——没有什么好的战略理由去用它们。

如果能有一张新地图,配上一种能切实鼓励玩家把步兵机器人装进 Condor、派往地图各处的新机制,那就太妙了。

于是我写下了迄今最长的一段 prompt:

Design a new map. Goal is to make different strategic incentives that encourage use of Infantry and Condors and aerial vehicles.

To do this the map will have limited harvester resources but several more uplinks - but uplinks will be on islands that are inaccessible by land vehicles or infantry. These uplinks can also not be claimed using air vehicles. The ONLY way to get them is to fly infantry there in a Condor.

Armies always start with a Condor and a single squad. If an army has no Condor a new one will be provided for free, flying in from the edge closest to their HQ and landing there. That free condor will come with a single free squad on board.

The two HQs should be entirely separated by water, but still accessible by vehicles thanks to two bridges across the map in different places

I want to encourage a battle over uplinks.

The map should be the times the size of other maps - still square

First research and then critique this design. Only build after we have agreed on any modifications

You get to design a new biome for this

成果就是热带风情的 Archipelago 地图:七个岛屿 uplink,玩家只有用 Condor 把步兵空运过去才能占领。在你从简单地图掌握了基本机制之后,这绝对是最好玩的一张图。v9 版本让这张图更有意思——它现在长这样:

Three islands, each with an uplink satellite. Blue holds one, red holds another, A blue condor is flying towards the red island, which is guarded by a red plane. There is a bridge nearby. The theme is tropical islands and looks very pleasant.

v10:Goliath 与 agent 对战

我决定给游戏加入巨型机器人机甲——想想《环太平洋》里的 Jaeger,或者《战锤 40,000》里的 Titan。

下面是我用来和 Claude 头脑风暴的一些 prompt:

Help me brainstorm ideas for adding giant robots to this game - think dreadnoughts or titans from W20K - how could we do this in a way that enhanced gameplay, kept things balanced, added unique twist? Don't overthink this yet

Let's keep brainstorming. I like the idea that it's a mobile base - that can accept harvested scrap and can have buildings built near it (even if it later moves on) and can produce infantry units too. An interaction with condor would be neat but I don't know what that could be.

Idea: as it gets damage it loses the ability to fire some weapons - by default it has eye laser (like lancers) and arm canons (like titan) and two shoulder mounted mortars, plus machine guns similar to a squad of troops

Damage knocks out mortars and then laser - it always has guns. You can't build next to a building that was only put there because of the mech, you need the mech there for off-base building and only within three squares of it

[...] Lets do two condors can carry the mech

最终成果非常酷。

Video poster frame

Goliath 需要用 Gantry 建造——而 Gantry 只有在先建好 Fab、Bay、Airpad 和 Tech Lab 之后才能建造。你可以看到 Goliath 处于建造中的状态,然后它会从 Gantry 里走出来,在地图上四处行进。

Goliath 可以“锚定”(anchor),把自己扎进地面。锚定状态下它可以充当一个新的 HQ,在一片新区域里建造步兵单位和更多建筑。

两架 Condor 可以钩住一台 Goliath,然后带着它在地图上飞来飞去!

现在,游戏的胜利条件是摧毁敌方的 HQ 建筑以及他们可能建造的任何 Goliath。

还有几个与 Goliath 相关的 mutator:

  • Goliath Armada:双方开局各有四台空降的 Goliath(每台配一对 Condor),没有其他单位。

  • Robot Love:添加一条特殊规则——如果敌对的 Goliath 在战场上彼此靠得足够近,它们会坠入爱河,游戏以平局结束。(这条要感谢 Natalie。)

Agent 对战

v10 的另一个功能是 agent 对战。在琢磨多人模式该怎么做的时候,我冒出一个想法:要是让不同的 LLM 在游戏里一决高下会怎样?

Fun extra challenge: think about how we might make multiplayer available to coding agents. It would be neat if we could set up a battle between eg GPT-6 Sol and Claude Opus 5.5 where each model has access to a tool which gives them information about the game (presumably non-visual, but only the information they could see through fog of war etc) and lets them control their units etc [...]

Consult ~/dev/llm/docs and include notes in that file about how LLM could be used here via a new tools plugin

Opus 5.5 开始动手,产出了这份 AGENT-BATTLES.md 提案,随后实现并测试了它。这个功能还包括录制和回放对战的能力——这是一场 Claude Haiku 5.5 对阵 GPT-6 Luna 的回放,这是同一场对战在一个单独的调试工具里的样子,可以看到底层的 prompt 响应。

Screenshot of a replay of a real-time strategy game between two AI models, shown from a top-down view of a snowy map with a dark frozen lake of cracked ice floes on the left and pine forests at the top and lower right. Top bar: pause button, "6", "1×", "anthropic/claude-haiku-5-5 · industry" in blue, "gpt-6-luna · industry" in red, a blue-and-red strength bar labeled "B" and "R", and "0". Left notification: "Blue: Pushing turrets at the enemy's south-east edge." Replay panel: "Blue anthropic/claude-haiku-5-5 · industry vs Red gpt-6-luna · industry · frostbite seed 42", a timeline slider at "6 / 7", and buttons "−30s", "+30s", "All", "Blue's eyes", "Red's eyes", "Notes". In the scene, a group of blue tanks and a large blue Goliath mech trailing smoke advance near the ice edge at lower center, while a column of red turrets (one burning) lines the ice to their north, red tanks and trucks sit by a rocky ridge to the east, and red base buildings occupy the top right. A minimap is in the top right corner and zoom in, zoom out and lightning-bolt buttons are on the lower left.

驱动 agent 对战的 prompt 可在此查看。

README 里还链接了几场类似的回放。我希望将来某个时候能把它做成一个完整的排行榜。

v11:随机地图

这个版本的存在纯属偶然:某天我瞄了一眼自己的 Claude 用量页面,发现每周额度只用了 75%,而且 45 分钟后就要重置。我决定看看能不能用剩余的 token 挤出 Battle Drones 的一个额外功能,于是选了“随机地图”作为目标:

Design and implement a mechanism for generating a random map using any of the available biomes - it should be the size of the largest map and rivers and bridges and rocks and forest and scrap and crystals are all in play. Make them rotationally symmetric and use a seed to allow them to be selected or reused later. You have 45 minutes to build this! Be creative.

这是对话记录,还有 Claude 生成的一张展示它工作成果的图片:

Grid of ten top-down game maps, two per biome (temperate, desert, arctic, volcanic, tropical), each with a river or lava flow, bridges and roads. Title: "Battle Drones: generated maps (108x108, point-symmetric), 2 per biome, runtime ground painter". Each map is captioned with a name and layout type plus a seed and crossing counts, e.g. "Hawthorn Delta · fork" "random-temperate-1x8a6r2 · 6 bridges, 4 fords"; layout types are fork, badlands, crossing and lake.

v12:通过声音联机

这个功能我刚刚才跑通,还没来得及认真测试。最新版 Battle Drones 现在支持两台放在彼此麦克风距离内的设备联机对战!

这个功能源自我上周的 Chirp Pong 实验。我把 Claude Code 指向那个已经跑通的概念验证:

Clone Simonw/tools from GitHub and look at recent branches for the example pong game that uses web microphone to implement multiplayer between two phones via audio signals

Build a version of that for battledrones

Opus 构建了这个 Radio Probe 工具来测量两台设备之间能获得多少带宽,并基于测得的不错结果实现了一套完整的音频调制解调(modem)系统。到目前为止我在笔记本、iPhone 和 iPad 之间试过,效果似乎相当好!

为什么要用声音?因为我热爱静态 HTML——运行成本为零——我不想在某个地方起一台服务器,然后只要还有人想玩这个游戏,我就得一直负责维护它运转。

一些想法

我对游戏开发几乎一窍不通。这反而成了试炼 coding agent 的绝佳机会——在这个领域,我既有的软件工程经验对结果的影响更小。

游戏的风险也超低。最坏的情况无非是我某个傻傻的游戏实验出个 bug。

今天早上(经由 Hacker News)我读到了这篇报道:Steam 玩家恳求官方推出“无 AI”过滤器,因为 Steam Next Fest 已被 AI 粗制滥造的内容淹没。我个人做梦也不会想把 Battle Drones 提交给这类活动——它的用心程度还远远不够格被当作一个正经的独立游戏项目。

……但我现在能看到一条路:这样的 vibe coded 游戏有可能被认真对待。Battle Drones 好玩、好看,还有创新的功能(音频联机这一招,据我所知在 RTS 里是头一回)。

我很想看看,一个比我更有品位、怀着打造真正杰出作品的热情的人,能做出什么来!

这个项目还有一些其他观察:

  • 静态 HTML 加 JavaScript 是游戏开发的绝佳媒介。WebGL 表现很好,Three.js(以及之前的 Phaser)都是非常优秀的构建平台,而且当前这些模型对它们了如指掌。

  • 这也让游戏可以作为渐进式 Web 应用(PWA)运行——我从没要求过,但 Battle Drones 可以离线玩。我在飞机上玩过它,尽管我从没主动安装过——我的手机把它缓存了下来。

  • 给 Claude 一个 OpenAI API key,让它用 OpenAI 的模型生成图片,效果非常好。它能查看自己生成的图片,并迭代改进 prompt。

  • Opus 5.5 用 Three.js 做 3D 建模的能力惊人(Blender 以及其他 3D 应用无疑也一样)。GPT-6 Astra 同样如此。它们完全有能力为 3D 游戏项目构建模型。

  • 对于回放和多人模式这类功能,确定性的模拟引擎很有用。有一次 Claude 不得不把 Math.sin()、Math.cos() 这类调用替换成自定义版本,因为不同浏览器(比如 Chrome 和 Safari)返回的数字有极细微差别,会让回放失去同步。

  • Opus 5.5 还会写音乐!这个项目里没有任何音频文件——配乐完全由代码生成,不同地图各不相同,甚至战况升温时会变得更激烈。之前用 Claude 做音乐作曲的实验见 Scrimshaw Jukebox。

  • 我仍然对“Make it a LOT more fun”这个 prompt 的好用程度感到不可思议。

  • 工具几乎是免费的。我用 prompt 随手做出了 Radio Probe、模型浏览器、Agent 对战 Agent 调试工具,Claude Code 还给自己建了一批工具,我自己都还没研究过。

  • 静态 HTML 游戏之间的音频联机是可行的!我希望看到更多游戏采用同样的模式——今天搜了一圈,除了 Alon Horesh 的 Siner 和 Georgi Gerganov(也是 llama.cpp 的作者)的 ggwave,没找到太多先例。

  • Claude Code 的“Ultracode”烧 token 如流水,但它也能用一个 prompt 解决复杂问题(比如加入音频联机)。

  • 我还是没完全摆脱用这种方式做软件的内疚感。我觉得自己配不上在这么一个几乎毫无经验的领域创造出这么好的东西!到现在我已经私下给足够多的人看过它,再不公开发布出来让大家看到、让大家从中学习,反而觉得不对劲了。

更新:在线多人模式支持

我在本文前面说过:

游戏的风险也超低。最坏的情况无非是我某个傻傻的游戏实验出个 bug。

然后我和 Natalie 试玩了多人版……尖锐的 modem 声音让她头痛得厉害!

这是个相当糟糕的 bug。我加了一条警告,随后受到启发去做了正经的网络多人模式。我试过让 WebRTC 跑起来,但即使在我自己的 WiFi 网络下,我自己的两台设备之间也建立不了连接,于是我让 Claude 构建了一个简单、无状态的 WebSocket 中继服务器:

If I wanted to support multiplayer between two devices at a very low cost without storing any state on the server could I do that with a tiny asyncio web server running on the cheapest Fly instance?

Build the server and the fly.toml for deploying it, use Fly application name battledrones-relay - put that in a folder in the repo, include deploy instructions in the README in that folder

这是最终做出来的服务器。由于它可以缩容到零,并且只跑在单个 Fly.io 的 shared-cpu-1x 实例上,成本应该不会超过每月 2.19 美元——而且这还是它全程保持热机、持续服务连接的情况。

Battle Drones 现在支持在线多人模式。点击“Duel a friend online”,然后把生成的房间 URL 通过你常用的消息应用发给朋友,或者让对方扫描屏幕上显示的二维码。

我还加了一个功能:比赛结束后可以复制这场对局的 JSON,把它喂给回放功能,重新观看自己的游戏。

我没料到这么快就要做在线多人模式,但那个让人头痛的 bug 让我觉得有必要紧急提供一个替代方案。

你看到的是我博客上的长文。订阅 /atom/everything/ 可以收到我的全部文章,或者看看我的其他订阅方式。