@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.
Files changed (210) hide show
  1. package/.github/copilot-instructions.md +11 -0
  2. package/.github/skills/trace-analyzer-extension/SKILL.md +3 -3
  3. package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +1 -1
  4. package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +1 -1
  5. package/.github/skills/trace-audit-reporting/SKILL.md +3 -3
  6. package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +1 -1
  7. package/package.json +19 -13
  8. package/plans/Flappy_Bird_Folder_Documentation_Pass.md +4 -4
  9. package/plans/README.md +24 -0
  10. package/plans/Roadmap.md +62 -40
  11. package/plans/analyze-trace-solid-split.plans.md +66 -0
  12. package/plans/architecture-solid-split.plans.md +9 -15
  13. package/plans/asciiMaze-typescript-repair.plans.md +1 -1
  14. package/plans/generate-docs-solid-split.plans.md +87 -0
  15. package/plans/methods-docs.plans.md +25 -1
  16. package/plans/methods-solid-split.plans.md +14 -14
  17. package/plans/neat-docs.plans.md +9 -1
  18. package/plans/neat-test-surface-repair.plans.md +1 -1
  19. package/plans/render-docs-html-solid-split.plans.md +68 -0
  20. package/plans/src-no-explicit-any-cleanup.plans.md +1 -1
  21. package/plans/utils-docs.plans.md +6 -1
  22. package/scripts/analyze-trace/analyze-trace.analysis.ts +479 -0
  23. package/scripts/analyze-trace/analyze-trace.constants.ts +35 -0
  24. package/scripts/analyze-trace/analyze-trace.io.ts +69 -0
  25. package/scripts/analyze-trace/analyze-trace.report.ts +100 -0
  26. package/scripts/analyze-trace/analyze-trace.shared.ts +116 -0
  27. package/scripts/analyze-trace/analyze-trace.ts +45 -0
  28. package/scripts/analyze-trace/analyze-trace.types.ts +72 -0
  29. package/scripts/assets/theme.css +80 -23
  30. package/scripts/copy-examples.ts +239 -0
  31. package/scripts/export-onnx.ts +223 -0
  32. package/scripts/generate-bench-tables.ts +378 -37
  33. package/scripts/generate-docs/generate-docs.constants.ts +107 -0
  34. package/scripts/generate-docs/generate-docs.order.ts +355 -0
  35. package/scripts/generate-docs/generate-docs.state.ts +31 -0
  36. package/scripts/generate-docs/generate-docs.targets.ts +165 -0
  37. package/scripts/generate-docs/generate-docs.ts +63 -0
  38. package/scripts/generate-docs/generate-docs.types.ts +112 -0
  39. package/scripts/generate-docs/output/generate-docs.output.folder-index.utils.ts +167 -0
  40. package/scripts/generate-docs/output/generate-docs.output.ordering.utils.ts +353 -0
  41. package/scripts/generate-docs/output/generate-docs.output.readme.utils.ts +420 -0
  42. package/scripts/generate-docs/output/generate-docs.output.ts +123 -0
  43. package/scripts/generate-docs/output/generate-docs.output.warnings.utils.ts +219 -0
  44. package/scripts/generate-docs/symbols/generate-docs.symbols.collection.utils.ts +365 -0
  45. package/scripts/generate-docs/symbols/generate-docs.symbols.jsdoc.utils.ts +373 -0
  46. package/scripts/generate-docs/symbols/generate-docs.symbols.normalize.utils.ts +155 -0
  47. package/scripts/generate-docs/symbols/generate-docs.symbols.render.utils.ts +149 -0
  48. package/scripts/generate-docs/symbols/generate-docs.symbols.signature.utils.ts +289 -0
  49. package/scripts/generate-docs/symbols/generate-docs.symbols.ts +11 -0
  50. package/scripts/mermaid-cli.mjs +102 -22
  51. package/scripts/mermaid-cli.ts +736 -0
  52. package/scripts/render-docs-html/render-docs-html.assets.ts +54 -0
  53. package/scripts/render-docs-html/render-docs-html.mermaid.ts +245 -0
  54. package/scripts/{render-docs-html.sidebar.ts → render-docs-html/render-docs-html.navigation.ts} +141 -144
  55. package/scripts/render-docs-html/render-docs-html.pages.ts +333 -0
  56. package/scripts/render-docs-html/render-docs-html.shared.ts +333 -0
  57. package/scripts/render-docs-html/render-docs-html.types.ts +42 -0
  58. package/scripts/render-docs-html.ts +23 -587
  59. package/scripts/run-docs.ts +238 -0
  60. package/scripts/write-dist-docs-pkg.ts +40 -0
  61. package/src/README.md +75 -75
  62. package/src/architecture/connection/README.md +5 -5
  63. package/src/architecture/layer/README.md +508 -508
  64. package/src/architecture/network/README.md +1458 -1458
  65. package/src/architecture/network/activate/README.md +694 -694
  66. package/src/architecture/network/bootstrap/README.md +77 -77
  67. package/src/architecture/network/connect/README.md +74 -74
  68. package/src/architecture/network/deterministic/README.md +135 -135
  69. package/src/architecture/network/evolve/README.md +364 -364
  70. package/src/architecture/network/gating/README.md +130 -130
  71. package/src/architecture/network/genetic/README.md +399 -399
  72. package/src/architecture/network/mutate/README.md +897 -897
  73. package/src/architecture/network/onnx/README.md +720 -720
  74. package/src/architecture/network/onnx/export/README.md +728 -728
  75. package/src/architecture/network/onnx/export/layers/README.md +450 -450
  76. package/src/architecture/network/onnx/import/README.md +618 -618
  77. package/src/architecture/network/onnx/schema/README.md +32 -32
  78. package/src/architecture/network/prune/README.md +245 -245
  79. package/src/architecture/network/remove/README.md +135 -135
  80. package/src/architecture/network/runtime/README.md +106 -106
  81. package/src/architecture/network/serialize/README.md +542 -542
  82. package/src/architecture/network/slab/README.md +608 -608
  83. package/src/architecture/network/standalone/README.md +212 -212
  84. package/src/architecture/network/stats/README.md +84 -84
  85. package/src/architecture/network/topology/README.md +465 -465
  86. package/src/architecture/network/training/README.md +200 -200
  87. package/src/architecture/node/README.md +5 -5
  88. package/src/architecture/nodePool/README.md +14 -14
  89. package/src/methods/README.md +99 -99
  90. package/src/methods/activation/README.md +189 -189
  91. package/src/methods/cost/README.md +131 -131
  92. package/src/methods/rate/README.md +86 -86
  93. package/src/multithreading/README.md +77 -77
  94. package/src/multithreading/workers/browser/README.md +8 -8
  95. package/src/multithreading/workers/node/README.md +8 -8
  96. package/src/neat/README.md +148 -148
  97. package/src/neat/adaptive/README.md +120 -120
  98. package/src/neat/adaptive/acceptance/README.md +40 -40
  99. package/src/neat/adaptive/complexity/README.md +137 -137
  100. package/src/neat/adaptive/core/README.md +197 -197
  101. package/src/neat/adaptive/lineage/README.md +90 -90
  102. package/src/neat/adaptive/mutation/README.md +284 -284
  103. package/src/neat/compat/README.md +43 -43
  104. package/src/neat/compat/core/README.md +90 -90
  105. package/src/neat/diversity/README.md +35 -35
  106. package/src/neat/diversity/core/README.md +88 -88
  107. package/src/neat/evaluate/README.md +85 -85
  108. package/src/neat/evaluate/auto-distance/README.md +75 -75
  109. package/src/neat/evaluate/entropy-compat/README.md +37 -37
  110. package/src/neat/evaluate/entropy-sharing/README.md +43 -43
  111. package/src/neat/evaluate/fitness/README.md +23 -23
  112. package/src/neat/evaluate/novelty/README.md +120 -120
  113. package/src/neat/evaluate/objectives/README.md +17 -17
  114. package/src/neat/evaluate/shared/README.md +94 -94
  115. package/src/neat/evolve/README.md +96 -96
  116. package/src/neat/evolve/adaptive/README.md +60 -60
  117. package/src/neat/evolve/objectives/README.md +63 -63
  118. package/src/neat/evolve/offspring/README.md +56 -56
  119. package/src/neat/evolve/population/README.md +171 -171
  120. package/src/neat/evolve/runtime/README.md +79 -79
  121. package/src/neat/evolve/speciation/README.md +74 -74
  122. package/src/neat/evolve/warnings/README.md +10 -10
  123. package/src/neat/export/README.md +114 -114
  124. package/src/neat/helpers/README.md +50 -50
  125. package/src/neat/init/README.md +9 -9
  126. package/src/neat/lineage/core/README.md +101 -101
  127. package/src/neat/multiobjective/category/README.md +74 -74
  128. package/src/neat/multiobjective/crowding/README.md +272 -272
  129. package/src/neat/multiobjective/dominance/README.md +171 -171
  130. package/src/neat/multiobjective/fronts/README.md +68 -68
  131. package/src/neat/multiobjective/metrics/README.md +43 -43
  132. package/src/neat/multiobjective/objectives/README.md +31 -31
  133. package/src/neat/multiobjective/shared/README.md +27 -27
  134. package/src/neat/mutation/README.md +97 -97
  135. package/src/neat/mutation/add-conn/README.md +115 -115
  136. package/src/neat/mutation/add-node/README.md +126 -126
  137. package/src/neat/mutation/flow/README.md +149 -149
  138. package/src/neat/mutation/repair/README.md +185 -185
  139. package/src/neat/mutation/select/README.md +117 -117
  140. package/src/neat/mutation/shared/README.md +32 -32
  141. package/src/neat/objectives/README.md +25 -25
  142. package/src/neat/objectives/core/README.md +67 -67
  143. package/src/neat/pruning/README.md +40 -40
  144. package/src/neat/pruning/core/README.md +171 -171
  145. package/src/neat/pruning/facade/README.md +32 -32
  146. package/src/neat/rng/README.md +104 -104
  147. package/src/neat/rng/core/README.md +137 -137
  148. package/src/neat/rng/facade/README.md +50 -50
  149. package/src/neat/selection/README.md +111 -111
  150. package/src/neat/selection/core/README.md +227 -227
  151. package/src/neat/selection/facade/README.md +61 -61
  152. package/src/neat/shared/README.md +163 -163
  153. package/src/neat/speciation/README.md +31 -31
  154. package/src/neat/speciation/threshold/README.md +35 -35
  155. package/src/neat/species/README.md +25 -25
  156. package/src/neat/species/core/README.md +20 -20
  157. package/src/neat/species/core/shared/README.md +18 -18
  158. package/src/neat/species/history/context/README.md +22 -22
  159. package/src/neat/telemetry/accessors/README.md +58 -58
  160. package/src/neat/telemetry/exports/README.md +233 -233
  161. package/src/neat/telemetry/facade/README.md +252 -252
  162. package/src/neat/telemetry/facade/archive/README.md +57 -57
  163. package/src/neat/telemetry/facade/buffer/README.md +43 -43
  164. package/src/neat/telemetry/facade/lineage/README.md +12 -12
  165. package/src/neat/telemetry/facade/objectives/README.md +44 -44
  166. package/src/neat/telemetry/facade/runtime/README.md +26 -26
  167. package/src/neat/telemetry/facade/species/README.md +27 -27
  168. package/src/neat/telemetry/metrics/README.md +696 -696
  169. package/src/neat/telemetry/recorder/README.md +57 -57
  170. package/src/neat/telemetry/types/README.md +32 -32
  171. package/src/neat/topology-intent/README.md +75 -75
  172. package/src/utils/README.md +193 -193
  173. package/test/examples/asciiMaze/browser-entry/README.md +92 -92
  174. package/test/examples/asciiMaze/dashboardManager/README.md +109 -109
  175. package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +28 -28
  176. package/test/examples/asciiMaze/evolutionEngine/README.md +1527 -1527
  177. package/test/examples/asciiMaze/mazeMovement/README.md +105 -105
  178. package/test/examples/asciiMaze/mazeMovement/finalization/README.md +16 -16
  179. package/test/examples/asciiMaze/mazeMovement/policy/README.md +57 -57
  180. package/test/examples/asciiMaze/mazeMovement/runtime/README.md +52 -52
  181. package/test/examples/asciiMaze/mazeMovement/shaping/README.md +46 -46
  182. package/test/examples/flappy_bird/browser-entry/README.md +508 -508
  183. package/test/examples/flappy_bird/browser-entry/host/README.md +101 -101
  184. package/test/examples/flappy_bird/browser-entry/host/resize/README.md +144 -144
  185. package/test/examples/flappy_bird/browser-entry/network-view/README.md +194 -194
  186. package/test/examples/flappy_bird/browser-entry/playback/README.md +278 -278
  187. package/test/examples/flappy_bird/browser-entry/playback/background/README.md +129 -129
  188. package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +502 -502
  189. package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +139 -139
  190. package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +10 -10
  191. package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +43 -43
  192. package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +30 -30
  193. package/test/examples/flappy_bird/browser-entry/runtime/README.md +59 -59
  194. package/test/examples/flappy_bird/browser-entry/visualization/README.md +276 -276
  195. package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +16 -16
  196. package/test/examples/flappy_bird/constants/README.md +1070 -1070
  197. package/test/examples/flappy_bird/environment/README.md +22 -22
  198. package/test/examples/flappy_bird/evaluation/README.md +32 -32
  199. package/test/examples/flappy_bird/evaluation/rollout/README.md +141 -141
  200. package/test/examples/flappy_bird/flappy-evolution-worker/README.md +425 -425
  201. package/test/examples/flappy_bird/simulation-shared/README.md +170 -170
  202. package/test/examples/flappy_bird/simulation-shared/observation/README.md +109 -109
  203. package/test/examples/flappy_bird/trainer/README.md +325 -325
  204. package/test/examples/flappy_bird/trainer/evaluation/README.md +74 -74
  205. package/scripts/analyze-trace.ts +0 -590
  206. package/scripts/copy-examples.mjs +0 -114
  207. package/scripts/export-onnx.mjs +0 -86
  208. package/scripts/generate-bench-tables.mjs +0 -182
  209. package/scripts/generate-docs.ts +0 -2900
  210. package/scripts/write-dist-docs-pkg.mjs +0 -16
