跳到正文
lauren· @poteto · X·· 1 小时前AI 评分61
AI 导读

Grok Bot 工程负责人 Lauren Tan 分享她 4 天前作为副业项目开始开发的游戏,落地约 1150 个 PR。每当发现代码问题就让 bot 加一条 lint 规则;大量使用 TLA+ 验证剧情、过场动画和游戏系统的状态机,每个主要系统各有一个形式化验证 skill。

正文 · 原文

trivia:

  • started working on the game as a side project 4 days ago, landing ~1,150 PRs
  • every time i found an issue in the code i asked bot to make a lint rule against it
  • used TLA+ heavily to find bugs in the game's various state machines: the story, cutscenes, the game's systems. there are many formal verification skills, one for each major system
  • i put context into the filepaths: code that runs every frame or every tick gets a .hot.ts extension, and a lint rule bans allocating in it (no object literals, closures, new, etc.), so the game loop creates almost no garbage and GC doesn't cause stutters
  • game engine is mostly custom. three.js draws the 3D scene, but the simulation, post-processing and audio are all ours
  • the simulation is fully deterministic, so every run replays exactly from its inputs. when you post a high score, the server replays your whole run to check it isn't cheated
  • we generate dynamic og:images for every run based on your final stats, and it's all localized too! the game supports 10 languages
  • my favorite feature: the music seamlessly transitions into different music for the various biomes, continuing the previous melody
  • no audio files. all the music and sound effects are synthesized live in the browser by a custom Game Boy-style chip (two pulse voices, a wave voice, noise) plus a synthwave layer. the songs are written as text in code
  • all the pixel art is code. every sprite is a file drawn with one shared palette and packed into a sprite atlas at build time
  • it runs inside an X post, from the 245px card up to full screen. the bar is 60 fps with 500 enemies on a mid-range phone
  • the build fails if the first download goes over budget. it's about 124 KB gzipped right now
  • bots play the game headless to tune each difficulty against target survival rates
  • comments are banned by a lint rule. if code needs explaining, the fix is a better name or a test

来源:lauren · x.com