跳到正文
Simon Willison·· 4 小时前AI 评分68

Simon Willison 用 Claude 打造音频多人对战 RTS 游戏 Battle Drones

Battle Drones - a vibe coded RTS with audio-based multiplayer

AI 导读

Simon Willison 发布了用编码智能体开发的即时战略游戏 Battle Drones,共 12 个大版本、321 次 commit,主要用 Claude Code 完成,可在手机和桌面浏览器游玩。

正文 · AI 翻译

2026年10月20日

我最新的氛围编码游戏实验是一款名为 Battle Drones(点击这里试玩)的 Command & Conquer 风格 RTS(即时战略)游戏。与我之前的实验不同,这一款玩起来真的很有趣。有点不好意思承认,我达到这个效果的方式是让 Claude“让它变得有趣得多”。它还支持附近设备之间的多人游戏,使用音频来同步游戏状态!以下是我目前构建的内容,以及我在此过程中学到的一些东西。

Battle Drones

我最初的目标是构建一款可以在手机上玩的、Command & Conquer 风格的 RTS 游戏。我对 1995 年的原作有着美好的回忆(我也喜欢 Red Alert),想找回一点那种魔力。

经过 12 次大迭代(以及编码智能体的 321 次提交,主要使用 Claude Code),我现在拥有了一款基于浏览器的游戏,可在移动端和桌面端运行,有多种游戏模式、几张地图(包括随机地图生成器),甚至还支持彼此处于麦克风收音范围内的两台设备进行多人游戏。

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

目前已有的功能包括:

  • 9 种建筑、7 种地面载具、6 种空中载具、3 种步兵单位——全部为 3D 模型,你可以在这里浏览
  • 战争迷雾
  • 需要不同的武器来攻击空中或地面载具
  • 六张地图,横跨五种生物群系——温带、沙漠、极地、火山、热带
  • 随机地图生成器
  • 遭遇战模式——在旋转对称地图上红方对战蓝方
  • 背水一战模式——一名玩家抵御尽可能多的敌人波次
  • 范围效果武器:弹幕、EMP、空投舱、天锤
  • 补给箱空投,附带额外资源
  • 随事件变化的游戏内音乐——战斗爆发时变得更激烈
  • 不同的游戏内 AI 个性(Balanced、Rush、Air Swarm、Boom、Skyforce、Ironclad)
  • AI 对 AI 模式,观看这些个性互相对战
  • Goliath——一个巨型踏步机甲,拥有激光眼和臂部火炮,并能够建立新基地
  • 突变器,可添加额外规则或变化
  • 每日行动挑战
  • 军衔和成就(勋章)
  • 智能体对战智能体模式,两个 LLM 可以互相对战 Battle Drones
  • 一种多人模式,基于两台附近的手机通过音频消息通信,是我之前 Chirp Pong 实验的扩展

我是如何构建它的

Battle Drones 是重度氛围编码的产物——我几乎没审查过任何代码,而且它是用一种我自己几乎没用过的语言(TypeScript)构建的。不过我进行了相当多的试玩,而且自项目开始以来已经经历了大量迭代。

以下是目前为止项目的大致历史,包括关键提示词和对话记录的链接。

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 密钥的环境变量,并让它使用 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 在提示 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:多样化的地形

它仍然不怎么好玩,画面也很乏味。那时已经是十月了,我已经升级到了 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.

这产生了五张新地图,带有各种风格生成的背景瓦片,可见此处。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 实验印证了我之前的看法:编程智能体能构建出看起来像游戏的东西,却无法做出真正引人入胜、好玩的作品。

我在晚餐时和某人聊起了这个想法,然后心想应该给模型一个正儿八经的机会来证明我是错的。我在手机上向 Opus 5.5 发出了提示:

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 自己编写了发布说明——以下是其中的亮点:

