Skip to content

ai-training/scenario.ts step() is CCN 36, the worst left in src/ #6

Description

@cgreening

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions