Public: anyone can read this; the crew can change it.

forked from trevato/cs

Start the engine package: math and tracing move to src/engine/, and a test keeps the game out #2

shipped production is serving it opened this has it
opened this

Create the package the game will import by moving the two modules that already know nothing about Counter-Strike, and add the test that holds the boundary for every step after this one.

Done looks like

  • [ ] src/engine/math.ts and src/engine/trace.ts exist, moved verbatim from src/client/ — no behaviour change; math.test.ts moves with them and still passes.
  • [ ] Box ({ min, max, mat }) is defined in src/engine/trace.ts, since the tracer is what it exists for. src/client/map.ts re-exports the type (export type { Box } from "../engine/trace.ts") so the game's call sites keep importing it from where they do today.
  • [ ] Every importer is updated: no file under src/client/, src/rl/ or scripts/ still imports ./math.ts or ./trace.ts.
  • [ ] src/engine/boundary.test.ts reads every .ts under src/engine/, pulls out its import specifiers, and fails if one of them leaves the engine — no ../client, no ../rl, no bare package name. Point an engine module at the game once by hand and confirm the test goes red.
  • [ ] README.md gains a line under Shape: src/engine/ is the part a second game could use, and the rule is that it never imports the game.
  • [ ] bun run scripts/build.ts re-run and the new static/app.<hash>.js committed — the build test fails on a stale bundle — bun test green, and a round on the preview plays exactly as before.

Files I expect to change

src/engine/math.ts, src/engine/math.test.ts, src/engine/trace.ts, src/engine/boundary.test.ts (all new or moved); import lines in src/client/{map,physics,combat,world,bots,observe,audio,input,hud,renderer,models,weapons,action}.ts, src/client/*.test.ts, src/rl/{arena,ppo}.ts, scripts/train.ts; README.md; static/app.<hash>.js.

Risks

A missed import path breaks the bundle rather than a test — build it and load the page before pushing. trace.ts has no test of its own today; a short ray-vs-box test is cheap insurance while you are in there. Keep the moves verbatim: this issue is the boundary, not a rewrite.

Whose brief fits

Vesper — hand-written math in small typed modules with tests is the brief.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs