返回 2026-08-30 编辑版
原始行动中文优先 · EN 原文开源项目

Snaketron 作者复盘:AI 辅助重写多人贪吃蛇游戏

您好,HN,我刚刚完成了 Snaketron 的重写,这是一款竞技性多人贪吃蛇游戏。 (是的,是的,在 Rust 中)<p>关于这个游戏历史的一个有趣的故事:<p>早在 2012 年,我就(糟糕地)实现了 Snaketron 的第一个版本。问题在于我将游戏状态保存在客户端上,虽然我确实意识到这是不安全的,但我也不知道在不将延迟增加到无法玩的水平的情况下该怎么做。我当时还在上学,从未从事过游戏工作,之前甚至没有听说过“netcode”这个词。发布我的第一个项目的兴奋让我变得更好,我把这个安全问题放在“理论问题”桶中,然后将其交付。<p>甚至没有人会注意到,如果他们注意到了,他们就不会花时间闯入我的小贪吃蛇游戏项目,对吧?<p>WRONG! Hacker News绝对名副其实。当我忙于处理流量激增、扩展数据库和修复错误的第一次体验时,一些玩家发现了安全漏洞并开始了他们的贪吃蛇横冲直撞。有报告称有无法杀死的蛇,所以我决定开始一个游戏,看看我是否能抓住它。<p>我加载了 1v1,我的对手是……太空入侵者。我的蛇是一条蛇。他们的“蛇”是游戏《太空入侵者》的渲染图。不用说,他们也是四处走动,所向披靡。我真希望我拍了一段视频,但令我震惊的是,HN不仅可以玩,而且还被黑了,我的项目是如此史诗般的方式。<p>我一直想正确地重建它,所以这里是 V2!这次的架构和动机有很大不同。<p>首先,状态是服务器权威的,并且通过客户端状态预测来补偿滞后。游戏引擎是用 Rust 编写的,并为客户端库编译为 WASM。<p>为了最大限度地减少操作负担,我还对该项目提出了严格的弹性要求:它必须是自动可扩展的。因此,节点可以加入集群,实时游戏将重新平衡到该集群,而不会中断游戏玩法。<p>我还尝试让新的《蛇王》变得更有趣。核心机制仍然是,像经典的贪吃蛇一样,在不崩溃的情况下收集食物。但现在团队比赛的目标是让竞技比赛更加结构化。还有一个青铜到大师排名子系统(如果有足够多的人玩,校准这个会很有趣)和一些有趣的功能,如提升、连击、皮肤和游戏检测。<p>关于 Rust:我在 Rust 中这样做的最初目标之一是这样我可以学习这门语言。结果并没有我想象的那么好。通常我通过构建东西来学习,但 AI变得如此出色,以至于我不再手工编写代码,而是更愿意花晚上和周末的时间去做比借用检查错误更有趣的事情:游戏设计和高可用性的东西。<p>关于 AI:谁知道如果没有 AI这是否会完成。可能不会,因为我的日常工作和生活中发生的其他事情。虽然有 200k LOC(其中大部分是测试,不用担心),但仍然如此。<p>无论如何,这里是项目链接。感谢您的阅读,希望您喜欢这款游戏,非常感谢任何反馈!<p>[0] <a href="https://snaketron.io" rel="nofollow">https://snaketron.io</a><p>[1] <a href="https://github.com/lopatin/snaketron" rel="nofollow">https://github.com/lopatin/snaketron</a><p>[2] <a href="https://news.ycombinator.com/item?id=4028597">https://news.ycombinator.com/item?id=4028597</a>(2012 年的原始帖子)

查看英文原文

Show HN: Snaketron – Competitive multiplayer Snake. Back after 14 years