@@ -37,6 +37,36 @@ flowchart TD
37
37
 
38
38
  ## neat/evolve/speciation/evolve.speciation.utils.ts
39
39
 
40
+ ### applyGlobalStagnationInjectionIfNeeded
41
+
42
+ ```ts
43
+ applyGlobalStagnationInjectionIfNeeded(
44
+ internal: NeatControllerForEvolution,
45
+ helpers: { buildFreshGenomeForStagnation: () => Promise<GenomeWithMetadata>; replaceFraction: number; },
46
+ ): Promise<void>
47
+ ```
48
+
49
+ Apply global stagnation injection if configured.
50
+
51
+ This is the evolve loop's constrained recovery valve for long periods without
52
+ global improvement. Instead of discarding the whole population or rebuilding
53
+ the generation logic from scratch, the helper replaces only the worst-ranked
54
+ fraction beyond elitism with fresh genomes, then resets the stagnation window
55
+ so the controller can test whether the new search seeds reopen progress.
56
+
57
+ The design is intentionally conservative:
58
+
59
+ - elites are preserved,
60
+ - the replacement fraction is bounded by the caller,
61
+ - injected genomes still pass through the normal later evolution pipeline.
62
+
63
+ Parameters:
64
+ - `internal` - - NEAT controller instance.
65
+ - `helpers` - - Helper callbacks for stagnation injection.
66
+ - `helpers` - - Genome builder for injection.
67
+
68
+ Returns: A promise that resolves after bounded replacements are complete.
69
+
40
70
  ### applySpeciationAndSharingIfEnabled
