
有意義な時間 - そう、Claude の mod で Doom を動かせる
……移植は本当にうんざりするほど大変だった。仕組みを短く言うと、mod サンドボックスには WebAssembly がないため、mod が $.process.spawn で起動するネイティブバイナリを使い、Unix socket で通信する(Windows では 127.0.0.1 + token)。zig cc で linux/macos/windows × x86_64/arm64 向けにビルド済みなので、kitty ではコンパイラー不要。

この mod について
……移植は本当にうんざりするほど大変だった。仕組みを短く言うと、mod サンドボックスには WebAssembly がないため、mod が $.process.spawn で起動するネイティブバイナリを使い、Unix socket で通信します(Windows では 127.0.0.1 + token)。zig cc で linux/macos/windows × x86_64/arm64 向けにビルド済みなので、コンパイラーは必要ありません。
kitty では、画面はエンジンが書き出すファイルを指す Image です。Claude Code はパスを kitty に渡すだけで、ピクセルは 1 つも通りません。それ以外では Raster の象限ブロック(1 セル 4 px)を使います。他に動くものがないと Claude Code は ~3 frames/s しか描画しないため、ゲームの下にある帯を 30 ms ごとに再描画してフレームを出し続けます。kitty では ~31 fps、ブロック表示では ~35-40 です。
キーボード処理は厄介です。TS には "onPress" イベントしかありません。ターミナルはキーが離されたことを通知せず、リピート遅延の後に最後のキーを繰り返すだけです。Claude Code は kitty のキーボード flags 5 だけを有効にするため、mod からも離したことが見えません。最初はターンキーを 220 ms 押し続ける案を試しましたが、押し続けたターンがリピート開始まで約 ~300 ms 完全に止まりました。
そこで、他のターミナル Doom が入力を偽装する方法を調べました。
- doom-cli:リピート遅延を学習し、次のリピート時刻までキーを押し続ける
- intermission:押してから 550 ms、リピート中は 120 ms、方向転換はマウスだけ
- claude-doom:押すたびに 160 ms のパルス
- doom-braille:100 ms 無音になったら離す
doom-cli の方式を採用し、さらにそのソースの TODO が示す修正も入れました。リピートが始まるまでゆっくりターンします。今はタップで約 ~10° 回転し、以前の ~60° ではありません。キーを押し続けても止まりません。
マウスだけは離したことを報告する入力です。そのためゲーム上で横にドラッグすると a/d とまったく同じ速度で曲がり、離した瞬間に止まります。w/s で歩きながら、同時にマウスで方向転換できます。
もう 1 つ。今のところ linux でしか遊んでいません。macos と windows のエンジンはビルド済みですが、まだ実行していません。mac/windows を使っているなら、動くか教えてほしいです。
/plugin marketplace add reporails/arcade /plugin install doom@reporails-arcade を実行し、その後 CLAUDE_CODE_NO_FLICKER=1 claude、続けて /doom を実行します。
repo: github.com/reporails/arcade(MIT。エンジンは GPL-2.0、ゲームデータは Freedoom、BSD)。submitted by /u/cleverhoods [link] [comments]
インストール
インストール方法は元のソースをご確認ください。
原文 / README
... and it was annoying as hell to port it. how it works, short version: the mod sandbox has no WebAssembly, so the engine is a native binary the mod starts with $.process.spawn and talks to over a unix socket (127.0.0.1 + a token on windows). prebuilt for linux/macos/windows × x86_64/arm64 with zig cc, so no compiler needed in kitty the picture is an Image pointed at a file the engine writes. claude code just hands kitty the path, zero pixels go through it. everywhere else it's a Raster of quadrant blocks (4 px a cell) claude code only draws ~3 frames/s when nothing else moves, so a strip under the game redraws itself every 30 ms to keep frames coming. ~31 fps in kitty, ~35-40 with blocks keyboard managing is a nightmare, TS only has an "onPress" event. a terminal never tells you a key was released, it just repeats the newest key after its repeat delay. claude code turns on kitty keyboard flags 5 only, so mods can't see releases either. my first guess (hold a turn key 220 ms) made a held turn stop dead for ~300 ms before the repeats kicked in. what fixed it was reading how other terminal dooms fake it: - doom-cli: learn the repeat delay, hold a key until its next repeat is due - intermission: 550 ms after a press, 120 ms while repeating, mouse-only turning - claude-doom: 160 ms pulse per press - doom-braille: release after 100 ms of silence went with doom-cli's model, plus the fix its own source suggests in a TODO: turn slowly until the repeats start. a tap now turns ~10° instead of ~60°, and a held key never stops. the mouse is the only input that reports its release, so dragging sideways on the game turns at exactly the a/d speed and stops the moment you let go. walk with w/s and turn with the mouse at the same time. one more thing: played on linux only. macos and windows engines are built but they are yet to run, so if you're on a mac/windows, I'd love to know if it works. /plugin marketplace add reporails/arcade /plugin install doom@reporails-arcade then CLAUDE_CODE_NO_FLICKER=1 claude and /doom. repo: github.com/reporails/arcade (MIT; the engine is GPL-2.0, the game data is Freedoom, BSD). submitted by /u/cleverhoods [link] [comments]

