step in src/ai-training/scenario.ts is the worst remaining function in the
codebase by cyclomatic complexity:
uvx lizard src --languages typescript -w
src/ai-training/scenario.ts:423: warning: step has 74 NLOC, 36 CCN, 731 token
For context, the average across 1006 functions in src/ is 2.2, and the
previous worst (runCommand, CCN 39) is now 1 after becoming a dispatch table.
This one is harder: it is the episode loop, and its branches are real
decisions (which controller flies, whether the episode is done, which fitness
term applies) rather than a dispatch that wants to be a lookup.
Care required: scenario.ts is invariant 5 — one combat model. A change
here changes the world every brain was trained in, so any refactor must be
proved equivalent on a fixed seed (identical episode outcome), not merely
self-consistent. Retraining is NOT an acceptable way to make the tests pass.
Lower priority than it looks: it is complex but heavily tested and stable.
stepinsrc/ai-training/scenario.tsis the worst remaining function in thecodebase by cyclomatic complexity:
For context, the average across 1006 functions in
src/is 2.2, and theprevious worst (
runCommand, CCN 39) is now 1 after becoming a dispatch table.This one is harder: it is the episode loop, and its branches are real
decisions (which controller flies, whether the episode is done, which fitness
term applies) rather than a dispatch that wants to be a lookup.
Care required:
scenario.tsis invariant 5 — one combat model. A changehere changes the world every brain was trained in, so any refactor must be
proved equivalent on a fixed seed (identical episode outcome), not merely
self-consistent. Retraining is NOT an acceptable way to make the tests pass.
Lower priority than it looks: it is complex but heavily tested and stable.