每一场遭遇战和每日行动(Daily Op)现在都以一个选择开局,为处于劣势的一方提供翻盘途径,并把军队拉向地图中央。还有两种新的玩法。

  • 开局方案:在计时开始前选择 Blitz、Industry 或 Air Wing。
  • 召唤能力:弹幕、EMP、空投舱和“天锤”轨道打击。
  • 目标与回收:上行链路中继站、补给空投和值得回收废料的残骸。
  • 手感:战斗打击感、自适应音乐、单位语音和播报员。
  • 指挥:战斗警报、游戏速度、保存的编队和触屏部署。
  • 新模式:Last Stand 生存波次和包含 8 个任务的 Ops 战役。
  • 成长系统:英雄、附带奖项的战后报告、职业生涯、7 种变更器和每日行动。

战斗持续时间更长,局势反转更频繁。在普通难度下的 1,200 场 AI 对 AI 测试对局中,25 分钟后仍未分出胜负的比赛从 14% 降至 0.9%。曾经落后 800+ 废料的一方最终获胜的占比从 24% 升至 46%。

Claude 耗时如此之久的一部分原因是,它运行了一千多次模拟试玩会话,并利用这些结果来重新平衡现有单位、添加新单位并引入新功能。

v5:战斗无人机进入 3D

在 Ultracode 成功实现“让它有趣得多”之后,我决定更具野心:

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)加入了机器人步兵(士兵、火箭小队、狙击手)和一种名为“秃鹰(Condor)”的运兵飞机。

v8:群岛

我开始对自己在游戏中实际投入的设计输入如此之少感到内疚——在过去的几个版本中,真的就是我一直说着“让它更有趣”和“加一点视觉打磨”。

我注意到 AI 并不常使用 v7 中新增的步兵和运兵飞机——使用它们并没有什么出色的战略理由。

如果我们有一张新地图,配上一种新的游戏机制,积极鼓励玩家用步兵机器人装满秃鹰飞机,然后把它们派往地图各处,那就太棒了。

于是有了我迄今为止最长的一次提示词:

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

最终成果是热带风格的 群岛 地图,图上有七个岛上上行链路,玩家只能用秃鹰飞机把步兵运过去才能占领。等你掌握了更简单地图上的基本游戏机制之后,它绝对是玩起来最有趣的一张地图。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:歌利亚与智能体对战

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

以下是我用来和 Claude 进行头脑风暴的一些提示词:

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

最终结果 真的很酷。

歌利亚可以通过龙门架(Gantry)建造——这是一种必须先建造制造厂(Fab)、船坞(Bay)、停机坪(Airpad)和科技实验室(Tech Lab)之后才能建造的建筑。你可以看到歌利亚正在建造中,建成后它会从龙门架里走出来,并可以在地图上行进。

歌利亚可以“锚定”,也就是挖地扎根。锚定状态下,它们可以充当新的总部,在新区域建造步兵单位和额外建筑。

两架秃鹰飞机可以挂载一台歌利亚,此时它就可以被拖着在地图上飞行了!

现在,只有摧毁敌方总部建筑 以及 它们可能建造的任何歌利亚,游戏才会结束。

还有一些与歌利亚相关的变异规则:

  • 歌利亚舰队 让每一方开局拥有四台空中的歌利亚(每台配有一对秃鹰飞机),且没有其他单位。
  • 机器人之恋 加入了一条特殊规则:如果敌方歌利亚在战场上靠得太近,它们会相爱,游戏以平局结束。(这个点子要感谢 Natalie)。

智能体对战

v10 的另一个特性是 智能体对战。在思考多人对战如何实现时,我有了一个想法:如果让不同的 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 的回放,这是同一场对战在一个单独的调试工具中查看,其中显示了底层的提示词响应。

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:27", "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:03". 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:27 / 7:48", 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.

驱动智能体对战的提示词可以在这里看到。

还有几个类似的回放在 README 中链接。我希望将来能把它做成一个完整的联赛积分表。

v11:随机地图

这个版本的存在纯粹是因为有一天我瞥了一眼我的 Claude Usage 页面,发现我一周的配额只用了 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:通过声音实现的多人模式

我刚刚让这个功能跑起来,所以还没多少时间 actively 测试它。最新版的 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 工具来测量两台设备之间能获得多少带宽,基于它的积极结果,实现了一套完整的音频调制解调器系统。到目前为止我已在笔记本电脑、iPhone 和 iPad 之间试过,看起来运行得非常好!

为什么要用声音来做这件事?因为我热爱静态 HTML,它运行起来零成本,而我不想在某处架设一个服务器,然后只要还有人想玩这个游戏,就得一直负责维护它。

一些想法

我对游戏开发几乎一无所知。这恰好是一个绝佳的机会,可以在我现有的软件工程经验对结果影响较小的领域里试用编码智能体。

游戏的风险也极低。最坏的情况不过是我的某个愚蠢的游戏实验出了个 bug。

今天早上(来自 Hacker News)我看到了Steam Fans Are Begging for a No-AI Filter as Steam Next Fest Is Filled With Slop。我个人绝不会把 Battle Drones 提交到这样的活动——它还是太低成本了,不足以作为正规独立游戏项目获得考虑。

……但我现在能看到这种 vibe coded 游戏被认真对待的路径了。Battle Drones 很有趣,看起来不错,还有创新功能(就我所知,这种音频多人对战模式在 RTS 游戏中尚属首次)。

我很想看看比我品味更好、又满怀热情要打造真正杰出作品的人能构建出什么!

从这个项目中得出的另外几点观察:

  • 静态 HTML 和 JavaScript 是游戏开发的绝佳媒介。WebGL 表现出色,而 Three.js(以及之前的 Phaser)都是很好的构建平台,当前的模型对它们了如指掌。
  • 这也让它们能作为 Progressive Web Apps 运行——我没有要求这个,但 Battle Drones 支持离线运行。尽管从未直接安装过,我还是能在飞机上玩它——我的手机缓存了它。
  • 给 Claude 一个 OpenAI API 密钥并让它使用 OpenAI 的模型生成图像,效果非常好。它可以查看自己生成的图像并对提示词进行迭代。
  • Opus 5.5 在使用 Three.js(以及 Blender,毫无疑问还有其他 3D 应用)进行 3D 建模方面表现出色。GPT-6 Astra 也同样如此。它们完全有能力为 3D 游戏项目构建模型。
  • 对于回放和多人游戏这类功能,拥有一个确定性的模拟引擎很有用。有一次 Claude 不得不将对 Math.sin() 和 Math.cos() 等函数的调用替换为自定义版本,因为不同浏览器(例如 Chrome 与 Safari)返回的数字有非常细微的差异,导致回放失去同步。
  • Opus 5.5 会写音乐!这个项目中没有任何音频文件——配乐完全通过代码生成,在不同的地图上有所变化,甚至在战斗越激烈时变得越激昂。参见Scrimshaw Jukebox,这是之前一次用 Claude 进行音乐创作的实验。
  • 我仍然无法释怀“让它变得有趣得多”这个提示词的效果有多好。
  • 工具实际上几乎零成本。我提示生成了Radio Probe、Model browser、Agent vs. Agent debug tool,而 Claude Code 还为自己构建了一堆工具,连我自己都还没探索过。
  • 基于音频的静态 HTML 游戏之间的多人联机是可行的!我希望看到更多游戏采用同样的模式——今天翻查了一番,除了 Alon Horesh 的 Siner 和 Georgi Gerganov 的 ggwave(他也是 llama.cpp 的作者),我没找到太多先例。
  • Claude Code “Ultracode”烧起 token 来就像没有明天,但它也能从一个提示词解决复杂问题(比如添加基于音频的多人联机)。
  • 我仍然无法完全摆脱用这种方式构建软件的负罪感。我并不觉得自己有资格创造出这么好的东西,尤其是在这个我几乎没有先前经验的领域!到这时我已经私下给足够多的人看过,如果不让其他人也看到并从中学习,反而让我觉得不妥。

来源: Simon Willison · simonwillison.net