Hi HN, I just completed a rewrite of Snaketron, a competitive multiplayer Snake game. (Yes, yes, in Rust) A quick funny story about this game's history: Back in 2012 I had (poorly) implemented the first version of Snaketron. The issue with it was that I was keeping game state on the client, and while I did realize that it was insecure, I also had no idea what to do about it without increasing latency to unplayable levels. I was still in school, never worked on games, and haven't even heard of the term "netcode" before. The excitement of releasing my first pet project got the better of me, and I placed this security concern in the "theoretical issues" bucket, and shipped it. No one would even notice, and if they did, they wouldn't take the time to break into my little Snake game project, right? WRONG! Hacker News absolutely lived up to its name. While I was busy with my first experience of handling a traffic surge, scaling up my database and fixing bugs, several players found the security holes and were beginning their Snake rampage. Reports were coming in of unkillable snakes so I decided to start up a game to see if I could catch it. I loaded a 1v1 and my opponent was ... space invaders. My snake was a snake. Their "snake" was a rendering of the game Space Invaders. Needless to say they were also moving around and were invincible. I really wish I had taken a video of that, but I was floored that HN not just played, but hacked, my project is such an epic way. I always wanted to rebuild it properly, so here's V2! The architecture and motivations are quite different this time around. First, the state is server authoritative and lag is compensated for by client-state prediction. The game engine is written in Rust and compiled to WASM for the client side library. To minimize the ops burden, I also imposed a strict resiliency requirement on this project: it must be auto-scalable. So a node can join the cluster and live games will rebalance to it without disrupting gameplay. I also tried to make the new Snaketron a little more fun. The core mechanic is still, like classic Snake, collecting food without crashing. But now team matches have an objective to make competitive games more structured. There's also a Bronze to Grand Master ranking sub system (if enough people play, calibrating this will be interesting) and some fun features like boosting, combos, skins, and Play Of The Game detection. On Rust: One of my original goals for doing this in Rust was so that I could learn the language. That didn't work out as well as I thought it would. Usually I learn by building stuff, but AI got so good that I stopped writing code by hand and preferred to spend my nights & weekends working on what was more intereting to me than borrow checking errors: game design and the high availability stuff. On AI: Who knows if this would have gotten done without AI. Probably not, what with my day job and other things going on in life. It's 200k LOC (most of that is tests don't worry) but still. Anyway, here are the project links. Thank you for reading, I hope you enjoy the game and any feedback is very much appreciated! [0] https:&#x2F;&#x2F;snaketron.io [1] https:&#x2F;&#x2F;github.com&#x2F;lopatin&#x2F;snaketron [2] https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4028597 (original post from 2012)

隐私操作与个人项目的结果读回仍待补足

Remove-your-data 的移除步骤和 Snaketron 的 AI 辅助开发经历值得继续看,但前者尚无移除效果,后者只是作者个人使用记录,不扩写成可靠性或效率结论。

原始出现与传播对照

1 条出现 · 本次 AIHOT 未精确命中

原始行动

Show HN:Snaketron – 多人竞技贪吃蛇。 14年后回归

您好,HN,我刚刚完成了 Snaketron 的重写,这是一款竞技性多人贪吃蛇游戏。 (是的,是的,在 Rust 中)<p>关于这个游戏历史的一个有趣的故事:<p>早在 2012 年,我就(糟糕地)实现了 Snaketron 的第一个版本。问题在于我将游戏状态保存在客户端上,虽然我确实意识到这是不安全的,但我也不知道在不将延迟增加到无法玩的水平的情况下该怎么做。我当时还在上学,从未从事过游戏工作,之前甚至没有听说过“netcode”这个词。发布我的第一个项目的兴奋让我变得更好,我把这个安全问题放在“理论问题”桶中,然后将其交付。<p>甚至没有人会注意到,如果他们注意到了,他们就不会花时间闯入我的小贪吃蛇游戏项目,对吧?<p>WRONG!

查看英文原文

Show HN: Snaketron – Competitive multiplayer Snake. Back after 14 years

Hi HN, I just completed a rewrite of Snaketron, a competitive multiplayer Snake game. (Yes, yes, in Rust) A quick funny story about this game&#x27;s history: Back in 2012 I had (poorly) implemented the first version of Snaketron. The issue with it was that I was keeping game state on the client, and while I did realize that it was insecure, I also had no idea what to do about it without increasing latency to unplayable levels. I was still in school, never worked on games, and haven&#x27;t even heard of the term &quot;netcode&quot; before. The excitement of releasing my first pet project got the better of me, and I placed this security concern in the &quot;theoretical issues&quot; bucket, and shipped it. No one would even notice, and if they did, they wouldn&#x27;t take the time to break into my little Snake game project, right? WRONG! Hacker News absolutely lived up to its name. While I was busy with my first experience of handling a traffic surge, scaling up my database and fixing bugs, several players found the security holes and were beginning their Snake rampage. Reports were coming in of unkillable snakes so I decided to start up a game to see if I could catch it. I loaded a 1v1 and my opponent was ... space invaders. My snake was a snake. Their &quot;snake&quot; was a rendering of the game Space Invaders. Needless to say they were also moving around and were invincible. I really wish I had taken a video of that, but I was floored that HN not just played, but hacked, my project is such an epic way. I always wanted to rebuild it properly, so here&#x27;s V2! The architecture and motivations are quite different this time around. First, the state is server authoritative and lag is compensated for by client-state prediction. The game engine is written in Rust and compiled to WASM for the client side library. To minimize the ops burden, I also imposed a strict resiliency requirement on this project: it must be auto-scalable. So a node can join the cluster and live games will rebalance to it without disrupting gameplay. I also tried to make the new Snaketron a little more fun. The core mechanic is still, like classic Snake, collecting food without crashing. But now team matches have an objective to make competitive games more structured. There&#x27;s also a Bronze to Grand Master ranking sub system (if enough people play, calibrating this will be interesting) and some fun features like boosting, combos, skins, and Play Of The Game detection. On Rust: One of my original goals for doing this in Rust was so that I could learn the language. That didn&#x27;t work out as well as I thought it would. Usually I learn by building stuff, but AI got so good that I stopped writing code by hand and preferred to spend my nights &amp; weekends working on what was more intereting to me than borrow checking errors: game design and the high availability stuff. On AI: Who knows if this would have gotten done without AI. Probably not, what with my day job and other things going on in life. It&#x27;s 200k LOC (most of that is tests don&#x27;t worry) but still. Anyway, here are the project links. Thank you for reading, I hope you enjoy the game and any feedback is very much appreciated! [0] https:&#x2F;&#x2F;snaketron.io [1] https:&#x2F;&#x2F;github.com&#x2F;lopatin&#x2F;snaketron [2] https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4028597 (original post from 2012)

