@reicek/neataptic-ts 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/copilot-instructions.md +11 -0
- package/.github/skills/trace-analyzer-extension/SKILL.md +3 -3
- package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +1 -1
- package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +1 -1
- package/.github/skills/trace-audit-reporting/SKILL.md +3 -3
- package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +1 -1
- package/package.json +19 -13
- package/plans/Flappy_Bird_Folder_Documentation_Pass.md +4 -4
- package/plans/README.md +24 -0
- package/plans/Roadmap.md +62 -40
- package/plans/analyze-trace-solid-split.plans.md +66 -0
- package/plans/architecture-solid-split.plans.md +9 -15
- package/plans/asciiMaze-typescript-repair.plans.md +1 -1
- package/plans/generate-docs-solid-split.plans.md +87 -0
- package/plans/methods-docs.plans.md +25 -1
- package/plans/methods-solid-split.plans.md +14 -14
- package/plans/neat-docs.plans.md +9 -1
- package/plans/neat-test-surface-repair.plans.md +1 -1
- package/plans/render-docs-html-solid-split.plans.md +68 -0
- package/plans/src-no-explicit-any-cleanup.plans.md +1 -1
- package/plans/utils-docs.plans.md +6 -1
- package/scripts/analyze-trace/analyze-trace.analysis.ts +479 -0
- package/scripts/analyze-trace/analyze-trace.constants.ts +35 -0
- package/scripts/analyze-trace/analyze-trace.io.ts +69 -0
- package/scripts/analyze-trace/analyze-trace.report.ts +100 -0
- package/scripts/analyze-trace/analyze-trace.shared.ts +116 -0
- package/scripts/analyze-trace/analyze-trace.ts +45 -0
- package/scripts/analyze-trace/analyze-trace.types.ts +72 -0
- package/scripts/assets/theme.css +80 -23
- package/scripts/copy-examples.ts +239 -0
- package/scripts/export-onnx.ts +223 -0
- package/scripts/generate-bench-tables.ts +378 -37
- package/scripts/generate-docs/generate-docs.constants.ts +107 -0
- package/scripts/generate-docs/generate-docs.order.ts +355 -0
- package/scripts/generate-docs/generate-docs.state.ts +31 -0
- package/scripts/generate-docs/generate-docs.targets.ts +165 -0
- package/scripts/generate-docs/generate-docs.ts +63 -0
- package/scripts/generate-docs/generate-docs.types.ts +112 -0
- package/scripts/generate-docs/output/generate-docs.output.folder-index.utils.ts +167 -0
- package/scripts/generate-docs/output/generate-docs.output.ordering.utils.ts +353 -0
- package/scripts/generate-docs/output/generate-docs.output.readme.utils.ts +420 -0
- package/scripts/generate-docs/output/generate-docs.output.ts +123 -0
- package/scripts/generate-docs/output/generate-docs.output.warnings.utils.ts +219 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.collection.utils.ts +365 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.jsdoc.utils.ts +373 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.normalize.utils.ts +155 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.render.utils.ts +149 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.signature.utils.ts +289 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.ts +11 -0
- package/scripts/mermaid-cli.mjs +102 -22
- package/scripts/mermaid-cli.ts +736 -0
- package/scripts/render-docs-html/render-docs-html.assets.ts +54 -0
- package/scripts/render-docs-html/render-docs-html.mermaid.ts +245 -0
- package/scripts/{render-docs-html.sidebar.ts → render-docs-html/render-docs-html.navigation.ts} +141 -144
- package/scripts/render-docs-html/render-docs-html.pages.ts +333 -0
- package/scripts/render-docs-html/render-docs-html.shared.ts +333 -0
- package/scripts/render-docs-html/render-docs-html.types.ts +42 -0
- package/scripts/render-docs-html.ts +23 -587
- package/scripts/run-docs.ts +238 -0
- package/scripts/write-dist-docs-pkg.ts +40 -0
- package/src/README.md +75 -75
- package/src/architecture/connection/README.md +5 -5
- package/src/architecture/layer/README.md +508 -508
- package/src/architecture/network/README.md +1458 -1458
- package/src/architecture/network/activate/README.md +694 -694
- package/src/architecture/network/bootstrap/README.md +77 -77
- package/src/architecture/network/connect/README.md +74 -74
- package/src/architecture/network/deterministic/README.md +135 -135
- package/src/architecture/network/evolve/README.md +364 -364
- package/src/architecture/network/gating/README.md +130 -130
- package/src/architecture/network/genetic/README.md +399 -399
- package/src/architecture/network/mutate/README.md +897 -897
- package/src/architecture/network/onnx/README.md +720 -720
- package/src/architecture/network/onnx/export/README.md +728 -728
- package/src/architecture/network/onnx/export/layers/README.md +450 -450
- package/src/architecture/network/onnx/import/README.md +618 -618
- package/src/architecture/network/onnx/schema/README.md +32 -32
- package/src/architecture/network/prune/README.md +245 -245
- package/src/architecture/network/remove/README.md +135 -135
- package/src/architecture/network/runtime/README.md +106 -106
- package/src/architecture/network/serialize/README.md +542 -542
- package/src/architecture/network/slab/README.md +608 -608
- package/src/architecture/network/standalone/README.md +212 -212
- package/src/architecture/network/stats/README.md +84 -84
- package/src/architecture/network/topology/README.md +465 -465
- package/src/architecture/network/training/README.md +200 -200
- package/src/architecture/node/README.md +5 -5
- package/src/architecture/nodePool/README.md +14 -14
- package/src/methods/README.md +99 -99
- package/src/methods/activation/README.md +189 -189
- package/src/methods/cost/README.md +131 -131
- package/src/methods/rate/README.md +86 -86
- package/src/multithreading/README.md +77 -77
- package/src/multithreading/workers/browser/README.md +8 -8
- package/src/multithreading/workers/node/README.md +8 -8
- package/src/neat/README.md +148 -148
- package/src/neat/adaptive/README.md +120 -120
- package/src/neat/adaptive/acceptance/README.md +40 -40
- package/src/neat/adaptive/complexity/README.md +137 -137
- package/src/neat/adaptive/core/README.md +197 -197
- package/src/neat/adaptive/lineage/README.md +90 -90
- package/src/neat/adaptive/mutation/README.md +284 -284
- package/src/neat/compat/README.md +43 -43
- package/src/neat/compat/core/README.md +90 -90
- package/src/neat/diversity/README.md +35 -35
- package/src/neat/diversity/core/README.md +88 -88
- package/src/neat/evaluate/README.md +85 -85
- package/src/neat/evaluate/auto-distance/README.md +75 -75
- package/src/neat/evaluate/entropy-compat/README.md +37 -37
- package/src/neat/evaluate/entropy-sharing/README.md +43 -43
- package/src/neat/evaluate/fitness/README.md +23 -23
- package/src/neat/evaluate/novelty/README.md +120 -120
- package/src/neat/evaluate/objectives/README.md +17 -17
- package/src/neat/evaluate/shared/README.md +94 -94
- package/src/neat/evolve/README.md +96 -96
- package/src/neat/evolve/adaptive/README.md +60 -60
- package/src/neat/evolve/objectives/README.md +63 -63
- package/src/neat/evolve/offspring/README.md +56 -56
- package/src/neat/evolve/population/README.md +171 -171
- package/src/neat/evolve/runtime/README.md +79 -79
- package/src/neat/evolve/speciation/README.md +74 -74
- package/src/neat/evolve/warnings/README.md +10 -10
- package/src/neat/export/README.md +114 -114
- package/src/neat/helpers/README.md +50 -50
- package/src/neat/init/README.md +9 -9
- package/src/neat/lineage/core/README.md +101 -101
- package/src/neat/multiobjective/category/README.md +74 -74
- package/src/neat/multiobjective/crowding/README.md +272 -272
- package/src/neat/multiobjective/dominance/README.md +171 -171
- package/src/neat/multiobjective/fronts/README.md +68 -68
- package/src/neat/multiobjective/metrics/README.md +43 -43
- package/src/neat/multiobjective/objectives/README.md +31 -31
- package/src/neat/multiobjective/shared/README.md +27 -27
- package/src/neat/mutation/README.md +97 -97
- package/src/neat/mutation/add-conn/README.md +115 -115
- package/src/neat/mutation/add-node/README.md +126 -126
- package/src/neat/mutation/flow/README.md +149 -149
- package/src/neat/mutation/repair/README.md +185 -185
- package/src/neat/mutation/select/README.md +117 -117
- package/src/neat/mutation/shared/README.md +32 -32
- package/src/neat/objectives/README.md +25 -25
- package/src/neat/objectives/core/README.md +67 -67
- package/src/neat/pruning/README.md +40 -40
- package/src/neat/pruning/core/README.md +171 -171
- package/src/neat/pruning/facade/README.md +32 -32
- package/src/neat/rng/README.md +104 -104
- package/src/neat/rng/core/README.md +137 -137
- package/src/neat/rng/facade/README.md +50 -50
- package/src/neat/selection/README.md +111 -111
- package/src/neat/selection/core/README.md +227 -227
- package/src/neat/selection/facade/README.md +61 -61
- package/src/neat/shared/README.md +163 -163
- package/src/neat/speciation/README.md +31 -31
- package/src/neat/speciation/threshold/README.md +35 -35
- package/src/neat/species/README.md +25 -25
- package/src/neat/species/core/README.md +20 -20
- package/src/neat/species/core/shared/README.md +18 -18
- package/src/neat/species/history/context/README.md +22 -22
- package/src/neat/telemetry/accessors/README.md +58 -58
- package/src/neat/telemetry/exports/README.md +233 -233
- package/src/neat/telemetry/facade/README.md +252 -252
- package/src/neat/telemetry/facade/archive/README.md +57 -57
- package/src/neat/telemetry/facade/buffer/README.md +43 -43
- package/src/neat/telemetry/facade/lineage/README.md +12 -12
- package/src/neat/telemetry/facade/objectives/README.md +44 -44
- package/src/neat/telemetry/facade/runtime/README.md +26 -26
- package/src/neat/telemetry/facade/species/README.md +27 -27
- package/src/neat/telemetry/metrics/README.md +696 -696
- package/src/neat/telemetry/recorder/README.md +57 -57
- package/src/neat/telemetry/types/README.md +32 -32
- package/src/neat/topology-intent/README.md +75 -75
- package/src/utils/README.md +193 -193
- package/test/examples/asciiMaze/browser-entry/README.md +92 -92
- package/test/examples/asciiMaze/dashboardManager/README.md +109 -109
- package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +28 -28
- package/test/examples/asciiMaze/evolutionEngine/README.md +1527 -1527
- package/test/examples/asciiMaze/mazeMovement/README.md +105 -105
- package/test/examples/asciiMaze/mazeMovement/finalization/README.md +16 -16
- package/test/examples/asciiMaze/mazeMovement/policy/README.md +57 -57
- package/test/examples/asciiMaze/mazeMovement/runtime/README.md +52 -52
- package/test/examples/asciiMaze/mazeMovement/shaping/README.md +46 -46
- package/test/examples/flappy_bird/browser-entry/README.md +508 -508
- package/test/examples/flappy_bird/browser-entry/host/README.md +101 -101
- package/test/examples/flappy_bird/browser-entry/host/resize/README.md +144 -144
- package/test/examples/flappy_bird/browser-entry/network-view/README.md +194 -194
- package/test/examples/flappy_bird/browser-entry/playback/README.md +278 -278
- package/test/examples/flappy_bird/browser-entry/playback/background/README.md +129 -129
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +502 -502
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +139 -139
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +10 -10
- package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +43 -43
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +30 -30
- package/test/examples/flappy_bird/browser-entry/runtime/README.md +59 -59
- package/test/examples/flappy_bird/browser-entry/visualization/README.md +276 -276
- package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +16 -16
- package/test/examples/flappy_bird/constants/README.md +1070 -1070
- package/test/examples/flappy_bird/environment/README.md +22 -22
- package/test/examples/flappy_bird/evaluation/README.md +32 -32
- package/test/examples/flappy_bird/evaluation/rollout/README.md +141 -141
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +425 -425
- package/test/examples/flappy_bird/simulation-shared/README.md +170 -170
- package/test/examples/flappy_bird/simulation-shared/observation/README.md +109 -109
- package/test/examples/flappy_bird/trainer/README.md +325 -325
- package/test/examples/flappy_bird/trainer/evaluation/README.md +74 -74
- package/scripts/analyze-trace.ts +0 -590
- package/scripts/copy-examples.mjs +0 -114
- package/scripts/export-onnx.mjs +0 -86
- package/scripts/generate-bench-tables.mjs +0 -182
- package/scripts/generate-docs.ts +0 -2900
- package/scripts/write-dist-docs-pkg.mjs +0 -16
|
@@ -78,13 +78,23 @@ flowchart TB
|
|
|
78
78
|
ScoreEntry["ScoredGenomeEntry\nranking helper"] --> Network
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
###
|
|
81
|
+
### FlappyGenerationEvaluationPlan
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
Generation-level rollout plans for staged evaluation.
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
Each generation resolves one plan that answers three questions: how strong is
|
|
86
|
+
the current mutation schedule, which shared seeds belong to each stage, and
|
|
87
|
+
what rollout budget each stage is allowed to spend. This is the contract that
|
|
88
|
+
makes quick screening, full passes, and reevaluation feel like one coherent
|
|
89
|
+
policy instead of three unrelated helper calls.
|
|
90
|
+
|
|
91
|
+
### FlappyGenerationReport
|
|
92
|
+
|
|
93
|
+
Compact generation report used for training logs.
|
|
94
|
+
|
|
95
|
+
The report is shaped for longitudinal monitoring rather than raw storage. It
|
|
96
|
+
collects the distribution and best-run details needed to judge whether a
|
|
97
|
+
generation improved robustly instead of producing one lucky outlier.
|
|
88
98
|
|
|
89
99
|
### FlappyTrainerNeatController
|
|
90
100
|
|
|
@@ -95,13 +105,13 @@ documents only the methods and mutable options it actually depends on, which
|
|
|
95
105
|
makes the orchestration code read more like policy and less like framework
|
|
96
106
|
plumbing.
|
|
97
107
|
|
|
98
|
-
###
|
|
108
|
+
### FlappyTrainerNetwork
|
|
99
109
|
|
|
100
|
-
|
|
110
|
+
Network shape expected by the Flappy trainer.
|
|
101
111
|
|
|
102
|
-
The
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
The trainer only needs the evaluation-facing subset of a full network plus an
|
|
113
|
+
optional score field used by staged ranking helpers. That narrow shape keeps
|
|
114
|
+
the trainer decoupled from most of the broader network implementation.
|
|
105
115
|
|
|
106
116
|
### FlappyTrainerRuntimeState
|
|
107
117
|
|
|
@@ -119,16 +129,6 @@ These values define the static training shape before runtime state and staged
|
|
|
119
129
|
evaluation are attached. Once created, the rest of the trainer can treat this
|
|
120
130
|
as a stable configuration shelf rather than scattered ad hoc constants.
|
|
121
131
|
|
|
122
|
-
### FlappyGenerationEvaluationPlan
|
|
123
|
-
|
|
124
|
-
Generation-level rollout plans for staged evaluation.
|
|
125
|
-
|
|
126
|
-
Each generation resolves one plan that answers three questions: how strong is
|
|
127
|
-
the current mutation schedule, which shared seeds belong to each stage, and
|
|
128
|
-
what rollout budget each stage is allowed to spend. This is the contract that
|
|
129
|
-
makes quick screening, full passes, and reevaluation feel like one coherent
|
|
130
|
-
policy instead of three unrelated helper calls.
|
|
131
|
-
|
|
132
132
|
### ScoredGenomeEntry
|
|
133
133
|
|
|
134
134
|
Score carrier used for deterministic ordering helpers.
|
|
@@ -139,6 +139,39 @@ leak across multiple helpers.
|
|
|
139
139
|
|
|
140
140
|
## trainer/trainer.ts
|
|
141
141
|
|
|
142
|
+
### handleTrainerMainError
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
handleTrainerMainError(
|
|
146
|
+
error: unknown,
|
|
147
|
+
): void
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Handles fatal `main` rejection path.
|
|
151
|
+
|
|
152
|
+
The trainer keeps this boundary small so unexpected failures are formatted in
|
|
153
|
+
one consistent place before reaching the CLI. That keeps shutdown behavior
|
|
154
|
+
and terminal messaging consistent whether the failure came from setup,
|
|
155
|
+
evaluation, or the loop itself.
|
|
156
|
+
|
|
157
|
+
Parameters:
|
|
158
|
+
- `error` - - Unknown rejection reason from trainer execution.
|
|
159
|
+
|
|
160
|
+
Returns: Nothing.
|
|
161
|
+
|
|
162
|
+
### isDirectTrainerExecution
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
isDirectTrainerExecution(): boolean
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Resolves whether this module is the direct Node entrypoint.
|
|
169
|
+
|
|
170
|
+
This lets the file behave as both a reusable module and a runnable script
|
|
171
|
+
without duplicating the startup boundary in a second wrapper file.
|
|
172
|
+
|
|
173
|
+
Returns: `true` when Node launched this file directly.
|
|
174
|
+
|
|
142
175
|
### runTrainer
|
|
143
176
|
|
|
144
177
|
```ts
|
|
@@ -176,39 +209,6 @@ Example:
|
|
|
176
209
|
await runTrainer();
|
|
177
210
|
```
|
|
178
211
|
|
|
179
|
-
### handleTrainerMainError
|
|
180
|
-
|
|
181
|
-
```ts
|
|
182
|
-
handleTrainerMainError(
|
|
183
|
-
error: unknown,
|
|
184
|
-
): void
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
Handles fatal `main` rejection path.
|
|
188
|
-
|
|
189
|
-
The trainer keeps this boundary small so unexpected failures are formatted in
|
|
190
|
-
one consistent place before reaching the CLI. That keeps shutdown behavior
|
|
191
|
-
and terminal messaging consistent whether the failure came from setup,
|
|
192
|
-
evaluation, or the loop itself.
|
|
193
|
-
|
|
194
|
-
Parameters:
|
|
195
|
-
- `error` - - Unknown rejection reason from trainer execution.
|
|
196
|
-
|
|
197
|
-
Returns: Nothing.
|
|
198
|
-
|
|
199
|
-
### isDirectTrainerExecution
|
|
200
|
-
|
|
201
|
-
```ts
|
|
202
|
-
isDirectTrainerExecution(): boolean
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
Resolves whether this module is the direct Node entrypoint.
|
|
206
|
-
|
|
207
|
-
This lets the file behave as both a reusable module and a runnable script
|
|
208
|
-
without duplicating the startup boundary in a second wrapper file.
|
|
209
|
-
|
|
210
|
-
Returns: `true` when Node launched this file directly.
|
|
211
|
-
|
|
212
212
|
## trainer/trainer.errors.ts
|
|
213
213
|
|
|
214
214
|
Small CLI-facing error-rendering boundary for the trainer.
|
|
@@ -218,6 +218,10 @@ shutdown paths from inventing slightly different terminal messages. That is a
|
|
|
218
218
|
small detail, but it makes long-running scripts and quick debugging sessions
|
|
219
219
|
easier to scan.
|
|
220
220
|
|
|
221
|
+
### FLAPPY_TRAINER_UNEXPECTED_ERROR_PREFIX
|
|
222
|
+
|
|
223
|
+
Prefix used when rendering unexpected trainer failures to stderr.
|
|
224
|
+
|
|
221
225
|
### formatTrainerErrorMessage
|
|
222
226
|
|
|
223
227
|
```ts
|
|
@@ -237,10 +241,6 @@ Parameters:
|
|
|
237
241
|
|
|
238
242
|
Returns: Formatted error string for CLI logging.
|
|
239
243
|
|
|
240
|
-
### FLAPPY_TRAINER_UNEXPECTED_ERROR_PREFIX
|
|
241
|
-
|
|
242
|
-
Prefix used when rendering unexpected trainer failures to stderr.
|
|
243
|
-
|
|
244
244
|
## trainer/trainer.constants.ts
|
|
245
245
|
|
|
246
246
|
Named knobs for trainer cadence, fairness, fallback behavior, and terminal
|
|
@@ -322,13 +322,6 @@ Reporting and terminal output:
|
|
|
322
322
|
| `FLAPPY_TRAINER_LOG_PARTS_DELIMITER` | Keeps compact generation logs consistently tokenized. |
|
|
323
323
|
| `FLAPPY_TRAINER_STOPPED_MESSAGE` | Gives graceful shutdown a stable terminal message. |
|
|
324
324
|
|
|
325
|
-
### FLAPPY_TRAINER_DEFAULT_POPULATION_SIZE
|
|
326
|
-
|
|
327
|
-
Default population size used by the Flappy trainer NEAT run.
|
|
328
|
-
|
|
329
|
-
The demo keeps this large enough for staged selection to matter while still
|
|
330
|
-
remaining practical for local experimentation.
|
|
331
|
-
|
|
332
325
|
### FLAPPY_TRAINER_DEFAULT_ELITISM_COUNT
|
|
333
326
|
|
|
334
327
|
Number of elite genomes preserved unchanged each generation.
|
|
@@ -336,6 +329,13 @@ Number of elite genomes preserved unchanged each generation.
|
|
|
336
329
|
Preserving a small elite keeps the trainer from discarding clearly strong
|
|
337
330
|
genomes while the rest of the population continues exploring.
|
|
338
331
|
|
|
332
|
+
### FLAPPY_TRAINER_DEFAULT_POPULATION_SIZE
|
|
333
|
+
|
|
334
|
+
Default population size used by the Flappy trainer NEAT run.
|
|
335
|
+
|
|
336
|
+
The demo keeps this large enough for staged selection to matter while still
|
|
337
|
+
remaining practical for local experimentation.
|
|
338
|
+
|
|
339
339
|
### FLAPPY_TRAINER_DEFAULT_RNG_SEED
|
|
340
340
|
|
|
341
341
|
Deterministic trainer RNG seed used for reproducible training runs.
|
|
@@ -343,215 +343,215 @@ Deterministic trainer RNG seed used for reproducible training runs.
|
|
|
343
343
|
Reusing the shared Flappy example seed makes trainer behavior easier to
|
|
344
344
|
compare across doc examples, tests, and manual tuning sessions.
|
|
345
345
|
|
|
346
|
-
###
|
|
346
|
+
### FLAPPY_TRAINER_DUMMY_FLAP_OUTPUT
|
|
347
347
|
|
|
348
|
-
|
|
348
|
+
Dummy output channel value for the "flap" action score.
|
|
349
349
|
|
|
350
|
-
|
|
351
|
-
|
|
350
|
+
Keeping the flap score lower than the no-flap score produces a predictable
|
|
351
|
+
never-flap dummy network for defensive report code paths.
|
|
352
352
|
|
|
353
|
-
###
|
|
353
|
+
### FLAPPY_TRAINER_DUMMY_NETWORK_ID
|
|
354
354
|
|
|
355
|
-
|
|
355
|
+
ID used by dummy fallback network for defensive reporting paths.
|
|
356
356
|
|
|
357
|
-
|
|
358
|
-
|
|
357
|
+
The report helpers occasionally need a safe stand-in network so logging can
|
|
358
|
+
stay total even when no real population data is available.
|
|
359
359
|
|
|
360
|
-
###
|
|
360
|
+
### FLAPPY_TRAINER_DUMMY_NO_FLAP_OUTPUT
|
|
361
361
|
|
|
362
|
-
|
|
362
|
+
Dummy output channel value for the "no flap" action score.
|
|
363
363
|
|
|
364
|
-
|
|
365
|
-
|
|
364
|
+
The dummy network intentionally prefers the passive action so fallback report
|
|
365
|
+
generation remains deterministic and simple.
|
|
366
366
|
|
|
367
|
-
###
|
|
367
|
+
### FLAPPY_TRAINER_FRAME_PRIMARY_BASE_SCORE
|
|
368
368
|
|
|
369
|
-
|
|
369
|
+
Base offset awarded to genomes that satisfy the mean-pipe progress filter.
|
|
370
370
|
|
|
371
|
-
The
|
|
372
|
-
|
|
371
|
+
The large offset makes it obvious that surviving the gate is more important
|
|
372
|
+
than tiny differences in the secondary frame-oriented terms.
|
|
373
373
|
|
|
374
|
-
###
|
|
374
|
+
### FLAPPY_TRAINER_FRAME_PRIMARY_PIPE_WEIGHT
|
|
375
375
|
|
|
376
|
-
|
|
376
|
+
Pipe-progress contribution weight for frame-primary scoring.
|
|
377
377
|
|
|
378
|
-
|
|
379
|
-
|
|
378
|
+
This keeps pipe progress visible even inside the gated scoring branch so the
|
|
379
|
+
ranking still prefers genuinely advancing policies.
|
|
380
380
|
|
|
381
|
-
###
|
|
381
|
+
### FLAPPY_TRAINER_FRAME_PRIMARY_SURVIVAL_WEIGHT
|
|
382
382
|
|
|
383
|
-
|
|
383
|
+
Survival contribution weight for frame-primary scoring.
|
|
384
384
|
|
|
385
|
-
|
|
386
|
-
|
|
385
|
+
Once a genome passes the pipe-progress gate, extra survival time still matters
|
|
386
|
+
because it often signals more stable control.
|
|
387
387
|
|
|
388
|
-
###
|
|
388
|
+
### FLAPPY_TRAINER_FRAME_STABILITY_STDDEV_WEIGHT
|
|
389
389
|
|
|
390
|
-
|
|
390
|
+
Penalty multiplier applied to fitness standard deviation in frame-primary scoring.
|
|
391
391
|
|
|
392
|
-
|
|
393
|
-
|
|
392
|
+
Higher instability lowers the provisional score so a lucky but erratic genome
|
|
393
|
+
is less likely to outrank a steadier competitor.
|
|
394
394
|
|
|
395
|
-
###
|
|
395
|
+
### FLAPPY_TRAINER_FULL_PASS_ELITISM_MULTIPLIER
|
|
396
396
|
|
|
397
|
-
|
|
397
|
+
Multiplier over elitism used to size full-pass candidate pool.
|
|
398
398
|
|
|
399
|
-
This
|
|
400
|
-
|
|
399
|
+
This ties the full-pass budget to a familiar population concept so the deeper
|
|
400
|
+
stage scales alongside the preserved elite.
|
|
401
401
|
|
|
402
|
-
###
|
|
402
|
+
### FLAPPY_TRAINER_FULL_PASS_POPULATION_FRACTION
|
|
403
403
|
|
|
404
|
-
|
|
404
|
+
Population fraction used to size full-pass candidate pool.
|
|
405
405
|
|
|
406
|
-
|
|
407
|
-
|
|
406
|
+
The full stage uses the larger of this fraction and the elitism-based floor so
|
|
407
|
+
promising mid-pack genomes are not excluded too aggressively.
|
|
408
408
|
|
|
409
|
-
###
|
|
409
|
+
### FLAPPY_TRAINER_FULL_ROLLOUT_EARLY_TERMINATION_CONSECUTIVE_FRAMES
|
|
410
410
|
|
|
411
|
-
|
|
411
|
+
Consecutive unrecoverable frames needed to stop full rollout early.
|
|
412
412
|
|
|
413
|
-
This
|
|
414
|
-
|
|
413
|
+
This longer streak makes the full stage less trigger-happy than the quick
|
|
414
|
+
screen while still avoiding wasted rollout budget.
|
|
415
415
|
|
|
416
|
-
###
|
|
416
|
+
### FLAPPY_TRAINER_FULL_ROLLOUT_EARLY_TERMINATION_GRACE_FRAMES
|
|
417
417
|
|
|
418
|
-
|
|
418
|
+
Early-termination grace frames used during full rollout stage.
|
|
419
419
|
|
|
420
|
-
|
|
421
|
-
|
|
420
|
+
The deeper stage allows more time before judging a trajectory unrecoverable
|
|
421
|
+
because the trainer is now evaluating stronger candidates more carefully.
|
|
422
422
|
|
|
423
|
-
###
|
|
423
|
+
### FLAPPY_TRAINER_FULL_ROLLOUT_PIPE_PROGRESS_TARGET
|
|
424
424
|
|
|
425
|
-
|
|
425
|
+
Pipe-progress target used to normalize full and reevaluation rollout fitness.
|
|
426
426
|
|
|
427
|
-
The
|
|
428
|
-
|
|
427
|
+
The deeper stages share a tougher target because they are used for robust
|
|
428
|
+
ranking rather than first-pass elimination.
|
|
429
429
|
|
|
430
|
-
###
|
|
430
|
+
### FLAPPY_TRAINER_LOG_PARTS_DELIMITER
|
|
431
431
|
|
|
432
|
-
|
|
432
|
+
Delimiter used when composing compact generation log lines.
|
|
433
433
|
|
|
434
|
-
|
|
435
|
-
|
|
434
|
+
A single-space delimiter keeps the log dense, stable, and easy to parse by eye
|
|
435
|
+
during long-running terminal sessions.
|
|
436
436
|
|
|
437
|
-
###
|
|
437
|
+
### FLAPPY_TRAINER_MUTATION_AMOUNT_END
|
|
438
438
|
|
|
439
|
-
|
|
439
|
+
Final mutation amount reached after annealing window completes.
|
|
440
440
|
|
|
441
|
-
|
|
442
|
-
|
|
441
|
+
Cooling the mutation amount along with the rate reduces late-generation noise
|
|
442
|
+
without fully freezing structural search.
|
|
443
443
|
|
|
444
|
-
###
|
|
444
|
+
### FLAPPY_TRAINER_MUTATION_AMOUNT_START
|
|
445
445
|
|
|
446
|
-
|
|
446
|
+
Initial mutation amount at generation `0` before annealing.
|
|
447
447
|
|
|
448
|
-
|
|
449
|
-
|
|
448
|
+
This controls how many mutation operations can be applied while the trainer
|
|
449
|
+
is still in its exploratory phase.
|
|
450
450
|
|
|
451
|
-
###
|
|
451
|
+
### FLAPPY_TRAINER_MUTATION_ANNEAL_GENERATIONS
|
|
452
452
|
|
|
453
|
-
|
|
453
|
+
Generation count used to fully anneal mutation schedule from start to end values.
|
|
454
454
|
|
|
455
|
-
|
|
456
|
-
|
|
455
|
+
Within this window the trainer gradually cools from more exploratory updates
|
|
456
|
+
toward smaller, steadier changes.
|
|
457
457
|
|
|
458
|
-
###
|
|
458
|
+
### FLAPPY_TRAINER_MUTATION_RATE_END
|
|
459
459
|
|
|
460
|
-
|
|
460
|
+
Final mutation rate reached after annealing window completes.
|
|
461
461
|
|
|
462
|
-
|
|
463
|
-
|
|
462
|
+
Lower late-stage mutation pressure helps good policies stabilize instead of
|
|
463
|
+
being reshuffled as aggressively as the opening generations.
|
|
464
464
|
|
|
465
|
-
###
|
|
465
|
+
### FLAPPY_TRAINER_MUTATION_RATE_START
|
|
466
466
|
|
|
467
|
-
|
|
467
|
+
Initial mutation rate at generation `0` before annealing.
|
|
468
468
|
|
|
469
|
-
The
|
|
470
|
-
|
|
469
|
+
The starting rate is intentionally aggressive so the early population can
|
|
470
|
+
discover useful topologies quickly.
|
|
471
471
|
|
|
472
|
-
###
|
|
472
|
+
### FLAPPY_TRAINER_NEAT_INITIAL_MUTATION_AMOUNT
|
|
473
473
|
|
|
474
|
-
|
|
474
|
+
Initial NEAT mutation amount before generation schedule annealing is applied.
|
|
475
475
|
|
|
476
|
-
|
|
477
|
-
|
|
476
|
+
Matching the controller bootstrap to the trainer policy avoids a confusing
|
|
477
|
+
mismatch between generation `0` and later loop behavior.
|
|
478
478
|
|
|
479
|
-
###
|
|
479
|
+
### FLAPPY_TRAINER_NEAT_INITIAL_MUTATION_RATE
|
|
480
480
|
|
|
481
|
-
|
|
481
|
+
Initial NEAT mutation rate before generation schedule annealing is applied.
|
|
482
482
|
|
|
483
|
-
This
|
|
484
|
-
|
|
483
|
+
This seeds the controller with a sensible baseline before the per-generation
|
|
484
|
+
planner starts taking over.
|
|
485
485
|
|
|
486
|
-
###
|
|
486
|
+
### FLAPPY_TRAINER_PIPE_FALLBACK_PIPE_WEIGHT
|
|
487
487
|
|
|
488
|
-
|
|
488
|
+
Pipe-progress contribution weight for fallback scoring path.
|
|
489
489
|
|
|
490
|
-
The
|
|
491
|
-
|
|
490
|
+
The fallback path leans heavily on pipe progress because it is the clearest
|
|
491
|
+
robust signal available before the primary gate is satisfied.
|
|
492
492
|
|
|
493
|
-
###
|
|
493
|
+
### FLAPPY_TRAINER_PIPE_FILTER_TOLERANCE
|
|
494
494
|
|
|
495
|
-
|
|
495
|
+
Allowed mean-pipes delta from the current best before frame-primary scoring applies.
|
|
496
496
|
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
This acts like a gating tolerance: only genomes close enough in pipe progress
|
|
498
|
+
get the more generous frame-primary score treatment.
|
|
499
499
|
|
|
500
|
-
###
|
|
500
|
+
### FLAPPY_TRAINER_QUICK_ROLLOUT_EARLY_TERMINATION_CONSECUTIVE_FRAMES
|
|
501
501
|
|
|
502
|
-
|
|
502
|
+
Consecutive unrecoverable frames needed to stop quick screening rollout early.
|
|
503
503
|
|
|
504
|
-
|
|
505
|
-
|
|
504
|
+
Requiring a streak prevents one noisy frame from ending the screen too early
|
|
505
|
+
while still saving time on clearly doomed trajectories.
|
|
506
506
|
|
|
507
|
-
###
|
|
507
|
+
### FLAPPY_TRAINER_QUICK_ROLLOUT_EARLY_TERMINATION_GRACE_FRAMES
|
|
508
508
|
|
|
509
|
-
|
|
509
|
+
Early-termination grace frames used during quick screening rollout stage.
|
|
510
510
|
|
|
511
|
-
|
|
512
|
-
|
|
511
|
+
This short grace period gives a policy a brief chance to stabilize before the
|
|
512
|
+
unrecoverable-flight heuristic is allowed to stop the rollout.
|
|
513
513
|
|
|
514
|
-
###
|
|
514
|
+
### FLAPPY_TRAINER_QUICK_ROLLOUT_MAX_FRAMES
|
|
515
515
|
|
|
516
|
-
|
|
516
|
+
Frame cap used during quick screening rollout stage.
|
|
517
517
|
|
|
518
|
-
|
|
519
|
-
|
|
518
|
+
The quick stage is supposed to eliminate obviously weak genomes cheaply, so
|
|
519
|
+
its horizon is intentionally shorter than the full evaluation horizon.
|
|
520
520
|
|
|
521
|
-
###
|
|
521
|
+
### FLAPPY_TRAINER_QUICK_ROLLOUT_PIPE_PROGRESS_TARGET
|
|
522
522
|
|
|
523
|
-
|
|
523
|
+
Pipe-progress target used to normalize quick screening rollout fitness.
|
|
524
524
|
|
|
525
|
-
The
|
|
526
|
-
|
|
525
|
+
The lower quick-stage target reflects the fact that this pass is a screen, not
|
|
526
|
+
the trainer's final statement of policy quality.
|
|
527
527
|
|
|
528
|
-
###
|
|
528
|
+
### FLAPPY_TRAINER_REEVALUATION_MIN_CANDIDATE_COUNT
|
|
529
529
|
|
|
530
|
-
|
|
530
|
+
Minimum candidate count for reevaluation stage, regardless of elitism.
|
|
531
531
|
|
|
532
|
-
|
|
533
|
-
|
|
532
|
+
This prevents small elite settings from starving the anti-luck pass of enough
|
|
533
|
+
genomes to produce a meaningful final comparison.
|
|
534
534
|
|
|
535
|
-
###
|
|
535
|
+
### FLAPPY_TRAINER_SCORE_MEDIAN_PERCENTILE
|
|
536
536
|
|
|
537
|
-
|
|
537
|
+
Percentile used when reporting median population score.
|
|
538
538
|
|
|
539
|
-
|
|
540
|
-
|
|
539
|
+
Keeping the percentile explicit makes the report math self-documenting even
|
|
540
|
+
for readers who skim the log formatter before the statistics helpers.
|
|
541
541
|
|
|
542
|
-
###
|
|
542
|
+
### FLAPPY_TRAINER_SCORE_P90_PERCENTILE
|
|
543
543
|
|
|
544
|
-
|
|
544
|
+
Percentile used when reporting high-end population score (P90).
|
|
545
545
|
|
|
546
|
-
|
|
547
|
-
|
|
546
|
+
The trainer uses `p90` as a quick "is the upper tail getting healthier?"
|
|
547
|
+
signal without over-focusing on only the single best genome.
|
|
548
548
|
|
|
549
|
-
###
|
|
549
|
+
### FLAPPY_TRAINER_STOPPED_MESSAGE
|
|
550
550
|
|
|
551
|
-
|
|
551
|
+
Log message emitted when trainer loop exits cleanly.
|
|
552
552
|
|
|
553
|
-
A
|
|
554
|
-
|
|
553
|
+
A dedicated constant keeps the shutdown path stable for humans and for any
|
|
554
|
+
scripts that watch trainer output.
|
|
555
555
|
|
|
556
556
|
## trainer/trainer.loop.service.ts
|
|
557
557
|
|
|
@@ -572,29 +572,26 @@ flowchart LR
|
|
|
572
572
|
Log --> Resolve
|
|
573
573
|
```
|
|
574
574
|
|
|
575
|
-
###
|
|
575
|
+
### applyMutationSchedule
|
|
576
576
|
|
|
577
577
|
```ts
|
|
578
|
-
|
|
578
|
+
applyMutationSchedule(
|
|
579
579
|
neatController: FlappyTrainerNeatController,
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
): Promise<void>
|
|
580
|
+
mutationSchedule: FlappyMutationSchedule,
|
|
581
|
+
): void
|
|
583
582
|
```
|
|
584
583
|
|
|
585
|
-
|
|
584
|
+
Applies mutation schedule values to the NEAT controller options.
|
|
586
585
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
emit a compact summary.
|
|
586
|
+
The schedule is resolved outside this helper so the loop can read as a clean
|
|
587
|
+
"resolve -> apply -> evolve -> report" flow. That separation also makes it
|
|
588
|
+
easier to inspect the active schedule in logs or tests.
|
|
591
589
|
|
|
592
590
|
Parameters:
|
|
593
591
|
- `neatController` - - Trainer NEAT controller.
|
|
594
|
-
- `
|
|
595
|
-
- `logGenerationSummary` - - Callback that emits compact generation logs.
|
|
592
|
+
- `mutationSchedule` - - Mutation schedule for current generation.
|
|
596
593
|
|
|
597
|
-
Returns:
|
|
594
|
+
Returns: Nothing.
|
|
598
595
|
|
|
599
596
|
### LogGenerationSummaryCallback
|
|
600
597
|
|
|
@@ -614,26 +611,29 @@ The loop owns evolution cadence, while the callback owns presentation.
|
|
|
614
611
|
Keeping those concerns separate makes it easy to reuse the loop with richer
|
|
615
612
|
reporting later.
|
|
616
613
|
|
|
617
|
-
###
|
|
614
|
+
### runTrainerEvolutionLoop
|
|
618
615
|
|
|
619
616
|
```ts
|
|
620
|
-
|
|
617
|
+
runTrainerEvolutionLoop(
|
|
621
618
|
neatController: FlappyTrainerNeatController,
|
|
622
|
-
|
|
623
|
-
|
|
619
|
+
trainerRuntimeState: FlappyTrainerRuntimeState,
|
|
620
|
+
logGenerationSummary: LogGenerationSummaryCallback,
|
|
621
|
+
): Promise<void>
|
|
624
622
|
```
|
|
625
623
|
|
|
626
|
-
|
|
624
|
+
Runs the outer evolution loop until runtime stop is requested.
|
|
627
625
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
626
|
+
Educational note:
|
|
627
|
+
This is the trainer's main heartbeat: resolve the current mutation schedule,
|
|
628
|
+
evolve one generation, run a representative fallback rollout for logging, and
|
|
629
|
+
emit a compact summary.
|
|
631
630
|
|
|
632
631
|
Parameters:
|
|
633
632
|
- `neatController` - - Trainer NEAT controller.
|
|
634
|
-
- `
|
|
633
|
+
- `trainerRuntimeState` - - Mutable trainer runtime state.
|
|
634
|
+
- `logGenerationSummary` - - Callback that emits compact generation logs.
|
|
635
635
|
|
|
636
|
-
Returns:
|
|
636
|
+
Returns: Promise resolved when the trainer has been stopped.
|
|
637
637
|
|
|
638
638
|
## trainer/trainer.setup.service.ts
|
|
639
639
|
|
|
@@ -644,20 +644,32 @@ controller construction can be read, tested, and tuned without also reading
|
|
|
644
644
|
the outer loop. This boundary answers a simple question: what does the demo
|
|
645
645
|
need before the first generation can run?
|
|
646
646
|
|
|
647
|
-
###
|
|
647
|
+
### createNeatController
|
|
648
648
|
|
|
649
649
|
```ts
|
|
650
|
-
|
|
650
|
+
createNeatController(
|
|
651
|
+
trainerSetup: FlappyTrainerSetup,
|
|
652
|
+
): FlappyTrainerNeatController
|
|
651
653
|
```
|
|
652
654
|
|
|
653
|
-
|
|
655
|
+
Builds the NEAT controller with baseline options.
|
|
654
656
|
|
|
655
657
|
Educational note:
|
|
656
|
-
The
|
|
657
|
-
|
|
658
|
-
|
|
658
|
+
The trainer enables population-level fitness mode because the quality of a
|
|
659
|
+
Flappy policy depends on fair comparison across shared seed batches, not on a
|
|
660
|
+
one-network-at-a-time scoring callback.
|
|
659
661
|
|
|
660
|
-
|
|
662
|
+
Parameters:
|
|
663
|
+
- `trainerSetup` - - Immutable trainer setup values.
|
|
664
|
+
|
|
665
|
+
Returns: Typed NEAT controller used by the trainer loop.
|
|
666
|
+
|
|
667
|
+
Example:
|
|
668
|
+
|
|
669
|
+
```ts
|
|
670
|
+
const trainerSetup = createTrainerSetup();
|
|
671
|
+
const neatController = createNeatController(trainerSetup);
|
|
672
|
+
```
|
|
661
673
|
|
|
662
674
|
### createTrainerRuntimeState
|
|
663
675
|
|
|
@@ -672,32 +684,20 @@ latest report so the outer loop can remain easy to reason about.
|
|
|
672
684
|
|
|
673
685
|
Returns: Fresh runtime state used by loop orchestration.
|
|
674
686
|
|
|
675
|
-
###
|
|
687
|
+
### createTrainerSetup
|
|
676
688
|
|
|
677
689
|
```ts
|
|
678
|
-
|
|
679
|
-
trainerSetup: FlappyTrainerSetup,
|
|
680
|
-
): FlappyTrainerNeatController
|
|
690
|
+
createTrainerSetup(): FlappyTrainerSetup
|
|
681
691
|
```
|
|
682
692
|
|
|
683
|
-
|
|
693
|
+
Creates immutable setup values for the trainer.
|
|
684
694
|
|
|
685
695
|
Educational note:
|
|
686
|
-
The
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
Parameters:
|
|
691
|
-
- `trainerSetup` - - Immutable trainer setup values.
|
|
692
|
-
|
|
693
|
-
Returns: Typed NEAT controller used by the trainer loop.
|
|
694
|
-
|
|
695
|
-
Example:
|
|
696
|
+
The setup object freezes the core training shape up front: input width,
|
|
697
|
+
output width, population size, and elitism count. Centralizing those values
|
|
698
|
+
makes the rest of the trainer read as policy rather than configuration noise.
|
|
696
699
|
|
|
697
|
-
|
|
698
|
-
const trainerSetup = createTrainerSetup();
|
|
699
|
-
const neatController = createNeatController(trainerSetup);
|
|
700
|
-
```
|
|
700
|
+
Returns: Default trainer setup values used for NEAT configuration.
|
|
701
701
|
|
|
702
702
|
### resolveNoopFitness
|
|
703
703
|
|
|
@@ -868,38 +868,38 @@ The trainer should stop between generations, not by tearing the process down
|
|
|
868
868
|
in the middle of evaluation. This file converts OS-level stop signals into one
|
|
869
869
|
shared runtime intent flag that the main loop can observe safely.
|
|
870
870
|
|
|
871
|
-
###
|
|
871
|
+
### handleTrainerStopSignal
|
|
872
872
|
|
|
873
873
|
```ts
|
|
874
|
-
|
|
874
|
+
handleTrainerStopSignal(
|
|
875
875
|
trainerRuntimeState: FlappyTrainerRuntimeState,
|
|
876
876
|
): void
|
|
877
877
|
```
|
|
878
878
|
|
|
879
|
-
|
|
879
|
+
Handles one stop signal update.
|
|
880
880
|
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
`Ctrl+C`. This service flips runtime intent instead of abruptly tearing down
|
|
884
|
-
the process mid-generation.
|
|
881
|
+
The handler does the minimum possible work because signal paths should stay
|
|
882
|
+
predictable and side-effect light.
|
|
885
883
|
|
|
886
884
|
Parameters:
|
|
887
885
|
- `trainerRuntimeState` - - Mutable trainer runtime state.
|
|
888
886
|
|
|
889
887
|
Returns: Nothing.
|
|
890
888
|
|
|
891
|
-
###
|
|
889
|
+
### registerTrainerStopSignals
|
|
892
890
|
|
|
893
891
|
```ts
|
|
894
|
-
|
|
892
|
+
registerTrainerStopSignals(
|
|
895
893
|
trainerRuntimeState: FlappyTrainerRuntimeState,
|
|
896
894
|
): void
|
|
897
895
|
```
|
|
898
896
|
|
|
899
|
-
|
|
897
|
+
Registers graceful stop signal handlers.
|
|
900
898
|
|
|
901
|
-
|
|
902
|
-
|
|
899
|
+
Educational note:
|
|
900
|
+
Long-running evolutionary runs should stop cleanly when the user presses
|
|
901
|
+
`Ctrl+C`. This service flips runtime intent instead of abruptly tearing down
|
|
902
|
+
the process mid-generation.
|
|
903
903
|
|
|
904
904
|
Parameters:
|
|
905
905
|
- `trainerRuntimeState` - - Mutable trainer runtime state.
|
|
@@ -1164,43 +1164,43 @@ These utilities keep score extraction and descending-order selection in one
|
|
|
1164
1164
|
place so the staged evaluation services do not each reinvent the same sorting
|
|
1165
1165
|
logic with slightly different fallback rules.
|
|
1166
1166
|
|
|
1167
|
-
###
|
|
1167
|
+
### resolveBestGenomeByScore
|
|
1168
1168
|
|
|
1169
1169
|
```ts
|
|
1170
|
-
|
|
1170
|
+
resolveBestGenomeByScore(
|
|
1171
1171
|
population: readonly FlappyTrainerNetwork[],
|
|
1172
|
-
|
|
1173
|
-
targetCount: number,
|
|
1174
|
-
): FlappyTrainerNetwork[]
|
|
1172
|
+
): FlappyTrainerNetwork | undefined
|
|
1175
1173
|
```
|
|
1176
1174
|
|
|
1177
|
-
|
|
1175
|
+
Resolves the best genome by current score.
|
|
1176
|
+
|
|
1177
|
+
This helper is intentionally tiny, but it gives the rest of the trainer a
|
|
1178
|
+
single vocabulary term for "the current best genome under whatever score shelf
|
|
1179
|
+
is currently populated."
|
|
1178
1180
|
|
|
1179
1181
|
Parameters:
|
|
1180
1182
|
- `population` - - Current trainer population.
|
|
1181
|
-
- `provisionalScoresByGenome` - - Optional map of staged provisional scores.
|
|
1182
|
-
- `targetCount` - - Maximum number of genomes to return.
|
|
1183
1183
|
|
|
1184
|
-
Returns: Highest-scoring
|
|
1184
|
+
Returns: Highest-scoring genome or `undefined` when population is empty.
|
|
1185
1185
|
|
|
1186
|
-
###
|
|
1186
|
+
### selectTopGenomesByScore
|
|
1187
1187
|
|
|
1188
1188
|
```ts
|
|
1189
|
-
|
|
1189
|
+
selectTopGenomesByScore(
|
|
1190
1190
|
population: readonly FlappyTrainerNetwork[],
|
|
1191
|
-
|
|
1191
|
+
provisionalScoresByGenome: ReadonlyMap<FlappyTrainerNetwork, number>,
|
|
1192
|
+
targetCount: number,
|
|
1193
|
+
): FlappyTrainerNetwork[]
|
|
1192
1194
|
```
|
|
1193
1195
|
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
This helper is intentionally tiny, but it gives the rest of the trainer a
|
|
1197
|
-
single vocabulary term for "the current best genome under whatever score shelf
|
|
1198
|
-
is currently populated."
|
|
1196
|
+
Returns top genomes ordered by current provisional score.
|
|
1199
1197
|
|
|
1200
1198
|
Parameters:
|
|
1201
1199
|
- `population` - - Current trainer population.
|
|
1200
|
+
- `provisionalScoresByGenome` - - Optional map of staged provisional scores.
|
|
1201
|
+
- `targetCount` - - Maximum number of genomes to return.
|
|
1202
1202
|
|
|
1203
|
-
Returns: Highest-scoring
|
|
1203
|
+
Returns: Highest-scoring genomes in descending score order.
|
|
1204
1204
|
|
|
1205
1205
|
## trainer/trainer.evaluation-plan.utils.ts
|
|
1206
1206
|
|
|
@@ -1232,50 +1232,46 @@ flowchart TB
|
|
|
1232
1232
|
ReevalOptions --> Plan
|
|
1233
1233
|
```
|
|
1234
1234
|
|
|
1235
|
-
###
|
|
1235
|
+
### buildSharedSeedBatch
|
|
1236
1236
|
|
|
1237
1237
|
```ts
|
|
1238
|
-
|
|
1238
|
+
buildSharedSeedBatch(
|
|
1239
1239
|
generationIndex: number,
|
|
1240
|
-
|
|
1240
|
+
stageSalt: number,
|
|
1241
|
+
seedCount: number,
|
|
1242
|
+
): number[]
|
|
1241
1243
|
```
|
|
1242
1244
|
|
|
1243
|
-
|
|
1245
|
+
Build deterministic shared seeds for one generation stage.
|
|
1244
1246
|
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1247
|
+
Shared seeds are what make same-generation comparisons fair: genomes face the
|
|
1248
|
+
same sampled worlds instead of winning because they happened to get a kinder
|
|
1249
|
+
random rollout.
|
|
1248
1250
|
|
|
1249
1251
|
Parameters:
|
|
1250
1252
|
- `generationIndex` - - Zero-based generation index.
|
|
1253
|
+
- `stageSalt` - - Constant stage-specific salt.
|
|
1254
|
+
- `seedCount` - - Number of seeds to produce.
|
|
1251
1255
|
|
|
1252
|
-
Returns:
|
|
1256
|
+
Returns: Deterministic shared seed list.
|
|
1253
1257
|
|
|
1254
|
-
###
|
|
1258
|
+
### createFullRolloutOptions
|
|
1255
1259
|
|
|
1256
1260
|
```ts
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
):
|
|
1261
|
+
createFullRolloutOptions(
|
|
1262
|
+
difficultyScale: number,
|
|
1263
|
+
): FlappyRolloutOptions
|
|
1260
1264
|
```
|
|
1261
1265
|
|
|
1262
|
-
|
|
1266
|
+
Builds full-stage rollout options.
|
|
1263
1267
|
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
structures rather than constantly replacing them.
|
|
1268
|
+
This stage gives stronger candidates a longer, stricter test so the trainer
|
|
1269
|
+
can refine the leaderboard before committing to expensive reevaluation.
|
|
1267
1270
|
|
|
1268
1271
|
Parameters:
|
|
1269
|
-
- `
|
|
1270
|
-
|
|
1271
|
-
Returns: Mutation rate and mutation amount for this generation.
|
|
1272
|
-
|
|
1273
|
-
### FlappyMutationSchedule
|
|
1274
|
-
|
|
1275
|
-
Mutation schedule used by generation planning and outer loop logging.
|
|
1272
|
+
- `difficultyScale` - - Difficulty scale for this generation.
|
|
1276
1273
|
|
|
1277
|
-
|
|
1278
|
-
cools both the frequency and the size of mutations together.
|
|
1274
|
+
Returns: Full stage rollout options.
|
|
1279
1275
|
|
|
1280
1276
|
### createQuickRolloutOptions
|
|
1281
1277
|
|
|
@@ -1296,41 +1292,50 @@ Parameters:
|
|
|
1296
1292
|
|
|
1297
1293
|
Returns: Quick stage rollout options.
|
|
1298
1294
|
|
|
1299
|
-
###
|
|
1295
|
+
### createReevaluationRolloutOptions
|
|
1300
1296
|
|
|
1301
1297
|
```ts
|
|
1302
|
-
|
|
1298
|
+
createReevaluationRolloutOptions(
|
|
1303
1299
|
difficultyScale: number,
|
|
1304
1300
|
): FlappyRolloutOptions
|
|
1305
1301
|
```
|
|
1306
1302
|
|
|
1307
|
-
Builds
|
|
1303
|
+
Builds high-confidence reevaluation rollout options.
|
|
1308
1304
|
|
|
1309
|
-
|
|
1310
|
-
|
|
1305
|
+
Reevaluation deliberately disables early termination so the strongest
|
|
1306
|
+
candidates are judged on a more faithful, less shortcut-heavy comparison.
|
|
1311
1307
|
|
|
1312
1308
|
Parameters:
|
|
1313
1309
|
- `difficultyScale` - - Difficulty scale for this generation.
|
|
1314
1310
|
|
|
1315
|
-
Returns:
|
|
1311
|
+
Returns: Reevaluation stage rollout options.
|
|
1316
1312
|
|
|
1317
|
-
###
|
|
1313
|
+
### FlappyMutationSchedule
|
|
1314
|
+
|
|
1315
|
+
Mutation schedule used by generation planning and outer loop logging.
|
|
1316
|
+
|
|
1317
|
+
These two numbers are treated as a single policy decision because the trainer
|
|
1318
|
+
cools both the frequency and the size of mutations together.
|
|
1319
|
+
|
|
1320
|
+
### mixSeed
|
|
1318
1321
|
|
|
1319
1322
|
```ts
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
+
mixSeed(
|
|
1324
|
+
generationIndex: number,
|
|
1325
|
+
stageSalt: number,
|
|
1326
|
+
): number
|
|
1323
1327
|
```
|
|
1324
1328
|
|
|
1325
|
-
|
|
1329
|
+
Mixes generation and stage salts into a deterministic uint32 RNG seed.
|
|
1326
1330
|
|
|
1327
|
-
|
|
1328
|
-
|
|
1331
|
+
The small mixing pipeline spreads nearby generation numbers apart so adjacent
|
|
1332
|
+
stages and generations do not accidentally reuse overly correlated seed sets.
|
|
1329
1333
|
|
|
1330
1334
|
Parameters:
|
|
1331
|
-
- `
|
|
1335
|
+
- `generationIndex` - - Current generation index.
|
|
1336
|
+
- `stageSalt` - - Stage-specific salt.
|
|
1332
1337
|
|
|
1333
|
-
Returns:
|
|
1338
|
+
Returns: Mixed uint32 seed.
|
|
1334
1339
|
|
|
1335
1340
|
### resolveCurriculumDifficultyScale
|
|
1336
1341
|
|
|
@@ -1350,45 +1355,40 @@ Parameters:
|
|
|
1350
1355
|
|
|
1351
1356
|
Returns: Difficulty scale in [0, 1].
|
|
1352
1357
|
|
|
1353
|
-
###
|
|
1358
|
+
### resolveGenerationEvaluationPlan
|
|
1354
1359
|
|
|
1355
1360
|
```ts
|
|
1356
|
-
|
|
1361
|
+
resolveGenerationEvaluationPlan(
|
|
1357
1362
|
generationIndex: number,
|
|
1358
|
-
|
|
1359
|
-
seedCount: number,
|
|
1360
|
-
): number[]
|
|
1363
|
+
): FlappyGenerationEvaluationPlan
|
|
1361
1364
|
```
|
|
1362
1365
|
|
|
1363
|
-
|
|
1366
|
+
Resolves all per-generation evaluation controls.
|
|
1364
1367
|
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
+
Think of this as the trainer's "generation contract": the rest of the system
|
|
1369
|
+
can ask for one object and receive a fully prepared set of seeds, rollout
|
|
1370
|
+
options, and annealed mutation values.
|
|
1368
1371
|
|
|
1369
1372
|
Parameters:
|
|
1370
1373
|
- `generationIndex` - - Zero-based generation index.
|
|
1371
|
-
- `stageSalt` - - Constant stage-specific salt.
|
|
1372
|
-
- `seedCount` - - Number of seeds to produce.
|
|
1373
1374
|
|
|
1374
|
-
Returns:
|
|
1375
|
+
Returns: Full staged evaluation plan for the generation.
|
|
1375
1376
|
|
|
1376
|
-
###
|
|
1377
|
+
### resolveMutationSchedule
|
|
1377
1378
|
|
|
1378
1379
|
```ts
|
|
1379
|
-
|
|
1380
|
+
resolveMutationSchedule(
|
|
1380
1381
|
generationIndex: number,
|
|
1381
|
-
|
|
1382
|
-
): number
|
|
1382
|
+
): FlappyMutationSchedule
|
|
1383
1383
|
```
|
|
1384
1384
|
|
|
1385
|
-
|
|
1385
|
+
Resolve a smooth mutation annealing schedule.
|
|
1386
1386
|
|
|
1387
|
-
|
|
1388
|
-
|
|
1387
|
+
Early generations mutate more aggressively so the population can search the
|
|
1388
|
+
space broadly. Later generations cool down so the trainer can refine useful
|
|
1389
|
+
structures rather than constantly replacing them.
|
|
1389
1390
|
|
|
1390
1391
|
Parameters:
|
|
1391
|
-
- `generationIndex` - -
|
|
1392
|
-
- `stageSalt` - - Stage-specific salt.
|
|
1392
|
+
- `generationIndex` - - Zero-based generation index.
|
|
1393
1393
|
|
|
1394
|
-
Returns:
|
|
1394
|
+
Returns: Mutation rate and mutation amount for this generation.
|