41
71
 
42
72
  ```ts
@@ -90,80 +120,43 @@ Parameters:
90
120
 
91
121
  Returns: A new genome prepared for bounded stagnation rescue.
92
122
 
93
- ### recordSpeciesHistorySnapshot
94
-
95
- ```ts
96
- recordSpeciesHistorySnapshot(
97
- internal: NeatControllerForEvolution,
98
- maxHistory: number,
99
- ): void
100
- ```
101
-
102
- Record a species history snapshot when needed.
103
-
104
- This helper preserves a minimal per-generation history row for downstream
105
- readers that expect species-history evidence even when the heavier extended
106
- history path is disabled. It deliberately records only lightweight summary
107
- fields, keeps one row per generation, and trims to a bounded rolling window
108
- so evolve can maintain export-friendly evidence without turning this bridge
109
- into the full history-enrichment layer.
110
-
111
- Parameters:
112
- - `internal` - - NEAT controller instance.
113
- - `maxHistory` - - Maximum history length.
114
-
115
- Returns: Nothing.
116
-
117
- ### updateSpeciesStagnationIfEnabled
123
+ ### buildSpeciesHistoryStats
118
124
 
119
125
  ```ts
120
- updateSpeciesStagnationIfEnabled(
121
- internal: NeatControllerForEvolution,
122
- ): void
126
+ buildSpeciesHistoryStats(
127
+ speciesList: SpeciesWithMetadata[],
128
+ ): { id: number; size: number; avgSharedFitness?: number | undefined; bestScore?: number | undefined; lastImproved?: number | undefined; }[]
123
129
  ```
124
130
 
125
- Update species stagnation status when speciation enabled.
126
-
127
- The stagnation update remains optional because some evolve configurations use
128
- the broader selection and replacement machinery without long-lived species
129
- maintenance. When speciation is active, this helper advances the species-side
130
- stagnation counters so later allocation and pruning decisions can distinguish
131
- between active lineages and species that have stopped improving.
131
+ Build the minimal species-history row shape used by evolve-side snapshots.
132
132
 
133
133
  Parameters:
134
- - `internal` - - NEAT controller instance.
134
+ - `speciesList` - - Live species registry for the current generation.
135
135
 
136
- Returns: Nothing.
136
+ Returns: Summary rows aligned with the shared species history contract.
137
137
 
138
- ### applyGlobalStagnationInjectionIfNeeded
138
+ ### ensureHiddenNodeVariance
139
139
 
140
140
  ```ts
141
- applyGlobalStagnationInjectionIfNeeded(
141
+ ensureHiddenNodeVariance(
142
142
  internal: NeatControllerForEvolution,
143
- helpers: { buildFreshGenomeForStagnation: () => Promise<GenomeWithMetadata>; replaceFraction: number; },
143
+ genome: GenomeWithMetadata,
144
144
  ): Promise<void>
145
145
  ```
146
146
 
147
- Apply global stagnation injection if configured.
148
-
149
- This is the evolve loop's constrained recovery valve for long periods without
150
- global improvement. Instead of discarding the whole population or rebuilding
151
- the generation logic from scratch, the helper replaces only the worst-ranked
152
- fraction beyond elitism with fresh genomes, then resets the stagnation window
153
- so the controller can test whether the new search seeds reopen progress.
154
-
155
- The design is intentionally conservative:
147
+ Ensure a minimal hidden-node variance in injected genomes.
156
148
 
157
- - elites are preserved,
158
- - the replacement fraction is bounded by the caller,
159
- - injected genomes still pass through the normal later evolution pipeline.
149
+ Fresh stagnation-recovery genomes can otherwise collapse into the smallest
150
+ legal topology and fail to contribute structural novelty. This helper adds
151
+ one conservative hidden-node bridge when the injected genome has no hidden
152
+ layer at all, preserving the idea that rescue should re-open search space
153
+ rather than only reshuffle minimal direct input-output paths.
160
154
 
161
155
  Parameters:
162
156
  - `internal` - - NEAT controller instance.
163
- - `helpers` - - Helper callbacks for stagnation injection.
164
- - `helpers` - - Genome builder for injection.
157
+ - `genome` - - Genome to adjust.
165
158
 
166
- Returns: A promise that resolves after bounded replacements are complete.
159
+ Returns: A promise that resolves after best-effort variance injection.
167
160
 
168
161
  ### ensureSpeciesHistorySnapshot
169
162
 
@@ -188,40 +181,47 @@ Parameters:
188
181
 
189
182
  Returns: Nothing.
190
183
 
191
- ### ensureHiddenNodeVariance
184
+ ### recordSpeciesHistorySnapshot
192
185
 
193
186
  ```ts
194
- ensureHiddenNodeVariance(
187
+ recordSpeciesHistorySnapshot(
195
188
  internal: NeatControllerForEvolution,
196
- genome: GenomeWithMetadata,
197
- ): Promise<void>
189
+ maxHistory: number,
190
+ ): void
198
191
  ```
199
192
 
200
- Ensure a minimal hidden-node variance in injected genomes.
193
+ Record a species history snapshot when needed.
201
194
 
202
- Fresh stagnation-recovery genomes can otherwise collapse into the smallest
203
- legal topology and fail to contribute structural novelty. This helper adds
204
- one conservative hidden-node bridge when the injected genome has no hidden
205
- layer at all, preserving the idea that rescue should re-open search space
206
- rather than only reshuffle minimal direct input-output paths.
195
+ This helper preserves a minimal per-generation history row for downstream
196
+ readers that expect species-history evidence even when the heavier extended
197
+ history path is disabled. It deliberately records only lightweight summary
198
+ fields, keeps one row per generation, and trims to a bounded rolling window
199
+ so evolve can maintain export-friendly evidence without turning this bridge
200
+ into the full history-enrichment layer.
207
201
 
208
202
  Parameters:
209
203
  - `internal` - - NEAT controller instance.
210
- - `genome` - - Genome to adjust.
204
+ - `maxHistory` - - Maximum history length.
211
205
 
212
- Returns: A promise that resolves after best-effort variance injection.
206
+ Returns: Nothing.
213
207
 
214
- ### buildSpeciesHistoryStats
208
+ ### updateSpeciesStagnationIfEnabled
215
209
 
216
210
  ```ts
217
- buildSpeciesHistoryStats(
218
- speciesList: SpeciesWithMetadata[],
219
- ): { id: number; size: number; avgSharedFitness?: number | undefined; bestScore?: number | undefined; lastImproved?: number | undefined; }[]
211
+ updateSpeciesStagnationIfEnabled(
212
+ internal: NeatControllerForEvolution,
213
+ ): void
220
214
  ```
221
215
 
222
- Build the minimal species-history row shape used by evolve-side snapshots.
216
+ Update species stagnation status when speciation enabled.
217
+
218
+ The stagnation update remains optional because some evolve configurations use
219
+ the broader selection and replacement machinery without long-lived species
220
+ maintenance. When speciation is active, this helper advances the species-side
221
+ stagnation counters so later allocation and pruning decisions can distinguish
222
+ between active lineages and species that have stopped improving.
223
223
 
224
224
  Parameters:
225
- - `speciesList` - - Live species registry for the current generation.
225
+ - `internal` - - NEAT controller instance.
226
226
 
227
- Returns: Summary rows aligned with the shared species history contract.
227
+ Returns: Nothing.
@@ -19,6 +19,16 @@ Read this chapter when you want to understand:
19
19
 
20
20
  ## neat/evolve/warnings/evolve.warnings.utils.ts
21
21
 
22
+ ### EVOLVE_NO_BEST_GENOME_WARNING
23
+
24
+ Warning emitted when evolution finishes without a best genome.
25
+
26
+ This message signals that the generation loop completed without producing a
27
+ champion snapshot that the controller considers safe to return. That usually
28
+ points to an upstream evaluation or population-state problem rather than to a
29
+ normal low-fitness generation, so the wording intentionally distinguishes
30
+ "no valid best genome" from merely "no improvement."
31
+
22
32
  ### warnIfNoBestGenome
23
33
 
24
34
  ```ts
@@ -31,13 +41,3 @@ The helper is deliberately conservative: it tries to warn, but it does not
31
41
  let missing or restricted console support destabilize the evolve loop further.
32
42
  That keeps warning emission informative for normal runtimes while preserving a
33
43
  best-effort contract for test harnesses and embedded environments.
34
-
35
- ### EVOLVE_NO_BEST_GENOME_WARNING
36
-
37
- Warning emitted when evolution finishes without a best genome.
38
-
39
- This message signals that the generation loop completed without producing a
40
- champion snapshot that the controller considers safe to return. That usually
41
- points to an upstream evaluation or population-state problem rather than to a
42
- normal low-fitness generation, so the wording intentionally distinguishes
43
- "no valid best genome" from merely "no improvement."
@@ -70,38 +70,6 @@ fs.writeFileSync('population.json', JSON.stringify(popSnapshot, null, 2));
70
70
 
71
71
  Returns: Array of genome JSON objects.
72
72
 
73
- ### importPopulation
74
-
75
- ```ts
76
- importPopulation(
77
- populationJSON: GenomeJSON[],
78
- ): Promise<void>
79
- ```
80
-
81
- Import (replace) the current population from an array of serialized genomes.
82
- This does not touch NEAT meta state (generation, innovations, etc.) - only the
83
- population array and implied `popsize` are updated.
84
- That makes it the right tool when you want to swap candidate solutions into an
85
- existing controller context instead of restoring a full historical checkpoint.
86
-
87
- Example:
88
-
89
- ```ts
90
- const populationData: GenomeJSON[] = JSON.parse(fs.readFileSync('population.json', 'utf8'));
91
- neat.importPopulation(populationData); // population replaced
92
- neat.evolve(); // continue evolving with new starting genomes
93
- ```
94
-
95
- Edge cases handled:
96
- - Empty array => becomes an empty population (popsize=0).
97
- - Malformed entries will throw if `Network.fromJSON` rejects them.
98
-
99
- Parameters:
100
- - `populationJSON` - Array of serialized genome objects.
101
-
102
- Returns: Promise that resolves once all genomes have been rehydrated and the
103
- controller population has been replaced.
104
-
105
73
  ### exportState
106
74
 
107
75
  ```ts
@@ -128,68 +96,6 @@ const neat2 = Neat.importState(raw, fitnessFn); // identical evolutionary contex
128
96
 
129
97
  Returns: A {@link NeatStateJSON} bundle containing meta + population.
130
98
 
131
- ### importStateImpl
132
-
133
- ```ts
134
- importStateImpl(
135
- stateBundle: NeatStateJSON,
136
- fitnessFunction: (network: GenomeWithSerialization) => number | Promise<number>,
137
- ): Promise<NeatControllerForExport>
138
- ```
139
-
140
- Static-style helper that rehydrates a full evolutionary state previously
141
- produced by {@link exportState}. Invoke this with the NEAT class (not an
142
- instance) bound as `this`, e.g. `Neat.importStateImpl(bundle, fitnessFn)`.
143
- It constructs a new NEAT instance using the meta data, then imports the
144
- population (if present).
145
-
146
- This is the most complete restore path in the chapter. If a saved bundle is
147
- valid, the caller gets back a fresh controller that knows both where the run
148
- was in evolutionary time and which genomes were alive at that moment.
149
-
150
- Safety and validation:
151
- - Throws if the bundle is not an object.
152
- - Silently skips population import if `population` is missing or not an array.
153
-
154
- Example:
155
-
156
- ```ts
157
- const bundle: NeatStateJSON = JSON.parse(fs.readFileSync('state.json', 'utf8'));
158
- const neat = Neat.importStateImpl(bundle, fitnessFn);
159
- neat.evolve();
160
- ```
161
-
162
- Parameters:
163
- - `stateBundle` - Full state bundle from {@link exportState} .
164
- - `fitnessFunction` - Fitness evaluation callback used for new instance.
165
-
166
- Returns: Rehydrated NEAT instance ready to continue evolving.
167
-
168
- ### toJSONImpl
169
-
170
- ```ts
171
- toJSONImpl(): NeatMetaJSON
172
- ```
173
-
174
- Serialize NEAT meta (excluding the mutable population) for persistence of
175
- innovation history and experiment configuration. This is sufficient to
176
- recreate a blank NEAT run at the same evolutionary generation with the same
177
- innovation counters, enabling deterministic continuation when combined later
178
- with a saved population.
179
-
180
- Use this path when the controller context matters but the population payload
181
- should be stored, transferred, or versioned separately.
182
-
183
- Example:
184
-
185
- ```ts
186
- const meta = neat.toJSONImpl();
187
- fs.writeFileSync('neat-meta.json', JSON.stringify(meta));
188
- // ... later ...
189
- const metaLoaded = JSON.parse(fs.readFileSync('neat-meta.json', 'utf8')) as NeatMetaJSON;
190
- const neat2 = Neat.fromJSONImpl(metaLoaded, fitnessFn); // empty population
191
- ```
192
-
193
99
  ### fromJSONImpl
194
100
 
195
101
  ```ts
@@ -234,21 +140,81 @@ export helpers preserve whatever `Network#toJSON()` emits, which lets the
234
140
  broader architecture evolve without forcing this chapter to hard-code every
235
141
  possible serialized field.
236
142
 
237
- ### NeatMetaJSON
143
+ ### GenomeWithSerialization
238
144
 
239
- Serialized meta information describing a NEAT run, excluding the concrete
240
- population genomes. This allows you to persist and resume experiment context
241
- without committing to a particular population snapshot.
145
+ Genome with toJSON serialization method.
242
146
 
243
- ### NeatStateJSON
147
+ This is the smallest runtime contract needed by the export helpers when they
148
+ only care about turning one genome into a JSON payload.
244
149
 
245
- Top-level bundle containing both NEAT meta information and the full array of
246
- serialized genomes (population). This is what you get from `exportState()` and
247
- feed into `importStateImpl()` to resume exactly where you left off.
150
+ ### importPopulation
248
151
 
249
- If `NeatMetaJSON` is the controller checkpoint and `GenomeJSON[]` is the pool
250
- of candidate solutions, `NeatStateJSON` is the combined pause-and-resume
251
- artifact that preserves both layers together.
152
+ ```ts
153
+ importPopulation(
154
+ populationJSON: GenomeJSON[],
155
+ ): Promise<void>
156
+ ```
157
+
158
+ Import (replace) the current population from an array of serialized genomes.
159
+ This does not touch NEAT meta state (generation, innovations, etc.) - only the
160
+ population array and implied `popsize` are updated.
161
+ That makes it the right tool when you want to swap candidate solutions into an
162
+ existing controller context instead of restoring a full historical checkpoint.
163
+
164
+ Example:
165
+
166
+ ```ts
167
+ const populationData: GenomeJSON[] = JSON.parse(fs.readFileSync('population.json', 'utf8'));
168
+ neat.importPopulation(populationData); // population replaced
169
+ neat.evolve(); // continue evolving with new starting genomes
170
+ ```
171
+
172
+ Edge cases handled:
173
+ - Empty array => becomes an empty population (popsize=0).
174
+ - Malformed entries will throw if `Network.fromJSON` rejects them.
175
+
176
+ Parameters:
177
+ - `populationJSON` - Array of serialized genome objects.
178
+
179
+ Returns: Promise that resolves once all genomes have been rehydrated and the
180
+ controller population has been replaced.
181
+
182
+ ### importStateImpl
183
+
184
+ ```ts
185
+ importStateImpl(
186
+ stateBundle: NeatStateJSON,
187
+ fitnessFunction: (network: GenomeWithSerialization) => number | Promise<number>,
188
+ ): Promise<NeatControllerForExport>
189
+ ```
190
+
191
+ Static-style helper that rehydrates a full evolutionary state previously
192
+ produced by {@link exportState}. Invoke this with the NEAT class (not an
193
+ instance) bound as `this`, e.g. `Neat.importStateImpl(bundle, fitnessFn)`.
194
+ It constructs a new NEAT instance using the meta data, then imports the
195
+ population (if present).
196
+
197
+ This is the most complete restore path in the chapter. If a saved bundle is
198
+ valid, the caller gets back a fresh controller that knows both where the run
199
+ was in evolutionary time and which genomes were alive at that moment.
200
+
201
+ Safety and validation:
202
+ - Throws if the bundle is not an object.
203
+ - Silently skips population import if `population` is missing or not an array.
204
+
205
+ Example:
206
+
207
+ ```ts
208
+ const bundle: NeatStateJSON = JSON.parse(fs.readFileSync('state.json', 'utf8'));
209
+ const neat = Neat.importStateImpl(bundle, fitnessFn);
210
+ neat.evolve();
211
+ ```
212
+
213
+ Parameters:
214
+ - `stateBundle` - Full state bundle from {@link exportState} .
215
+ - `fitnessFunction` - Fitness evaluation callback used for new instance.
216
+
217
+ Returns: Rehydrated NEAT instance ready to continue evolving.
252
218
 
253
219
  ### InnovationMapEntry
254
220
 
@@ -257,12 +223,13 @@ Connection innovation map entry.
257
223
  Innovation maps are serialized as `[key, value]` tuples so they can round-trip
258
224
  cleanly through JSON and later be restored into `Map` instances.
259
225
 
260
- ### GenomeWithSerialization
226
+ ### NeatConstructor
261
227
 
262
- Genome with toJSON serialization method.
228
+ NEAT class constructor interface.
263
229
 
264
- This is the smallest runtime contract needed by the export helpers when they
265
- only care about turning one genome into a JSON payload.
230
+ Static-style restore helpers depend on this constructor shape so they can
231
+ rebuild a controller instance from persisted meta data and then optionally
232
+ rehydrate the population.
266
233
 
267
234
  ### NeatControllerForExport
268
235
 
@@ -273,6 +240,22 @@ of the concrete `Neat` class. That keeps export and restore logic reusable in
273
240
  tests and static-style helper flows without coupling the file to the full
274
241
  controller implementation.
275
242
 
243
+ ### NeatMetaJSON
244
+
245
+ Serialized meta information describing a NEAT run, excluding the concrete
246
+ population genomes. This allows you to persist and resume experiment context
247
+ without committing to a particular population snapshot.
248
+
249
+ ### NeatStateJSON
250
+
251
+ Top-level bundle containing both NEAT meta information and the full array of
252
+ serialized genomes (population). This is what you get from `exportState()` and
253
+ feed into `importStateImpl()` to resume exactly where you left off.
254
+
255
+ If `NeatMetaJSON` is the controller checkpoint and `GenomeJSON[]` is the pool
256
+ of candidate solutions, `NeatStateJSON` is the combined pause-and-resume
257
+ artifact that preserves both layers together.
258
+
276
259
  ### NetworkClass
277
260
 
278
261
  Network class with static fromJSON method.
@@ -280,10 +263,27 @@ Network class with static fromJSON method.
280
263
  Import helpers use this contract when rebuilding genomes from serialized JSON
281
264
  without needing to know the concrete network implementation details.
282
265
 
283
- ### NeatConstructor
266
+ ### toJSONImpl
284
267
 
285
- NEAT class constructor interface.
268
+ ```ts
269
+ toJSONImpl(): NeatMetaJSON
270
+ ```
286
271
 
287
- Static-style restore helpers depend on this constructor shape so they can
288
- rebuild a controller instance from persisted meta data and then optionally
289
- rehydrate the population.
272
+ Serialize NEAT meta (excluding the mutable population) for persistence of
273
+ innovation history and experiment configuration. This is sufficient to
274
+ recreate a blank NEAT run at the same evolutionary generation with the same
275
+ innovation counters, enabling deterministic continuation when combined later
276
+ with a saved population.
277
+
278
+ Use this path when the controller context matters but the population payload
279
+ should be stored, transferred, or versioned separately.
280
+
281
+ Example:
282
+
283
+ ```ts
284
+ const meta = neat.toJSONImpl();
285
+ fs.writeFileSync('neat-meta.json', JSON.stringify(meta));
286
+ // ... later ...
287
+ const metaLoaded = JSON.parse(fs.readFileSync('neat-meta.json', 'utf8')) as NeatMetaJSON;
288
+ const neat2 = Neat.fromJSONImpl(metaLoaded, fitnessFn); // empty population
289
+ ```
@@ -51,56 +51,6 @@ cross the boundary into the live population in a normalized state?
51
51
 
52
52
  ## neat/helpers/neat.helpers.ts
53
53
 
54
- ### spawnFromParent
55
-
56
- ```ts
57
- spawnFromParent(
58
- parentGenome: GenomeWithMetadata,
59
- mutateCount: number,
60
- ): Promise<GenomeWithMetadata>
61
- ```
62
-
63
- Spawn (clone & mutate) a child genome from an existing parent genome.
64
-
65
- Read this helper as the provisional provenance path. It produces a candidate
66
- offspring whose lineage is already meaningful, but whose membership in the
67
- active population is still undecided. That split is important when a caller
68
- wants to preview, filter, score, or compare several children before allowing
69
- one of them to join the population through {@link addGenome}.
70
-
71
- Evolutionary rationale:
72
- - Cloning preserves the full topology and weights of the parent.
73
- - A configurable number of mutation passes are applied sequentially; each
74
- pass may alter structure (add/remove nodes or connections) or weights.
75
- - Lineage annotations (`_parents`, `_depth`) enable later analytics such as
76
- diversity statistics, genealogy visualization, and pruning heuristics.
77
- - Cache invalidation happens before the child is returned so later admission
78
- or evaluation logic never observes stale derived state from the clone.
79
-
80
- Robustness philosophy: individual mutation failures are silently ignored so a
81
- single stochastic edge case does not derail evolutionary progress.
82
-
83
- Parameters:
84
- - `this` - Bound NEAT instance (inferred when used as a method).
85
- - `parentGenome` - Parent genome/network to clone. Must implement either
86
- `clone()` OR a pair of `toJSON()` / static `fromJSON()` for deep copying.
87
- - `mutateCount` - Number of sequential mutation operations to attempt; each
88
- iteration chooses a mutation method using the instance's selection
89
- logic. Defaults to 1 for conservative structural drift.
90
-
91
- Returns: A new genome whose score and derived caches are reset, whose lineage
92
- metadata references the parent, and whose final admission into the
93
- live population is left to the caller.
94
-
95
- Example:
96
-
97
- ```ts
98
- // Assume `neat` is an instance implementing NeatLike and `parent` is a genome in neat.population
99
- const child = neat.spawnFromParent(parent, 3); // apply 3 mutation passes
100
- // Optionally inspect / filter the child before adding
101
- neat.addGenome(child, [parent._id]);
102
- ```
103
-
104
54
  ### addGenome
105
55
 
106
56
  ```ts
@@ -230,3 +180,53 @@ In practice this seam protects two invariants:
230
180
  - every entering genome receives the same controller-owned metadata shape,
231
181
  - every entry path applies the same best-effort cleanup before later chapters
232
182
  read the genome.
183
+
184
+ ### spawnFromParent
185
+
186
+ ```ts
187
+ spawnFromParent(
188
+ parentGenome: GenomeWithMetadata,
189
+ mutateCount: number,
190
+ ): Promise<GenomeWithMetadata>
191
+ ```
192
+
193
+ Spawn (clone & mutate) a child genome from an existing parent genome.
194
+
195
+ Read this helper as the provisional provenance path. It produces a candidate
196
+ offspring whose lineage is already meaningful, but whose membership in the
197
+ active population is still undecided. That split is important when a caller
198
+ wants to preview, filter, score, or compare several children before allowing
199
+ one of them to join the population through {@link addGenome}.
200
+
201
+ Evolutionary rationale:
202
+ - Cloning preserves the full topology and weights of the parent.
203
+ - A configurable number of mutation passes are applied sequentially; each
204
+ pass may alter structure (add/remove nodes or connections) or weights.
205
+ - Lineage annotations (`_parents`, `_depth`) enable later analytics such as
206
+ diversity statistics, genealogy visualization, and pruning heuristics.
207
+ - Cache invalidation happens before the child is returned so later admission
208
+ or evaluation logic never observes stale derived state from the clone.
209
+
210
+ Robustness philosophy: individual mutation failures are silently ignored so a
211
+ single stochastic edge case does not derail evolutionary progress.
212
+
213
+ Parameters:
214
+ - `this` - Bound NEAT instance (inferred when used as a method).
215
+ - `parentGenome` - Parent genome/network to clone. Must implement either
216
+ `clone()` OR a pair of `toJSON()` / static `fromJSON()` for deep copying.
217
+ - `mutateCount` - Number of sequential mutation operations to attempt; each
218
+ iteration chooses a mutation method using the instance's selection
219
+ logic. Defaults to 1 for conservative structural drift.
220
+
221
+ Returns: A new genome whose score and derived caches are reset, whose lineage
222
+ metadata references the parent, and whose final admission into the
223
+ live population is left to the caller.
224
+
225
+ Example:
226
+
227
+ ```ts
228
+ // Assume `neat` is an instance implementing NeatLike and `parent` is a genome in neat.population
229
+ const child = neat.spawnFromParent(parent, 3); // apply 3 mutation passes
230
+ // Optionally inspect / filter the child before adding
231
+ neat.addGenome(child, [parent._id]);
232
+ ```
@@ -118,6 +118,15 @@ After the call returns, the instance has concrete startup policy, prepared
118
118
  controller state, and either an attempted generation-zero pool or a safely
119
119
  preserved empty population ready for later work.
120
120
 
121
+ ### InitializeNeatConstructorRequest
122
+
123
+ Mutable constructor request packet consumed during bootstrap.
124
+
125
+ `optionBag` is the live options object that the public facade keeps after the
126
+ constructor returns, `rawOptions` preserves the caller's original intent for
127
+ checks that should not be default-inflated, and `defaults` supplies the
128
+ public baseline constants exported by the surrounding NEAT surface.
129
+
121
130
  ### NeatConstructorDefaults
122
131
 
123
132
  ### NeatInitializationHost
@@ -129,12 +138,3 @@ helper needs write access to a few controller-owned fields and one pool
129
138
  creation hook, but it does not own evaluation, evolution, or persistence.
130
139
  Keeping the contract narrow prevents the init chapter from quietly becoming a
131
140
  second facade.
132
-
133
- ### InitializeNeatConstructorRequest
134
-
135
- Mutable constructor request packet consumed during bootstrap.
136
-
137
- `optionBag` is the live options object that the public facade keeps after the
138
- constructor returns, `rawOptions` preserves the caller's original intent for
139
- checks that should not be default-inflated, and `defaults` supplies the
140
- public baseline constants exported by the surrounding NEAT surface.