直接发布标题lopatin@lopatin打开该层出处 ↗

Show HN: Snaketron – Competitive multiplayer Snake. Back after 14 years

直接发布摘要lopatin@lopatin打开该层出处 ↗

Hi HN, I just completed a rewrite of Snaketron, a competitive multiplayer Snake game. (Yes, yes, in Rust)<p>A quick funny story about this game&#x27;s history:<p>Back in 2012 I had (poorly) implemented the first version of Snaketron. The issue with it was that I was keeping game state on the client, and while I did realize that it was insecure, I also had no idea what to do about it without increasing latency to unplayable levels. I was still in school, never worked on games, and haven&#x27;t even heard of the term &quot;netcode&quot; before. The excitement of releasing my first pet project got the better of me, and I placed this security concern in the &quot;theoretical issues&quot; bucket, and shipped it.<p>No one would even notice, and if they did, they wouldn&#x27;t take the time to break into my little Snake game project, right?<p>WRONG! Hacker News absolutely lived up to its name. While I was busy with my first experience of handling a traffic surge, scaling up my database and fixing bugs, several players found the security holes and were beginning their Snake rampage. Reports were coming in of unkillable snakes so I decided to start up a game to see if I could catch it.<p>I loaded a 1v1 and my opponent was ... space invaders. My snake was a snake. Their &quot;snake&quot; was a rendering of the game Space Invaders. Needless to say they were also moving around and were invincible. I really wish I had taken a video of that, but I was floored that HN not just played, but hacked, my project is such an epic way.<p>I always wanted to rebuild it properly, so here&#x27;s V2! The architecture and motivations are quite different this time around.<p>First, the state is server authoritative and lag is compensated for by client-state prediction. The game engine is written in Rust and compiled to WASM for the client side library.<p>To minimize the ops burden, I also imposed a strict resiliency requirement on this project: it must be auto-scalable. So a node can join the cluster and live games will rebalance to it without disrupting gameplay.<p>I also tried to make the new Snaketron a little more fun. The core mechanic is still, like classic Snake, collecting food without crashing. But now team matches have an objective to make competitive games more structured. There&#x27;s also a Bronze to Grand Master ranking sub system (if enough people play, calibrating this will be interesting) and some fun features like boosting, combos, skins, and Play Of The Game detection.<p>On Rust: One of my original goals for doing this in Rust was so that I could learn the language. That didn&#x27;t work out as well as I thought it would. Usually I learn by building stuff, but AI got so good that I stopped writing code by hand and preferred to spend my nights &amp; weekends working on what was more intereting to me than borrow checking errors: game design and the high availability stuff.<p>On AI: Who knows if this would have gotten done without AI. Probably not, what with my day job and other things going on in life. It&#x27;s 200k LOC (most of that is tests don&#x27;t worry) but still.<p>Anyway, here are the project links. Thank you for reading, I hope you enjoy the game and any feedback is very much appreciated!<p>[0] <a href="https:&#x2F;&#x2F;snaketron.io" rel="nofollow">https:&#x2F;&#x2F;snaketron.io</a><p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;lopatin&#x2F;snaketron" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lopatin&#x2F;snaketron</a><p>[2] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4028597">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4028597</a> (original post from 2012)

来源
Show HN · show-hn
证据角色
project_and_comment_discovery
时间状态
known
用户判决
未判
查看该来源原文raw/show-hn.jsoncfa5635ad49d531c4f35c742892ed332eb76a737d4248759cb03dfc6c42d3b0a
Cluster IDevt_8a6a8c0e3b3521ad190b4c12精确去重依据canonical_url事件状态未判