@reicek/neataptic-ts 0.1.21 → 0.1.23
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/agents/boundary-mapper.agent.md +31 -0
- package/.github/agents/docs-scout.agent.md +29 -0
- package/.github/agents/plan-scout.agent.md +31 -0
- package/.github/agents/solid-split.agent.md +143 -0
- package/.github/copilot-instructions.md +119 -0
- package/.github/skills/solid-split-playbook/SKILL.md +220 -0
- package/.github/skills/solid-split-playbook/assets/docs-checklist.md +34 -0
- package/.github/skills/solid-split-playbook/assets/split-plan-template.md +48 -0
- package/.github/skills/solid-split-playbook/assets/split-workflow-checklist.md +51 -0
- package/.github/skills/trace-analyzer-extension/SKILL.md +63 -0
- package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +24 -0
- package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +101 -0
- package/.github/skills/trace-audit-reporting/SKILL.md +96 -0
- package/.github/skills/trace-audit-reporting/assets/performance-report-template.md +123 -0
- package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +132 -0
- package/package.json +7 -3
- package/plans/ES2023 migration +13 -8
- package/plans/Evolution_Training_Interoperability_Contracts.md +1 -1
- package/plans/Flappy_Bird_Folder_Documentation_Pass.md +53 -0
- package/plans/Flappy_Evolution_Worker_Documentation_Pass.md +58 -0
- package/plans/Interactive_Examples_and_Learning_Path.md +10 -2
- package/plans/Memory_Optimization.md +3 -3
- package/plans/README.md +63 -0
- package/plans/Roadmap.md +15 -3
- package/plans/asciiMaze_SOLID_split.done.md +130 -0
- package/plans/flappy_bird_SOLID_split.done.md +67 -0
- package/scripts/analyze-trace.ts +590 -0
- package/scripts/assets/theme.css +221 -34
- package/scripts/copy-examples.mjs +9 -5
- package/scripts/export-onnx.mjs +3 -3
- package/scripts/generate-bench-tables.mjs +10 -10
- package/scripts/generate-bench-tables.ts +10 -10
- package/scripts/generate-docs.ts +1415 -449
- package/scripts/render-docs-html.ts +15 -8
- package/src/README.md +127 -222
- package/src/architecture/README.md +117 -184
- package/src/architecture/architect.ts +6 -0
- package/src/architecture/layer/README.md +38 -38
- package/src/architecture/network/README.md +49 -31
- package/src/architecture/network/activate/README.md +77 -77
- package/src/architecture/network/connect/README.md +15 -13
- package/src/architecture/network/deterministic/README.md +7 -7
- package/src/architecture/network/evolve/README.md +44 -44
- package/src/architecture/network/gating/README.md +20 -20
- package/src/architecture/network/genetic/README.md +51 -51
- package/src/architecture/network/mutate/README.md +97 -97
- package/src/architecture/network/network.types.ts +39 -0
- package/src/architecture/network/onnx/README.md +264 -264
- package/src/architecture/network/prune/README.md +39 -39
- package/src/architecture/network/remove/README.md +26 -26
- package/src/architecture/network/serialize/README.md +56 -56
- package/src/architecture/network/serialize/network.serialize.json.utils.ts +1 -0
- package/src/architecture/network/serialize/network.serialize.utils.ts +6 -1
- package/src/architecture/network/serialize/network.serialize.utils.types.ts +1 -1
- package/src/architecture/network/slab/README.md +61 -61
- package/src/architecture/network/standalone/README.md +24 -24
- package/src/architecture/network/stats/README.md +9 -9
- package/src/architecture/network/topology/README.md +46 -46
- package/src/architecture/network/training/README.md +21 -21
- package/src/architecture/network.ts +114 -10
- package/src/methods/README.md +9 -87
- package/src/multithreading/README.md +8 -77
- package/src/multithreading/workers/README.md +2 -2
- package/src/multithreading/workers/browser/README.md +0 -6
- package/src/multithreading/workers/node/README.md +0 -3
- package/src/neat/README.md +623 -568
- package/src/neat/neat.evolve.population.utils.ts +29 -5
- package/src/neat/neat.helpers.ts +16 -0
- package/src/neat/neat.topology-intent.utils.ts +160 -0
- package/src/utils/README.md +18 -18
- package/test/examples/asciiMaze/README.md +59 -59
- package/test/examples/asciiMaze/asciiMaze.e2e.test.ts +14 -9
- package/test/examples/asciiMaze/browser-entry/README.md +196 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.abort.services.ts +95 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.constants.ts +23 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.curriculum.services.ts +115 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.globals.services.ts +106 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.host.services.ts +157 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.services.ts +14 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.ts +129 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.types.ts +120 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.utils.ts +98 -0
- package/test/examples/asciiMaze/browser-entry.ts +10 -576
- package/test/examples/asciiMaze/dashboardManager/README.md +276 -0
- package/test/examples/asciiMaze/dashboardManager/archive/README.md +16 -0
- package/test/examples/asciiMaze/dashboardManager/archive/dashboardManager.archive.services.ts +267 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.constants.ts +35 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.services.ts +103 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.ts +181 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.types.ts +267 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.utils.ts +254 -0
- package/test/examples/asciiMaze/dashboardManager/live/README.md +14 -0
- package/test/examples/asciiMaze/dashboardManager/live/dashboardManager.live.services.ts +264 -0
- package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +47 -0
- package/test/examples/asciiMaze/dashboardManager/telemetry/dashboardManager.telemetry.services.ts +513 -0
- package/test/examples/asciiMaze/dashboardManager.ts +13 -2335
- package/test/examples/asciiMaze/evolutionEngine/README.md +1058 -0
- package/test/examples/asciiMaze/evolutionEngine/curriculumPhase.ts +90 -0
- package/test/examples/asciiMaze/evolutionEngine/engineState.constants.ts +36 -0
- package/test/examples/asciiMaze/evolutionEngine/engineState.ts +58 -513
- package/test/examples/asciiMaze/evolutionEngine/engineState.types.ts +212 -0
- package/test/examples/asciiMaze/evolutionEngine/engineState.utils.ts +301 -0
- package/test/examples/asciiMaze/evolutionEngine/evolutionEngine.types.ts +445 -0
- package/test/examples/asciiMaze/evolutionEngine/evolutionLoop.ts +81 -50
- package/test/examples/asciiMaze/evolutionEngine/optionsAndSetup.ts +2 -4
- package/test/examples/asciiMaze/evolutionEngine/populationDynamics.ts +17 -33
- package/test/examples/asciiMaze/evolutionEngine/populationPruning.ts +1 -1
- package/test/examples/asciiMaze/evolutionEngine/rngAndTiming.ts +1 -2
- package/test/examples/asciiMaze/evolutionEngine/sampling.ts +1 -1
- package/test/examples/asciiMaze/evolutionEngine/scratchPools.ts +2 -5
- package/test/examples/asciiMaze/evolutionEngine/setupHelpers.ts +30 -37
- package/test/examples/asciiMaze/evolutionEngine/telemetryMetrics.ts +16 -58
- package/test/examples/asciiMaze/evolutionEngine/trainingWarmStart.ts +2 -2
- package/test/examples/asciiMaze/evolutionEngine.ts +55 -55
- package/test/examples/asciiMaze/fitness.ts +2 -2
- package/test/examples/asciiMaze/fitness.types.ts +65 -0
- package/test/examples/asciiMaze/interfaces.ts +64 -1352
- package/test/examples/asciiMaze/mazeMovement/README.md +356 -0
- package/test/examples/asciiMaze/mazeMovement/finalization/README.md +49 -0
- package/test/examples/asciiMaze/mazeMovement/finalization/mazeMovement.finalization.ts +138 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.constants.ts +101 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.services.ts +230 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.ts +299 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.types.ts +185 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.utils.ts +153 -0
- package/test/examples/asciiMaze/mazeMovement/policy/README.md +91 -0
- package/test/examples/asciiMaze/mazeMovement/policy/mazeMovement.policy.ts +467 -0
- package/test/examples/asciiMaze/mazeMovement/runtime/README.md +95 -0
- package/test/examples/asciiMaze/mazeMovement/runtime/mazeMovement.runtime.ts +354 -0
- package/test/examples/asciiMaze/mazeMovement/shaping/README.md +124 -0
- package/test/examples/asciiMaze/mazeMovement/shaping/mazeMovement.shaping.ts +459 -0
- package/test/examples/asciiMaze/mazeMovement.ts +12 -2978
- package/test/examples/flappy_bird/README.md +193 -88
- package/test/examples/flappy_bird/browser-entry/README.md +1441 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.host.utils.ts +4 -324
- package/test/examples/flappy_bird/browser-entry/browser-entry.network-view.utils.ts +9 -396
- package/test/examples/flappy_bird/browser-entry/browser-entry.playback.utils.ts +6 -714
- package/test/examples/flappy_bird/browser-entry/browser-entry.render.types.ts +26 -3
- package/test/examples/flappy_bird/browser-entry/browser-entry.runtime.types.ts +16 -1
- package/test/examples/flappy_bird/browser-entry/browser-entry.simulation.types.ts +39 -5
- package/test/examples/flappy_bird/browser-entry/browser-entry.spawn.utils.ts +11 -31
- package/test/examples/flappy_bird/browser-entry/browser-entry.stats.types.ts +32 -4
- package/test/examples/flappy_bird/browser-entry/browser-entry.ts +11 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.types.ts +8 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.visualization.types.ts +50 -7
- package/test/examples/flappy_bird/browser-entry/browser-entry.visualization.utils.ts +21 -893
- package/test/examples/flappy_bird/browser-entry/browser-entry.worker.types.ts +91 -10
- package/test/examples/flappy_bird/browser-entry/host/README.md +318 -0
- package/test/examples/flappy_bird/browser-entry/host/host.canvas.service.ts +16 -0
- package/test/examples/flappy_bird/browser-entry/host/host.constants.ts +20 -0
- package/test/examples/flappy_bird/browser-entry/host/host.dom.service.ts +10 -0
- package/test/examples/flappy_bird/browser-entry/host/host.resize.service.ts +1 -295
- package/test/examples/flappy_bird/browser-entry/host/host.stats.service.ts +14 -0
- package/test/examples/flappy_bird/browser-entry/host/host.ts +592 -6
- package/test/examples/flappy_bird/browser-entry/host/host.types.ts +13 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/README.md +309 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.constants.ts +47 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.services.ts +392 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.ts +132 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types.ts +92 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.utils.ts +272 -0
- package/test/examples/flappy_bird/browser-entry/network-view/README.md +389 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.draw.service.ts +13 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.labels.utils.ts +12 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.layout.utils.ts +14 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.topology.utils.ts +267 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.ts +823 -7
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.types.ts +11 -0
- package/test/examples/flappy_bird/browser-entry/playback/README.md +845 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/README.md +355 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +1068 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.batch.services.ts +64 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.cache.services.ts +207 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.constants.ts +197 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.batch.utils.ts +114 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.layout.utils.test.ts +96 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.layout.utils.ts +204 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.services.ts +49 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.utils.ts +313 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.layer.services.ts +81 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.math.utils.test.ts +33 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.math.utils.ts +201 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.selection.utils.ts +171 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.timing.utils.ts +124 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.utils.test.ts +279 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.utils.ts +132 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.scene.services.ts +26 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.services.ts +65 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.ts +48 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.types.ts +342 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.utils.ts +10 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.cache.services.ts +96 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.constants.ts +127 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.draw.services.ts +184 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.scene.services.ts +64 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.services.ts +6 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.ts +53 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.types.ts +105 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.utils.ts +100 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +541 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.bird.utils.ts +180 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.canvas.services.ts +77 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.entity.services.ts +167 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.scene.services.ts +57 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.service.test.ts +176 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.service.ts +113 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.services.ts +35 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.trail.utils.ts +248 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.types.ts +103 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.utils.ts +11 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.constants.ts +1 -1
- package/test/examples/flappy_bird/browser-entry/playback/playback.frame-render.service.ts +10 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.iteration.services.ts +192 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.loop.service.ts +12 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.orchestration.types.ts +78 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.render.pipe-outline.service.ts +128 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.render.service.ts +1 -116
- package/test/examples/flappy_bird/browser-entry/playback/playback.session.services.ts +184 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.snapshot.utils.test.ts +121 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.snapshot.utils.ts +8 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.layer.services.ts +36 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.service.ts +11 -128
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.services.ts +268 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.types.ts +91 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.utils.ts +11 -4
- package/test/examples/flappy_bird/browser-entry/playback/playback.trail.utils.ts +9 -86
- package/test/examples/flappy_bird/browser-entry/playback/playback.ts +75 -7
- package/test/examples/flappy_bird/browser-entry/playback/playback.types.ts +12 -9
- package/test/examples/flappy_bird/browser-entry/playback/playback.worker-channel.utils.ts +11 -123
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +55 -0
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/playback.snapshot.services.ts +103 -0
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/playback.snapshot.summary.utils.test.ts +45 -0
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/playback.snapshot.summary.utils.ts +28 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +95 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.history.services.test.ts +35 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.history.services.ts +64 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.opacity.utils.test.ts +37 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.opacity.utils.ts +74 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +71 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/playback.worker-channel.request.services.ts +45 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/playback.worker-channel.summary.services.ts +74 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/playback.worker-channel.types.ts +53 -0
- package/test/examples/flappy_bird/browser-entry/runtime/README.md +304 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.browser-globals.service.ts +15 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.errors.ts +17 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.evolution-launch.service.ts +56 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.evolution-loop.service.ts +19 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.lifecycle.service.ts +96 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.startup.service.ts +92 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.telemetry.service.ts +24 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.ts +31 -121
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.types.ts +65 -0
- package/test/examples/flappy_bird/browser-entry/visualization/README.md +568 -0
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.colors.utils.ts +26 -0
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.constants.ts +110 -0
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.draw.service.ts +979 -19
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.legend.utils.ts +157 -3
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.topology.utils.ts +13 -27
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.ts +7 -20
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.types.ts +14 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +238 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.errors.ts +11 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.generation.service.ts +12 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.playback.service.test.ts +143 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.playback.service.ts +140 -14
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.request.service.ts +27 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.ts +8 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.types.ts +23 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.url.service.ts +5 -0
- package/test/examples/flappy_bird/constants/README.md +1163 -0
- package/test/examples/flappy_bird/constants/constants.birds.ts +16 -38
- package/test/examples/flappy_bird/constants/constants.difficulty.ts +21 -0
- package/test/examples/flappy_bird/constants/constants.network-view.ts +24 -0
- package/test/examples/flappy_bird/constants/constants.network.ts +1 -1
- package/test/examples/flappy_bird/constants/constants.observation.ts +7 -0
- package/test/examples/flappy_bird/constants/constants.palette.ts +9 -2
- package/test/examples/flappy_bird/constants/constants.physics.ts +9 -0
- package/test/examples/flappy_bird/constants/constants.pipe-render.ts +3 -0
- package/test/examples/flappy_bird/constants/constants.pipes.ts +22 -3
- package/test/examples/flappy_bird/constants/constants.runtime.ts +28 -4
- package/test/examples/flappy_bird/constants/constants.starfield.ts +78 -3
- package/test/examples/flappy_bird/constants/constants.ts +6 -0
- package/test/examples/flappy_bird/environment/README.md +182 -0
- package/test/examples/flappy_bird/environment/environment.collision.utils.ts +7 -0
- package/test/examples/flappy_bird/environment/environment.constants.ts +16 -3
- package/test/examples/flappy_bird/environment/environment.observation.utils.ts +12 -19
- package/test/examples/flappy_bird/environment/environment.state.service.ts +10 -0
- package/test/examples/flappy_bird/environment/environment.step.service.ts +15 -66
- package/test/examples/flappy_bird/environment/environment.types.ts +14 -0
- package/test/examples/flappy_bird/evaluation/README.md +155 -0
- package/test/examples/flappy_bird/evaluation/evaluation.constants.ts +23 -4
- package/test/examples/flappy_bird/evaluation/evaluation.fitness.utils.ts +16 -1
- package/test/examples/flappy_bird/evaluation/evaluation.rollout.service.ts +7 -374
- package/test/examples/flappy_bird/evaluation/evaluation.seed.utils.ts +4 -0
- package/test/examples/flappy_bird/evaluation/evaluation.types.ts +18 -2
- package/test/examples/flappy_bird/evaluation/rollout/README.md +355 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.constants.ts +38 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.service.ts +71 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.services.ts +338 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.types.ts +69 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.utils.ts +399 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +845 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.constants.ts +49 -7
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.errors.ts +34 -3
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.evolution.service.ts +22 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.playback.service.ts +62 -26
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.protocol.service.ts +27 -1
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.runtime.service.ts +23 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.frame.service.ts +378 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.types.ts +22 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.utils.ts +20 -203
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.snapshot.utils.test.ts +94 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.snapshot.utils.ts +78 -13
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.ts +235 -344
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types.ts +170 -22
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.warm-start.service.ts +314 -0
- package/test/examples/flappy_bird/flappy.simulation.shared.utils.ts +17 -0
- package/test/examples/flappy_bird/flappyEnvironment.ts +21 -0
- package/test/examples/flappy_bird/flappyEvaluation.ts +12 -0
- package/test/examples/flappy_bird/flappyEvolution.worker.ts +7 -0
- package/test/examples/flappy_bird/index.ts +8 -2
- package/test/examples/flappy_bird/rng.ts +10 -0
- package/test/examples/flappy_bird/simulation-shared/README.md +518 -0
- package/test/examples/flappy_bird/simulation-shared/observation/README.md +255 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.features.utils.ts +339 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.ts +19 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.vector.utils.ts +81 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.constants.ts +3 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.control.utils.ts +6 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.difficulty.utils.ts +9 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.errors.ts +10 -1
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.memory.utils.ts +18 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.observation.utils.ts +7 -402
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.spawn.utils.ts +36 -6
- package/test/examples/flappy_bird/{evaluation/evaluation.statistics.utils.ts → simulation-shared/simulation-shared.statistics.utils.ts} +30 -9
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.types.ts +38 -5
- package/test/examples/flappy_bird/trainFlappyBird.ts +13 -0
- package/test/examples/flappy_bird/trainer/README.md +676 -0
- package/test/examples/flappy_bird/trainer/evaluation/README.md +253 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.constants.ts +15 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.services.ts +86 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.ts +187 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.types.ts +32 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.utils.ts +182 -0
- package/test/examples/flappy_bird/trainer/trainer.evaluation.service.ts +13 -0
- package/test/examples/flappy_bird/trainer/trainer.fitness.service.ts +23 -1
- package/test/examples/flappy_bird/trainer/trainer.loop.service.ts +17 -1
- package/test/examples/flappy_bird/trainer/trainer.report.service.services.ts +181 -0
- package/test/examples/flappy_bird/trainer/trainer.report.service.ts +136 -0
- package/test/examples/flappy_bird/trainer/trainer.selection.utils.ts +89 -0
- package/test/examples/flappy_bird/trainer/trainer.setup.service.ts +22 -0
- package/test/examples/flappy_bird/trainer/trainer.signals.service.ts +8 -0
- package/test/examples/flappy_bird/trainer/trainer.ts +38 -553
- package/test/examples/flappy_bird/trainer/trainer.types.ts +44 -7
- package/test/neat/neat.topology-intent.test.ts +129 -0
- package/test/network/network.topology-intent.test.ts +44 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.utils.ts +0 -12
- package/test/examples/flappy_bird/environment/environment.ts +0 -7
- package/test/examples/flappy_bird/evaluation/evaluation.ts +0 -7
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.ts +0 -15
- package/test/examples/flappy_bird/trainer/trainer.statistics.utils.ts +0 -78
|
@@ -11,6 +11,10 @@ import type {
|
|
|
11
11
|
GenomeWithMetadata,
|
|
12
12
|
NeatControllerForEvolution,
|
|
13
13
|
} from './neat.evolve.types';
|
|
14
|
+
import {
|
|
15
|
+
promoteGenomeToFeedForwardIntentWhenEligible,
|
|
16
|
+
usesFeedForwardMutationPolicy,
|
|
17
|
+
} from './neat.topology-intent.utils';
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
20
|
* Build the next population (elitism, provenance, offspring).
|
|
@@ -99,16 +103,36 @@ export function applyProvenance(
|
|
|
99
103
|
0,
|
|
100
104
|
Math.min(internal.options.provenance || 0, remainingSlotsAfterElites),
|
|
101
105
|
);
|
|
106
|
+
const shouldPromoteFeedForwardIntent = usesFeedForwardMutationPolicy(
|
|
107
|
+
internal.options.mutation,
|
|
108
|
+
);
|
|
109
|
+
|
|
102
110
|
// Step 2: Insert provenance genomes.
|
|
103
111
|
for (let index = 0; index < provenanceCount; index++) {
|
|
104
112
|
if (internal.options.network) {
|
|
105
|
-
|
|
113
|
+
const provenanceGenome = Network.fromJSON(
|
|
114
|
+
internal.options.network.toJSON(),
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
// Step 2.1: Preserve feed-forward intent when the seed topology is eligible.
|
|
118
|
+
promoteGenomeToFeedForwardIntentWhenEligible(
|
|
119
|
+
provenanceGenome,
|
|
120
|
+
shouldPromoteFeedForwardIntent,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
nextPopulation.push(provenanceGenome);
|
|
106
124
|
} else {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
const provenanceGenome = new Network(internal.input, internal.output, {
|
|
126
|
+
minHidden: internal.options.minHidden,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Step 2.2: Promote fresh provenance genomes when FFW is the active contract.
|
|
130
|
+
promoteGenomeToFeedForwardIntentWhenEligible(
|
|
131
|
+
provenanceGenome,
|
|
132
|
+
shouldPromoteFeedForwardIntent,
|
|
111
133
|
);
|
|
134
|
+
|
|
135
|
+
nextPopulation.push(provenanceGenome);
|
|
112
136
|
}
|
|
113
137
|
}
|
|
114
138
|
}
|
package/src/neat/neat.helpers.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { NeatLike } from './neat.types';
|
|
2
2
|
import Network from '../architecture/network';
|
|
3
|
+
import {
|
|
4
|
+
promoteGenomeToFeedForwardIntentWhenEligible,
|
|
5
|
+
usesFeedForwardMutationPolicy,
|
|
6
|
+
} from './neat.topology-intent.utils';
|
|
3
7
|
|
|
4
8
|
/**
|
|
5
9
|
* Genome with NEAT-specific metadata and methods.
|
|
@@ -13,6 +17,9 @@ interface GenomeWithMetadata {
|
|
|
13
17
|
clone?: () => GenomeWithMetadata;
|
|
14
18
|
toJSON?: () => Record<string, unknown>;
|
|
15
19
|
mutate?: (method: MutationMethod) => void;
|
|
20
|
+
setTopologyIntent?: (
|
|
21
|
+
topologyIntent: 'feed-forward' | 'unconstrained',
|
|
22
|
+
) => void;
|
|
16
23
|
[key: string]: unknown;
|
|
17
24
|
}
|
|
18
25
|
|
|
@@ -261,6 +268,9 @@ export function createPool(
|
|
|
261
268
|
// Step 1: Reset population container.
|
|
262
269
|
internal.population = [];
|
|
263
270
|
const poolSize = internal.options?.popsize ?? 50;
|
|
271
|
+
const shouldPromoteFeedForwardIntent = usesFeedForwardMutationPolicy(
|
|
272
|
+
internal.options?.mutation,
|
|
273
|
+
);
|
|
264
274
|
|
|
265
275
|
// Step 2: Generate each initial genome.
|
|
266
276
|
for (let genomeIndex = 0; genomeIndex < poolSize; genomeIndex++) {
|
|
@@ -276,6 +286,12 @@ export function createPool(
|
|
|
276
286
|
// Step 2a: Ensure no stale scoring information.
|
|
277
287
|
genomeCopy.score = undefined;
|
|
278
288
|
|
|
289
|
+
// Step 2a.1: Promote feed-forward topology intent when the policy and topology agree.
|
|
290
|
+
promoteGenomeToFeedForwardIntentWhenEligible(
|
|
291
|
+
genomeCopy,
|
|
292
|
+
shouldPromoteFeedForwardIntent,
|
|
293
|
+
);
|
|
294
|
+
|
|
279
295
|
// Step 2b: Attempt structural invariant enforcement (best effort).
|
|
280
296
|
try {
|
|
281
297
|
internal.ensureNoDeadEnds?.(genomeCopy);
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import * as methods from '../methods/methods';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Minimal mutation descriptor used by topology-intent helpers.
|
|
5
|
+
*/
|
|
6
|
+
export interface TopologyIntentMutationMethod {
|
|
7
|
+
/** Optional mutation name used for canonical pool comparison. */
|
|
8
|
+
name?: string;
|
|
9
|
+
/** Additional mutation metadata. */
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Minimal genome surface required to promote feed-forward intent safely.
|
|
15
|
+
*/
|
|
16
|
+
export interface TopologyIntentGenome {
|
|
17
|
+
/** Runtime node array in current graph order. */
|
|
18
|
+
nodes?: unknown[];
|
|
19
|
+
/** Runtime directed connection list. */
|
|
20
|
+
connections?: Array<{ from: unknown; to: unknown }>;
|
|
21
|
+
/** Runtime gated connection list. */
|
|
22
|
+
gates?: unknown[];
|
|
23
|
+
/** Runtime self-connection list. */
|
|
24
|
+
selfconns?: unknown[];
|
|
25
|
+
/** Public topology intent setter exposed by `Network`. */
|
|
26
|
+
setTopologyIntent?: (
|
|
27
|
+
topologyIntent: 'feed-forward' | 'unconstrained',
|
|
28
|
+
) => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Determine whether the configured mutation policy communicates feed-forward intent.
|
|
33
|
+
*
|
|
34
|
+
* @param mutationConfig Configured mutation option.
|
|
35
|
+
* @returns True when the option expresses canonical FFW intent.
|
|
36
|
+
*/
|
|
37
|
+
export function usesFeedForwardMutationPolicy(
|
|
38
|
+
mutationConfig:
|
|
39
|
+
| TopologyIntentMutationMethod
|
|
40
|
+
| TopologyIntentMutationMethod[]
|
|
41
|
+
| unknown,
|
|
42
|
+
): boolean {
|
|
43
|
+
// Step 1: Accept the canonical direct FFW reference.
|
|
44
|
+
if (mutationConfig === methods.mutation.FFW) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Step 2: Accept nested legacy `[methods.mutation.FFW]` wrappers.
|
|
49
|
+
if (
|
|
50
|
+
Array.isArray(mutationConfig) &&
|
|
51
|
+
mutationConfig.length === 1 &&
|
|
52
|
+
mutationConfig[0] === methods.mutation.FFW
|
|
53
|
+
) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Step 3: Accept flattened pools that match the canonical FFW operator names.
|
|
58
|
+
if (!Array.isArray(mutationConfig)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return matchesCanonicalFeedForwardPool(
|
|
63
|
+
mutationConfig as TopologyIntentMutationMethod[],
|
|
64
|
+
methods.mutation.FFW as TopologyIntentMutationMethod[],
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Promote a genome to feed-forward topology intent when the structure is eligible.
|
|
70
|
+
*
|
|
71
|
+
* @param genome Genome candidate being inserted into a population.
|
|
72
|
+
* @param shouldPromote Whether the active NEAT options request FFW semantics.
|
|
73
|
+
* @returns Nothing.
|
|
74
|
+
*/
|
|
75
|
+
export function promoteGenomeToFeedForwardIntentWhenEligible(
|
|
76
|
+
genome: TopologyIntentGenome,
|
|
77
|
+
shouldPromote: boolean,
|
|
78
|
+
): void {
|
|
79
|
+
// Step 1: Skip work when the configured mutation policy is not FFW.
|
|
80
|
+
if (!shouldPromote) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Step 2: Skip work when the genome cannot safely adopt feed-forward intent.
|
|
85
|
+
if (!isGenomeEligibleForFeedForwardIntentPromotion(genome)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Step 3: Apply the public topology contract through the network API.
|
|
90
|
+
genome.setTopologyIntent?.('feed-forward');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Check whether a configured mutation pool matches the canonical FFW pool.
|
|
95
|
+
*
|
|
96
|
+
* @param configuredPool Mutation pool configured on the NEAT instance.
|
|
97
|
+
* @param canonicalPool Canonical feed-forward mutation pool.
|
|
98
|
+
* @returns True when both pools align by operator name and order.
|
|
99
|
+
*/
|
|
100
|
+
function matchesCanonicalFeedForwardPool(
|
|
101
|
+
configuredPool: TopologyIntentMutationMethod[],
|
|
102
|
+
canonicalPool: TopologyIntentMutationMethod[],
|
|
103
|
+
): boolean {
|
|
104
|
+
// Step 1: Reject shape mismatches early.
|
|
105
|
+
if (configuredPool.length !== canonicalPool.length) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Step 2: Ensure the flattened pool matches the canonical FFW ordering.
|
|
110
|
+
return configuredPool.every((configuredMethod, methodIndex) => {
|
|
111
|
+
return configuredMethod?.name === canonicalPool[methodIndex]?.name;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Check whether a genome can safely adopt feed-forward topology intent.
|
|
117
|
+
*
|
|
118
|
+
* Eligibility is intentionally conservative: the graph must already be free of
|
|
119
|
+
* gates/self-connections and all normal connections must follow the current
|
|
120
|
+
* node ordering. This avoids reinterpreting arbitrary legacy seeds as ordered
|
|
121
|
+
* feed-forward graphs when that would change structural semantics.
|
|
122
|
+
*
|
|
123
|
+
* @param genome Genome candidate.
|
|
124
|
+
* @returns True when the genome can safely adopt feed-forward intent.
|
|
125
|
+
*/
|
|
126
|
+
function isGenomeEligibleForFeedForwardIntentPromotion(
|
|
127
|
+
genome: TopologyIntentGenome,
|
|
128
|
+
): boolean {
|
|
129
|
+
// Step 1: Validate that topology collections exist and that no recurrent-only
|
|
130
|
+
// features are currently active.
|
|
131
|
+
if (
|
|
132
|
+
!Array.isArray(genome.nodes) ||
|
|
133
|
+
!Array.isArray(genome.connections) ||
|
|
134
|
+
!Array.isArray(genome.gates) ||
|
|
135
|
+
!Array.isArray(genome.selfconns)
|
|
136
|
+
) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (genome.gates.length > 0 || genome.selfconns.length > 0) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Step 2: Require every connection to follow the current node ordering.
|
|
145
|
+
const nodeIndexByReference = new Map<unknown, number>();
|
|
146
|
+
genome.nodes.forEach((node, nodeIndex) => {
|
|
147
|
+
nodeIndexByReference.set(node, nodeIndex);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
return genome.connections.every((connection) => {
|
|
151
|
+
const sourceNodeIndex = nodeIndexByReference.get(connection.from);
|
|
152
|
+
const targetNodeIndex = nodeIndexByReference.get(connection.to);
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
sourceNodeIndex !== undefined &&
|
|
156
|
+
targetNodeIndex !== undefined &&
|
|
157
|
+
sourceNodeIndex < targetNodeIndex
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
}
|
package/src/utils/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Design principles:
|
|
|
20
20
|
|
|
21
21
|
### memoryStats
|
|
22
22
|
|
|
23
|
-
`(targetNetworks: import("
|
|
23
|
+
`(targetNetworks: import("src/utils/memory").NetworkView | import("src/utils/memory").NetworkView[] | undefined) => import("src/utils/memory").MemoryStats`
|
|
24
24
|
|
|
25
25
|
### MemoryStats
|
|
26
26
|
|
|
@@ -41,7 +41,7 @@ enabling typed local variables instead of `any` everywhere.
|
|
|
41
41
|
|
|
42
42
|
### registerTrackedNetwork
|
|
43
43
|
|
|
44
|
-
`(network: import("
|
|
44
|
+
`(network: import("src/utils/memory").NetworkView | null | undefined) => void`
|
|
45
45
|
|
|
46
46
|
### resetMemoryTracking
|
|
47
47
|
|
|
@@ -54,13 +54,13 @@ include additional fields; we only rely on fresh/pooled counts.
|
|
|
54
54
|
|
|
55
55
|
### unregisterTrackedNetwork
|
|
56
56
|
|
|
57
|
-
`(network: import("
|
|
57
|
+
`(network: import("src/utils/memory").NetworkView) => void`
|
|
58
58
|
|
|
59
59
|
## utils/memory.utils.ts
|
|
60
60
|
|
|
61
61
|
### accumulateCapacitySlices
|
|
62
62
|
|
|
63
|
-
`(accumulators: import("
|
|
63
|
+
`(accumulators: import("src/utils/memory.utils").Accumulators, network: import("src/utils/memory").NetworkView, heuristics: import("src/utils/memory.utils").HeuristicBytes) => void`
|
|
64
64
|
|
|
65
65
|
Track reserved vs used bytes based on connection capacity slices.
|
|
66
66
|
|
|
@@ -71,7 +71,7 @@ Parameters:
|
|
|
71
71
|
|
|
72
72
|
### accumulateSlabArrays
|
|
73
73
|
|
|
74
|
-
`(accumulators: import("
|
|
74
|
+
`(accumulators: import("src/utils/memory.utils").Accumulators, typedArrays: (Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int32Array<ArrayBufferLike>)[]) => void`
|
|
75
75
|
|
|
76
76
|
Sum slab-backed array counts and byte sizes into the accumulator.
|
|
77
77
|
|
|
@@ -86,7 +86,7 @@ Accumulates counts, slab byte totals, and reserved vs used capacity snapshots.
|
|
|
86
86
|
|
|
87
87
|
### aggregateNetworkStats
|
|
88
88
|
|
|
89
|
-
`(networksToSummarize: import("
|
|
89
|
+
`(networksToSummarize: import("src/utils/memory").NetworkView[], heuristics: import("src/utils/memory.utils").HeuristicBytes) => import("src/utils/memory.utils").Accumulators`
|
|
90
90
|
|
|
91
91
|
Aggregate per-network counters and slab metrics into a single accumulator.
|
|
92
92
|
|
|
@@ -98,7 +98,7 @@ Returns: Accumulated summary of network metrics.
|
|
|
98
98
|
|
|
99
99
|
### buildFlagSnapshot
|
|
100
100
|
|
|
101
|
-
`(configSnapshot: import("
|
|
101
|
+
`(configSnapshot: import("src/utils/memory.utils").ConfigSnapshot, allocationStats: import("src/utils/memory").SlabAllocStats) => { warnings: unknown; float32Mode: unknown; deterministicChainMode: unknown; enableGatingTraces: unknown; poolMaxPerBucket: number | null; poolPrewarmCount: number | null; enableNodePooling: boolean; allocStats: unknown; }`
|
|
102
102
|
|
|
103
103
|
Build flag snapshot derived from config and allocator stats.
|
|
104
104
|
|
|
@@ -115,7 +115,7 @@ Bundles precomputed accumulators, environment info, allocator stats, and flags.
|
|
|
115
115
|
|
|
116
116
|
### buildMemoryStatsSnapshot
|
|
117
117
|
|
|
118
|
-
`(input: import("
|
|
118
|
+
`(input: import("src/utils/memory.utils").BuildMemoryStatsInput) => import("src/utils/memory").MemoryStats`
|
|
119
119
|
|
|
120
120
|
Build the full MemoryStats snapshot from precomputed components.
|
|
121
121
|
|
|
@@ -126,7 +126,7 @@ Returns: Complete MemoryStats snapshot.
|
|
|
126
126
|
|
|
127
127
|
### buildSlabStats
|
|
128
128
|
|
|
129
|
-
`(accumulators: import("
|
|
129
|
+
`(accumulators: import("src/utils/memory.utils").Accumulators, networksToSummarize: import("src/utils/memory").NetworkView[], allocationStats: import("src/utils/memory").SlabAllocStats) => { slabBytes: number; slabArrayCount: number; fragmentationPct: number | null; reservedBytes: number | null; usedBytes: number | null; slabVersion: number | null; asyncBuilds: number; pooledFraction: number | null; }`
|
|
130
130
|
|
|
131
131
|
Assemble slab-related statistics for the MemoryStats payload.
|
|
132
132
|
|
|
@@ -139,7 +139,7 @@ Returns: Structured slab metrics block.
|
|
|
139
139
|
|
|
140
140
|
### calculateFragmentation
|
|
141
141
|
|
|
142
|
-
`(accumulators: import("
|
|
142
|
+
`(accumulators: import("src/utils/memory.utils").Accumulators) => number | null`
|
|
143
143
|
|
|
144
144
|
Compute fragmentation percentage from reserved vs used connection bytes.
|
|
145
145
|
|
|
@@ -150,7 +150,7 @@ Returns: Fragmentation percent (0-100) or null when undefined.
|
|
|
150
150
|
|
|
151
151
|
### calculatePooledFraction
|
|
152
152
|
|
|
153
|
-
`(allocationStats: import("
|
|
153
|
+
`(allocationStats: import("src/utils/memory").SlabAllocStats) => number | null`
|
|
154
154
|
|
|
155
155
|
Calculate pooled fraction from allocator stats with four-decimal precision.
|
|
156
156
|
|
|
@@ -169,7 +169,7 @@ Returns: Environment metrics structure for the snapshot.
|
|
|
169
169
|
|
|
170
170
|
### captureVersionMetadata
|
|
171
171
|
|
|
172
|
-
`(accumulators: import("
|
|
172
|
+
`(accumulators: import("src/utils/memory.utils").Accumulators, network: import("src/utils/memory").NetworkView) => void`
|
|
173
173
|
|
|
174
174
|
Capture slab metadata (version and async builds) once across all networks.
|
|
175
175
|
|
|
@@ -179,7 +179,7 @@ Parameters:
|
|
|
179
179
|
|
|
180
180
|
### collectConnectionTypedArrays
|
|
181
181
|
|
|
182
|
-
`(network: import("
|
|
182
|
+
`(network: import("src/utils/memory").NetworkView) => (Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int32Array<ArrayBufferLike>)[]`
|
|
183
183
|
|
|
184
184
|
Gather all typed arrays that represent connection-parallel data on a network.
|
|
185
185
|
|
|
@@ -190,7 +190,7 @@ Returns: Typed arrays aligned to connections.
|
|
|
190
190
|
|
|
191
191
|
### computeCounts
|
|
192
192
|
|
|
193
|
-
`(network: import("
|
|
193
|
+
`(network: import("src/utils/memory").NetworkView) => CountSnapshot`
|
|
194
194
|
|
|
195
195
|
Capture simple counts for nodes and connections on a network view.
|
|
196
196
|
|
|
@@ -208,7 +208,7 @@ Keeps only the flags relevant to the memory snapshot to avoid leaking full confi
|
|
|
208
208
|
|
|
209
209
|
### createEmptyAccumulators
|
|
210
210
|
|
|
211
|
-
`() => import("
|
|
211
|
+
`() => import("src/utils/memory.utils").Accumulators`
|
|
212
212
|
|
|
213
213
|
Initialize a fresh accumulator snapshot for memory summaries.
|
|
214
214
|
|
|
@@ -216,7 +216,7 @@ Returns: Zeroed accumulators ready for aggregation.
|
|
|
216
216
|
|
|
217
217
|
### describeConnectionBytes
|
|
218
218
|
|
|
219
|
-
`(network: import("
|
|
219
|
+
`(network: import("src/utils/memory").NetworkView, heuristics: import("src/utils/memory.utils").HeuristicBytes) => number`
|
|
220
220
|
|
|
221
221
|
Determine bytes per connection using typed-array width or heuristic fallback.
|
|
222
222
|
|
|
@@ -237,7 +237,7 @@ These numbers represent typical JS object footprints, not exact runtime measurem
|
|
|
237
237
|
|
|
238
238
|
### normalizeNetworks
|
|
239
239
|
|
|
240
|
-
`(targets: import("
|
|
240
|
+
`(targets: import("src/utils/memory").NetworkView | import("src/utils/memory").NetworkView[] | undefined, trackedNetworks: import("src/utils/memory").NetworkView[]) => import("src/utils/memory").NetworkView[]`
|
|
241
241
|
|
|
242
242
|
Normalize provided targets to an array of networks, falling back to tracked registry.
|
|
243
243
|
|
|
@@ -249,7 +249,7 @@ Returns: Array of networks to summarize.
|
|
|
249
249
|
|
|
250
250
|
### safeGetSlabAllocationStats
|
|
251
251
|
|
|
252
|
-
`(getSlabAllocationStats: () => unknown) => import("
|
|
252
|
+
`(getSlabAllocationStats: () => unknown) => import("src/utils/memory").SlabAllocStats`
|
|
253
253
|
|
|
254
254
|
Safely read slab allocation stats, guarding against provider errors.
|
|
255
255
|
|
|
@@ -32,59 +32,59 @@ Use this as a reference architecture when building your own task-specific neuroe
|
|
|
32
32
|
### Core runtime
|
|
33
33
|
|
|
34
34
|
- `evolutionEngine.ts`
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
- Public façade entry point: `EvolutionEngine.runMazeEvolution(options)`.
|
|
36
|
+
- Delegates to modular files under `evolutionEngine/`.
|
|
37
37
|
- `evolutionEngine/`
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
- `optionsAndSetup.ts`: normalize options, prepare maze/distance map, create NEAT instance.
|
|
39
|
+
- `evolutionLoop.ts`: generation loop, cancellation, stop conditions, telemetry flow.
|
|
40
|
+
- `populationDynamics.ts`: pruning, simplify phase, anti-collapse, dynamic population.
|
|
41
|
+
- `trainingWarmStart.ts`: warm-start + Lamarckian/Baldwinian helpers.
|
|
42
|
+
- `telemetryMetrics.ts`: generation metrics collection/log formatting.
|
|
43
|
+
- `rngAndTiming.ts`, `scratchPools.ts`, `sampling.ts`, etc.: performance + deterministic helpers.
|
|
44
44
|
|
|
45
45
|
### Maze simulation pipeline
|
|
46
46
|
|
|
47
47
|
- `mazeVision.ts`
|
|
48
|
-
|
|
48
|
+
- Builds 6D inputs for the policy network.
|
|
49
49
|
- `mazeMovement.ts`
|
|
50
|
-
|
|
50
|
+
- Simulates one episode with action selection, movement, penalties/rewards, and final run result.
|
|
51
51
|
- `fitness.ts`
|
|
52
|
-
|
|
52
|
+
- Converts simulation outcomes into scalar fitness.
|
|
53
53
|
- `mazeUtils.ts`
|
|
54
|
-
|
|
54
|
+
- Encoding, BFS distance, progress calculations, coordinate utilities.
|
|
55
55
|
|
|
56
56
|
### Visualization and UX
|
|
57
57
|
|
|
58
58
|
- `dashboardManager.ts`
|
|
59
|
-
|
|
59
|
+
- Rich per-generation dashboard with telemetry history, archive of solved mazes, and trend snapshots.
|
|
60
60
|
- `mazeVisualization.ts`
|
|
61
|
-
|
|
61
|
+
- Colorized maze rendering and summary stats.
|
|
62
62
|
- `networkVisualization.ts`
|
|
63
|
-
|
|
63
|
+
- Network topology formatting/inspection.
|
|
64
64
|
- `terminalUtility.ts` / `browserTerminalUtility.ts`
|
|
65
|
-
|
|
65
|
+
- Rendering primitives for Node terminal and browser DOM.
|
|
66
66
|
- `browserLogger.ts`
|
|
67
|
-
|
|
67
|
+
- Browser-target logging utility.
|
|
68
68
|
|
|
69
69
|
### Scenario definitions and adapters
|
|
70
70
|
|
|
71
71
|
- `mazes.ts`
|
|
72
|
-
|
|
72
|
+
- Static mazes (`tiny`, `small`, `medium`, `large`, `minotaur`) plus procedural `MazeGenerator`.
|
|
73
73
|
- `interfaces.ts`
|
|
74
|
-
|
|
74
|
+
- Canonical contracts: run options, telemetry contracts, network/visualization types.
|
|
75
75
|
- `index.ts` and `asciiMaze.ts`
|
|
76
|
-
|
|
76
|
+
- Re-exports for easier imports.
|
|
77
77
|
|
|
78
78
|
### Demo and test entry points
|
|
79
79
|
|
|
80
80
|
- `browser-entry.ts`
|
|
81
|
-
|
|
81
|
+
- Public `start(...)` API for browser demo lifecycle.
|
|
82
82
|
- `index.html`
|
|
83
|
-
|
|
83
|
+
- Simple host page loading `docs/assets/ascii-maze.bundle.js`.
|
|
84
84
|
- `asciiMaze.e2e.test.ts`
|
|
85
|
-
|
|
85
|
+
- Curriculum-style end-to-end evolution in test form.
|
|
86
86
|
- `networkRefinement.ts` and `refineWinner.ts`
|
|
87
|
-
|
|
87
|
+
- Two refinement helpers (class-based and functional style).
|
|
88
88
|
|
|
89
89
|
---
|
|
90
90
|
|
|
@@ -168,15 +168,15 @@ At a high level, `EvolutionEngine.runMazeEvolution` performs:
|
|
|
168
168
|
2. Maze preparation (encoding, start/exit detection, distance map)
|
|
169
169
|
3. NEAT creation and optional warm-start seeding
|
|
170
170
|
4. Generation loop:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
- evaluate population
|
|
172
|
+
- apply adaptive/population dynamics
|
|
173
|
+
- apply optional refinement phases
|
|
174
|
+
- log/update dashboard/telemetry
|
|
175
175
|
5. Stop when one of these occurs:
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
- solved threshold reached
|
|
177
|
+
- stagnation cap hit
|
|
178
|
+
- max generations reached
|
|
179
|
+
- cancellation/abort requested
|
|
180
180
|
|
|
181
181
|
The engine supports deterministic mode, telemetry toggles, persistence intervals, and dynamic population controls.
|
|
182
182
|
|
|
@@ -241,25 +241,25 @@ import { DashboardManager } from './dashboardManager';
|
|
|
241
241
|
import { TerminalUtility } from './terminalUtility';
|
|
242
242
|
|
|
243
243
|
const dashboard = new DashboardManager(
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
TerminalUtility.createTerminalClearer(),
|
|
245
|
+
(...args) => console.log(...args),
|
|
246
246
|
);
|
|
247
247
|
|
|
248
248
|
const result = await EvolutionEngine.runMazeEvolution({
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
249
|
+
mazeConfig: { maze: new MazeGenerator(24, 24).generate() },
|
|
250
|
+
agentSimConfig: { maxSteps: 2000 },
|
|
251
|
+
evolutionAlgorithmConfig: {
|
|
252
|
+
popSize: 40,
|
|
253
|
+
maxGenerations: 100,
|
|
254
|
+
maxStagnantGenerations: 50,
|
|
255
|
+
minProgressToPass: 95,
|
|
256
|
+
allowRecurrent: true,
|
|
257
|
+
},
|
|
258
|
+
reportingConfig: {
|
|
259
|
+
dashboardManager: dashboard,
|
|
260
|
+
logEvery: 1,
|
|
261
|
+
label: 'demo-24x24',
|
|
262
|
+
},
|
|
263
263
|
});
|
|
264
264
|
|
|
265
265
|
console.log(result.exitReason, result.bestResult?.progress);
|
|
@@ -272,17 +272,17 @@ console.log(result.exitReason, result.bestResult?.progress);
|
|
|
272
272
|
If you’re teaching or experimenting, these knobs are typically most impactful first:
|
|
273
273
|
|
|
274
274
|
1. `agentSimConfig.maxSteps`
|
|
275
|
-
|
|
275
|
+
- increase for larger/harder mazes
|
|
276
276
|
2. `evolutionAlgorithmConfig.popSize`
|
|
277
|
-
|
|
277
|
+
- larger population improves search breadth but costs compute
|
|
278
278
|
3. `evolutionAlgorithmConfig.maxGenerations`
|
|
279
|
-
|
|
279
|
+
- higher cap for difficult layouts
|
|
280
280
|
4. `evolutionAlgorithmConfig.minProgressToPass`
|
|
281
|
-
|
|
281
|
+
- solved threshold sensitivity
|
|
282
282
|
5. `lamarckianIterations` and `lamarckianSampleSize`
|
|
283
|
-
|
|
283
|
+
- adjust local supervised-style refinement pressure
|
|
284
284
|
6. `deterministic` + `randomSeed`
|
|
285
|
-
|
|
285
|
+
- reproducibility for educational comparisons
|
|
286
286
|
|
|
287
287
|
Then, for advanced learners:
|
|
288
288
|
|
|
@@ -297,15 +297,15 @@ Then, for advanced learners:
|
|
|
297
297
|
Try these in order:
|
|
298
298
|
|
|
299
299
|
1. **Perception ablation**
|
|
300
|
-
|
|
300
|
+
- Remove one input channel from `MazeVision` and observe learning degradation.
|
|
301
301
|
2. **Reward shaping experiment**
|
|
302
|
-
|
|
302
|
+
- Reduce exploration bonus and track effects on dead-end behavior.
|
|
303
303
|
3. **Curriculum comparison**
|
|
304
|
-
|
|
304
|
+
- Train directly on big mazes vs phased growth with transfer.
|
|
305
305
|
4. **Determinism study**
|
|
306
|
-
|
|
306
|
+
- Fix seed and compare run-to-run variance when toggling certain heuristics.
|
|
307
307
|
5. **Refinement impact**
|
|
308
|
-
|
|
308
|
+
- Compare before/after `NetworkRefinement.refineWinnerWithBackprop` on transfer tasks.
|
|
309
309
|
|
|
310
310
|
---
|
|
311
311
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import Network from '../../../src/architecture/network'; // Correct import for Network
|
|
2
1
|
import { MazeGenerator } from './mazes';
|
|
3
2
|
import { colors } from './colors';
|
|
4
3
|
import { DashboardManager } from './dashboardManager';
|
|
5
4
|
import { TerminalUtility } from './terminalUtility';
|
|
6
5
|
import { IDashboardManager } from './interfaces';
|
|
7
|
-
import {
|
|
8
|
-
|
|
6
|
+
import {
|
|
7
|
+
EvolutionEngine,
|
|
8
|
+
resolveMazeEvolutionPhaseOutcome,
|
|
9
|
+
} from './evolutionEngine';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Forces console output for this test by writing directly to stdout/stderr.
|
|
@@ -30,6 +31,9 @@ const dashboardManagerInstance: IDashboardManager = new DashboardManager(
|
|
|
30
31
|
forceLog,
|
|
31
32
|
);
|
|
32
33
|
|
|
34
|
+
/** Minimum progress required before the curriculum treats a phase as solved. */
|
|
35
|
+
const CURRICULUM_MIN_PROGRESS_TO_PASS = 95;
|
|
36
|
+
|
|
33
37
|
jest.setTimeout(3600000); //
|
|
34
38
|
|
|
35
39
|
/**
|
|
@@ -137,7 +141,7 @@ describe('ASCII Maze Solver using Neuro-Evolution', () => {
|
|
|
137
141
|
popSize: 40,
|
|
138
142
|
autoPauseOnSolve: false,
|
|
139
143
|
maxStagnantGenerations: 50,
|
|
140
|
-
minProgressToPass:
|
|
144
|
+
minProgressToPass: CURRICULUM_MIN_PROGRESS_TO_PASS,
|
|
141
145
|
// hard cap per phase (browser DEFAULT_MAX_GENERATIONS)
|
|
142
146
|
maxGenerations: 100,
|
|
143
147
|
lamarckianIterations: 4,
|
|
@@ -150,11 +154,12 @@ describe('ASCII Maze Solver using Neuro-Evolution', () => {
|
|
|
150
154
|
label: `procedural-curriculum-${dim}x${dim}`,
|
|
151
155
|
},
|
|
152
156
|
});
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
const phaseOutcome = resolveMazeEvolutionPhaseOutcome(
|
|
158
|
+
result,
|
|
159
|
+
proceduralPrevBest,
|
|
160
|
+
CURRICULUM_MIN_PROGRESS_TO_PASS,
|
|
161
|
+
);
|
|
162
|
+
proceduralPrevBest = phaseOutcome.nextBestNetwork;
|
|
158
163
|
|
|
159
164
|
expect(!!result?.bestNetwork).toBe(true);
|
|
160
165
|
});
|