@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
|
@@ -1,123 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
visibleWorldHeightPx: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Input used to resolve next playback-step request and budget remainder.
|
|
17
|
-
*/
|
|
18
|
-
export interface ResolvePlaybackStepRequestInput {
|
|
19
|
-
simulationFrameBudget: number;
|
|
20
|
-
visibleWorldWidthPx: number;
|
|
21
|
-
visibleWorldHeightPx: number;
|
|
22
|
-
emulationSpeedMultiplier: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Output for resolved playback-step request and frame-budget remainder.
|
|
27
|
-
*/
|
|
28
|
-
export interface ResolvePlaybackStepRequestResult {
|
|
29
|
-
simulationStepsThisRender: number;
|
|
30
|
-
simulationFrameBudgetRemainder: number;
|
|
31
|
-
playbackStepRequest: PlaybackStepRequest;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Shared alias for worker playback-step payload.
|
|
36
|
-
*/
|
|
37
|
-
export type PlaybackStepPayload = EvolutionPlaybackStepMessage['payload'];
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Resolves step count and request payload for the next worker playback batch.
|
|
41
|
-
*
|
|
42
|
-
* @param input - Current frame budget and viewport dimensions.
|
|
43
|
-
* @returns Request payload plus carried-over fractional frame budget.
|
|
44
|
-
*/
|
|
45
|
-
export function resolvePlaybackStepRequest(
|
|
46
|
-
input: ResolvePlaybackStepRequestInput,
|
|
47
|
-
): ResolvePlaybackStepRequestResult {
|
|
48
|
-
const updatedSimulationFrameBudget =
|
|
49
|
-
input.simulationFrameBudget + input.emulationSpeedMultiplier;
|
|
50
|
-
const simulationStepsThisRender = Math.max(
|
|
51
|
-
1,
|
|
52
|
-
Math.floor(updatedSimulationFrameBudget),
|
|
53
|
-
);
|
|
54
|
-
const simulationFrameBudgetRemainder =
|
|
55
|
-
updatedSimulationFrameBudget - simulationStepsThisRender;
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
simulationStepsThisRender,
|
|
59
|
-
simulationFrameBudgetRemainder,
|
|
60
|
-
playbackStepRequest: {
|
|
61
|
-
simulationSteps: simulationStepsThisRender,
|
|
62
|
-
visibleWorldWidthPx: input.visibleWorldWidthPx,
|
|
63
|
-
visibleWorldHeightPx: input.visibleWorldHeightPx,
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Resolves HUD playback frame stats from worker payload and leader metrics.
|
|
70
|
-
*
|
|
71
|
-
* @param playbackStepPayload - Playback payload returned by worker.
|
|
72
|
-
* @param frameIndex - Current render frame index.
|
|
73
|
-
* @param activeBirdCount - Number of alive birds in current frame.
|
|
74
|
-
* @param leaderPipesPassed - Current frame leader pipes passed.
|
|
75
|
-
* @param leaderFramesSurvived - Current frame leader survived frames.
|
|
76
|
-
* @returns Normalized per-frame HUD telemetry payload.
|
|
77
|
-
*/
|
|
78
|
-
export function resolvePlaybackFrameStats(
|
|
79
|
-
playbackStepPayload: PlaybackStepPayload,
|
|
80
|
-
frameIndex: number,
|
|
81
|
-
activeBirdCount: number,
|
|
82
|
-
leaderPipesPassed: number,
|
|
83
|
-
leaderFramesSurvived: number,
|
|
84
|
-
): PlaybackFrameStats {
|
|
85
|
-
return {
|
|
86
|
-
frameIndex,
|
|
87
|
-
activeBirdCount,
|
|
88
|
-
leaderPipesPassed,
|
|
89
|
-
leaderFramesSurvived,
|
|
90
|
-
activationCallsPerFrame:
|
|
91
|
-
playbackStepPayload.instrumentation?.activationCallsPerFrame ?? 0,
|
|
92
|
-
simulationStepsPerRaf:
|
|
93
|
-
playbackStepPayload.instrumentation?.simulationStepsPerRaf ?? 0,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Resolves final playback summary values when worker reports completion.
|
|
99
|
-
*
|
|
100
|
-
* @param playbackStepPayload - Playback payload returned by worker.
|
|
101
|
-
* @param latestLeaderPipesPassed - Last observed leader pipes passed fallback.
|
|
102
|
-
* @param latestLeaderFramesSurvived - Last observed leader frames fallback.
|
|
103
|
-
* @returns Final aggregate playback summary.
|
|
104
|
-
*/
|
|
105
|
-
export function resolvePlaybackCompletionSummary(
|
|
106
|
-
playbackStepPayload: PlaybackStepPayload,
|
|
107
|
-
latestLeaderPipesPassed: number,
|
|
108
|
-
latestLeaderFramesSurvived: number,
|
|
109
|
-
): {
|
|
110
|
-
averagePipesPassed: number;
|
|
111
|
-
p90FramesSurvived: number;
|
|
112
|
-
winnerPipesPassed: number;
|
|
113
|
-
winnerFramesSurvived: number;
|
|
114
|
-
} {
|
|
115
|
-
return {
|
|
116
|
-
averagePipesPassed: playbackStepPayload.averagePipesPassed ?? 0,
|
|
117
|
-
p90FramesSurvived: playbackStepPayload.p90FramesSurvived ?? 0,
|
|
118
|
-
winnerPipesPassed:
|
|
119
|
-
playbackStepPayload.winnerPipesPassed ?? latestLeaderPipesPassed,
|
|
120
|
-
winnerFramesSurvived:
|
|
121
|
-
playbackStepPayload.winnerFramesSurvived ?? latestLeaderFramesSurvived,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
1
|
+
export type {
|
|
2
|
+
PlaybackStepPayload,
|
|
3
|
+
PlaybackStepRequest,
|
|
4
|
+
ResolvePlaybackStepRequestInput,
|
|
5
|
+
ResolvePlaybackStepRequestResult,
|
|
6
|
+
} from './worker-channel/playback.worker-channel.types';
|
|
7
|
+
export { resolvePlaybackStepRequest } from './worker-channel/playback.worker-channel.request.services';
|
|
8
|
+
export {
|
|
9
|
+
resolvePlaybackCompletionSummary,
|
|
10
|
+
resolvePlaybackFrameStats,
|
|
11
|
+
} from './worker-channel/playback.worker-channel.summary.services';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# browser-entry/playback/snapshot
|
|
2
|
+
|
|
3
|
+
## browser-entry/playback/snapshot/playback.snapshot.services.ts
|
|
4
|
+
|
|
5
|
+
### applyPlaybackSnapshot
|
|
6
|
+
|
|
7
|
+
`(renderState: import("test/examples/flappy_bird/browser-entry/browser-entry.simulation.types").PopulationRenderState, snapshot: import("test/examples/flappy_bird/browser-entry/browser-entry.worker.types").EvolutionPlaybackStepSnapshot) => void`
|
|
8
|
+
|
|
9
|
+
Snapshot synchronization helpers for playback.
|
|
10
|
+
|
|
11
|
+
The worker streams packed typed-array snapshots, while the browser renderer
|
|
12
|
+
wants stable mutable arrays of pipes and birds. This module performs that
|
|
13
|
+
translation in place so playback can stay fast and allocation-light.
|
|
14
|
+
|
|
15
|
+
### syncPlaybackSnapshotBirds
|
|
16
|
+
|
|
17
|
+
`(renderState: import("test/examples/flappy_bird/browser-entry/browser-entry.simulation.types").PopulationRenderState, snapshot: import("test/examples/flappy_bird/browser-entry/browser-entry.worker.types").EvolutionPlaybackStepSnapshot) => void`
|
|
18
|
+
|
|
19
|
+
Synchronizes packed bird snapshot fields into the reusable render-state bird array.
|
|
20
|
+
|
|
21
|
+
This mirrors the pipe strategy: keep a stable array shape when possible and
|
|
22
|
+
update fields in place from the packed worker buffers.
|
|
23
|
+
|
|
24
|
+
Parameters:
|
|
25
|
+
- `renderState` - - Mutable render state mirror used by the browser.
|
|
26
|
+
- `snapshot` - - Packed worker playback snapshot for the current render tick.
|
|
27
|
+
|
|
28
|
+
Returns: Nothing.
|
|
29
|
+
|
|
30
|
+
### syncPlaybackSnapshotPipes
|
|
31
|
+
|
|
32
|
+
`(renderState: import("test/examples/flappy_bird/browser-entry/browser-entry.simulation.types").PopulationRenderState, snapshot: import("test/examples/flappy_bird/browser-entry/browser-entry.worker.types").EvolutionPlaybackStepSnapshot) => void`
|
|
33
|
+
|
|
34
|
+
Synchronizes packed pipe snapshot fields into the reusable render-state pipe array.
|
|
35
|
+
|
|
36
|
+
Instead of recreating pipe objects every frame, the browser grows the array as
|
|
37
|
+
needed and then mutates the existing records in place.
|
|
38
|
+
|
|
39
|
+
Parameters:
|
|
40
|
+
- `renderState` - - Mutable render state mirror used by the browser.
|
|
41
|
+
- `snapshot` - - Packed worker playback snapshot for the current render tick.
|
|
42
|
+
|
|
43
|
+
Returns: Nothing.
|
|
44
|
+
|
|
45
|
+
## browser-entry/playback/snapshot/playback.snapshot.summary.utils.ts
|
|
46
|
+
|
|
47
|
+
### resolveLeaderFramesSurvived
|
|
48
|
+
|
|
49
|
+
`(renderState: import("test/examples/flappy_bird/browser-entry/browser-entry.simulation.types").PopulationRenderState) => number`
|
|
50
|
+
|
|
51
|
+
Small summary helpers derived from hydrated playback render state.
|
|
52
|
+
|
|
53
|
+
Once a packed snapshot has been synchronized into the browser render state,
|
|
54
|
+
these helpers compute simple aggregate values needed by the HUD and playback
|
|
55
|
+
reporting flow.
|
package/test/examples/flappy_bird/browser-entry/playback/snapshot/playback.snapshot.services.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EvolutionPlaybackStepSnapshot,
|
|
3
|
+
PopulationRenderState,
|
|
4
|
+
} from '../../browser-entry.types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Snapshot synchronization helpers for playback.
|
|
8
|
+
*
|
|
9
|
+
* The worker streams packed typed-array snapshots, while the browser renderer
|
|
10
|
+
* wants stable mutable arrays of pipes and birds. This module performs that
|
|
11
|
+
* translation in place so playback can stay fast and allocation-light.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Applies worker snapshot data to the mutable playback render state.
|
|
16
|
+
*
|
|
17
|
+
* This is the top-level hydration step for one frame: copy scalar frame fields,
|
|
18
|
+
* then synchronize packed pipe and bird arrays into reusable browser-side
|
|
19
|
+
* objects.
|
|
20
|
+
*
|
|
21
|
+
* @param renderState - Mutable render state mirror used by the browser.
|
|
22
|
+
* @param snapshot - Worker playback snapshot for the current render tick.
|
|
23
|
+
* @returns Nothing.
|
|
24
|
+
*/
|
|
25
|
+
export function applyPlaybackSnapshot(
|
|
26
|
+
renderState: PopulationRenderState,
|
|
27
|
+
snapshot: EvolutionPlaybackStepSnapshot,
|
|
28
|
+
): void {
|
|
29
|
+
renderState.frameIndex = snapshot.frameIndex;
|
|
30
|
+
renderState.cumulativePipeTravelPx = snapshot.cumulativePipeTravelPx;
|
|
31
|
+
renderState.visibleWorldWidthPx = snapshot.visibleWorldWidthPx;
|
|
32
|
+
renderState.visibleWorldHeightPx = snapshot.visibleWorldHeightPx;
|
|
33
|
+
syncPlaybackSnapshotPipes(renderState, snapshot);
|
|
34
|
+
syncPlaybackSnapshotBirds(renderState, snapshot);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Synchronizes packed pipe snapshot fields into the reusable render-state pipe array.
|
|
39
|
+
*
|
|
40
|
+
* Instead of recreating pipe objects every frame, the browser grows the array as
|
|
41
|
+
* needed and then mutates the existing records in place.
|
|
42
|
+
*
|
|
43
|
+
* @param renderState - Mutable render state mirror used by the browser.
|
|
44
|
+
* @param snapshot - Packed worker playback snapshot for the current render tick.
|
|
45
|
+
* @returns Nothing.
|
|
46
|
+
*/
|
|
47
|
+
function syncPlaybackSnapshotPipes(
|
|
48
|
+
renderState: PopulationRenderState,
|
|
49
|
+
snapshot: EvolutionPlaybackStepSnapshot,
|
|
50
|
+
): void {
|
|
51
|
+
const targetPipeCount = snapshot.pipeCount;
|
|
52
|
+
while (renderState.pipes.length < targetPipeCount) {
|
|
53
|
+
renderState.pipes.push({
|
|
54
|
+
id: 0,
|
|
55
|
+
xPx: 0,
|
|
56
|
+
gapCenterYPx: 0,
|
|
57
|
+
gapSizePx: 0,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
renderState.pipes.length = targetPipeCount;
|
|
62
|
+
for (let pipeIndex = 0; pipeIndex < targetPipeCount; pipeIndex += 1) {
|
|
63
|
+
const pipe = renderState.pipes[pipeIndex];
|
|
64
|
+
pipe.id = pipeIndex;
|
|
65
|
+
pipe.xPx = snapshot.pipes.xPositionsPx[pipeIndex] ?? 0;
|
|
66
|
+
pipe.gapCenterYPx = snapshot.pipes.gapCenterYPositionsPx[pipeIndex] ?? 0;
|
|
67
|
+
pipe.gapSizePx = snapshot.pipes.gapSizesPx[pipeIndex] ?? 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Synchronizes packed bird snapshot fields into the reusable render-state bird array.
|
|
73
|
+
*
|
|
74
|
+
* This mirrors the pipe strategy: keep a stable array shape when possible and
|
|
75
|
+
* update fields in place from the packed worker buffers.
|
|
76
|
+
*
|
|
77
|
+
* @param renderState - Mutable render state mirror used by the browser.
|
|
78
|
+
* @param snapshot - Packed worker playback snapshot for the current render tick.
|
|
79
|
+
* @returns Nothing.
|
|
80
|
+
*/
|
|
81
|
+
function syncPlaybackSnapshotBirds(
|
|
82
|
+
renderState: PopulationRenderState,
|
|
83
|
+
snapshot: EvolutionPlaybackStepSnapshot,
|
|
84
|
+
): void {
|
|
85
|
+
const targetBirdCount = snapshot.birdCount;
|
|
86
|
+
while (renderState.birds.length < targetBirdCount) {
|
|
87
|
+
renderState.birds.push({
|
|
88
|
+
yPx: 0,
|
|
89
|
+
pipesPassed: 0,
|
|
90
|
+
framesSurvived: 0,
|
|
91
|
+
done: false,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
renderState.birds.length = targetBirdCount;
|
|
96
|
+
for (let birdIndex = 0; birdIndex < targetBirdCount; birdIndex += 1) {
|
|
97
|
+
const bird = renderState.birds[birdIndex];
|
|
98
|
+
bird.yPx = snapshot.birds.yPositionsPx[birdIndex] ?? 0;
|
|
99
|
+
bird.pipesPassed = snapshot.birds.pipesPassed[birdIndex] ?? 0;
|
|
100
|
+
bird.framesSurvived = snapshot.birds.framesSurvived[birdIndex] ?? 0;
|
|
101
|
+
bird.done = (snapshot.birds.doneFlags[birdIndex] ?? 0) === 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { PopulationRenderState } from '../../browser-entry.types';
|
|
2
|
+
import { resolveLeaderFramesSurvived } from './playback.snapshot.summary.utils';
|
|
3
|
+
|
|
4
|
+
describe('resolveLeaderFramesSurvived', () => {
|
|
5
|
+
it('returns the maximum survived-frame count across all birds', () => {
|
|
6
|
+
const renderState = createRenderState();
|
|
7
|
+
|
|
8
|
+
expect(resolveLeaderFramesSurvived(renderState)).toBe(17);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
function createRenderState(): PopulationRenderState {
|
|
13
|
+
return {
|
|
14
|
+
frameIndex: 0,
|
|
15
|
+
cumulativePipeTravelPx: 0,
|
|
16
|
+
visibleWorldWidthPx: 1,
|
|
17
|
+
visibleWorldHeightPx: 1,
|
|
18
|
+
nextPipeId: 0,
|
|
19
|
+
lastSpawnedPipeGapPx: 0,
|
|
20
|
+
lastSpawnedPipeGapCenterYPx: 0,
|
|
21
|
+
lastSpawnedPipeSpawnIntervalFrames: 0,
|
|
22
|
+
framesUntilNextPipeSpawn: 0,
|
|
23
|
+
pipes: [],
|
|
24
|
+
birds: [
|
|
25
|
+
{
|
|
26
|
+
yPx: 10,
|
|
27
|
+
pipesPassed: 1,
|
|
28
|
+
framesSurvived: 4,
|
|
29
|
+
done: false,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
yPx: 20,
|
|
33
|
+
pipesPassed: 2,
|
|
34
|
+
framesSurvived: 17,
|
|
35
|
+
done: true,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
yPx: 30,
|
|
39
|
+
pipesPassed: 0,
|
|
40
|
+
framesSurvived: 9,
|
|
41
|
+
done: false,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
package/test/examples/flappy_bird/browser-entry/playback/snapshot/playback.snapshot.summary.utils.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PopulationRenderState } from '../../browser-entry.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Small summary helpers derived from hydrated playback render state.
|
|
5
|
+
*
|
|
6
|
+
* Once a packed snapshot has been synchronized into the browser render state,
|
|
7
|
+
* these helpers compute simple aggregate values needed by the HUD and playback
|
|
8
|
+
* reporting flow.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Resolves the maximum survived-frame count in the current render state.
|
|
13
|
+
*
|
|
14
|
+
* This is the "leader frames survived" view of the current frame: the best raw
|
|
15
|
+
* frame count among all birds currently represented in the render state.
|
|
16
|
+
*
|
|
17
|
+
* @param renderState - Current render state.
|
|
18
|
+
* @returns Maximum frames survived by any bird.
|
|
19
|
+
*/
|
|
20
|
+
export function resolveLeaderFramesSurvived(
|
|
21
|
+
renderState: PopulationRenderState,
|
|
22
|
+
): number {
|
|
23
|
+
return renderState.birds.reduce(
|
|
24
|
+
(maximumFramesSurvived, bird) =>
|
|
25
|
+
Math.max(maximumFramesSurvived, bird.framesSurvived),
|
|
26
|
+
0,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# browser-entry/playback/trail
|
|
2
|
+
|
|
3
|
+
## browser-entry/playback/trail/playback.trail.history.services.ts
|
|
4
|
+
|
|
5
|
+
### pushChampionTrailPoint
|
|
6
|
+
|
|
7
|
+
`(trailPoints: import("test/examples/flappy_bird/browser-entry/browser-entry.simulation.types").TrailPoint[], frameIndex: number, yPosition: number) => void`
|
|
8
|
+
|
|
9
|
+
Appends one point to the champion-only short trail history.
|
|
10
|
+
|
|
11
|
+
The browser highlights the current leader with a shorter, denser trail than
|
|
12
|
+
the rest of the flock. Using a dedicated helper keeps that policy explicit in
|
|
13
|
+
the call site instead of scattering champion-specific retention numbers
|
|
14
|
+
through the playback renderer.
|
|
15
|
+
|
|
16
|
+
Parameters:
|
|
17
|
+
- `trailPoints` - - Mutable champion trail collection.
|
|
18
|
+
- `frameIndex` - - Source frame index.
|
|
19
|
+
- `yPosition` - - Bird y position.
|
|
20
|
+
|
|
21
|
+
Returns: Nothing.
|
|
22
|
+
|
|
23
|
+
### pushTrailPoint
|
|
24
|
+
|
|
25
|
+
`(trailPoints: import("test/examples/flappy_bird/browser-entry/browser-entry.simulation.types").TrailPoint[], frameIndex: number, yPosition: number, maxRetainedPoints: number) => void`
|
|
26
|
+
|
|
27
|
+
Appends one trail point while enforcing the maximum retained history length.
|
|
28
|
+
|
|
29
|
+
Playback trails are intentionally modeled as short rolling histories rather
|
|
30
|
+
than unbounded path logs. That keeps the neon afterimage readable, prevents
|
|
31
|
+
old turns from dominating the current frame, and avoids per-frame growth in a
|
|
32
|
+
long-running browser session.
|
|
33
|
+
|
|
34
|
+
Parameters:
|
|
35
|
+
- `trailPoints` - - Mutable trail collection.
|
|
36
|
+
- `frameIndex` - - Source frame index.
|
|
37
|
+
- `yPosition` - - Bird y position.
|
|
38
|
+
- `maxRetainedPoints` - - Optional maximum retained trail history length.
|
|
39
|
+
|
|
40
|
+
Returns: Nothing.
|
|
41
|
+
|
|
42
|
+
## browser-entry/playback/trail/playback.trail.opacity.utils.ts
|
|
43
|
+
|
|
44
|
+
### clamp01
|
|
45
|
+
|
|
46
|
+
`(value: number) => number`
|
|
47
|
+
|
|
48
|
+
Clamps a number to the inclusive [0, 1] range.
|
|
49
|
+
|
|
50
|
+
The trail renderer combines several normalized fade factors, so keeping this
|
|
51
|
+
utility local to the module makes the intent obvious: every opacity channel
|
|
52
|
+
must remain safe for direct canvas alpha use.
|
|
53
|
+
|
|
54
|
+
Parameters:
|
|
55
|
+
- `value` - - Candidate value.
|
|
56
|
+
|
|
57
|
+
Returns: Clamped value.
|
|
58
|
+
|
|
59
|
+
### resolveEdgeOpacityFactor
|
|
60
|
+
|
|
61
|
+
`(pointXPx: number, pointYPx: number, edgeBounds: import("test/examples/flappy_bird/browser-entry/playback/playback.types").PlaybackEdgeBounds) => number`
|
|
62
|
+
|
|
63
|
+
Converts distance-to-edge into a normalized opacity factor.
|
|
64
|
+
|
|
65
|
+
Trail points fade as they approach the viewport border so the rendered path
|
|
66
|
+
feels cropped by the camera instead of abruptly chopped off. This mirrors the
|
|
67
|
+
common animation principle of easing visual intensity near a frame boundary.
|
|
68
|
+
|
|
69
|
+
Returns 0 exactly on or beyond an edge and rises to 1 once distance exceeds
|
|
70
|
+
the configured fade band.
|
|
71
|
+
|
|
72
|
+
Parameters:
|
|
73
|
+
- `pointXPx` - - Point x position.
|
|
74
|
+
- `pointYPx` - - Point y position.
|
|
75
|
+
- `edgeBounds` - - Visible world bounds used for edge distance checks.
|
|
76
|
+
|
|
77
|
+
Returns: Opacity multiplier in [0, 1].
|
|
78
|
+
|
|
79
|
+
### resolveTrailLifetimeOpacityFactor
|
|
80
|
+
|
|
81
|
+
`(frameOffset: number, maxTrailFrameOffset: number) => number`
|
|
82
|
+
|
|
83
|
+
Converts trail age into a normalized opacity factor.
|
|
84
|
+
|
|
85
|
+
This helper implements the other half of the afterimage effect: recent trail
|
|
86
|
+
samples should read as energetic and bright, while older samples should fade
|
|
87
|
+
away smoothly so the viewer's eye stays anchored to the current flock motion.
|
|
88
|
+
|
|
89
|
+
Oldest retained history approaches 0 opacity; newest approaches 1.
|
|
90
|
+
|
|
91
|
+
Parameters:
|
|
92
|
+
- `frameOffset` - - Frames between this point and newest trail point.
|
|
93
|
+
- `maxTrailFrameOffset` - - Oldest age offset currently retained by trail.
|
|
94
|
+
|
|
95
|
+
Returns: Opacity multiplier in [0, 1].
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TrailPoint } from '../../browser-entry.types';
|
|
2
|
+
import {
|
|
3
|
+
pushChampionTrailPoint,
|
|
4
|
+
pushTrailPoint,
|
|
5
|
+
} from './playback.trail.history.services';
|
|
6
|
+
|
|
7
|
+
describe('pushTrailPoint', () => {
|
|
8
|
+
it('trims the oldest points when the trail exceeds the retained maximum', () => {
|
|
9
|
+
const trailPoints = createTrailPoints();
|
|
10
|
+
|
|
11
|
+
pushTrailPoint(trailPoints, 3, 30, 2);
|
|
12
|
+
|
|
13
|
+
expect(trailPoints).toEqual([
|
|
14
|
+
{ frameIndex: 2, yPx: 20 },
|
|
15
|
+
{ frameIndex: 3, yPx: 30 },
|
|
16
|
+
]);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('pushChampionTrailPoint', () => {
|
|
21
|
+
it('appends the latest champion point to the trail history', () => {
|
|
22
|
+
const trailPoints: TrailPoint[] = [];
|
|
23
|
+
|
|
24
|
+
pushChampionTrailPoint(trailPoints, 7, 42);
|
|
25
|
+
|
|
26
|
+
expect(trailPoints.at(-1)).toEqual({ frameIndex: 7, yPx: 42 });
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
function createTrailPoints(): TrailPoint[] {
|
|
31
|
+
return [
|
|
32
|
+
{ frameIndex: 1, yPx: 10 },
|
|
33
|
+
{ frameIndex: 2, yPx: 20 },
|
|
34
|
+
];
|
|
35
|
+
}
|
package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.history.services.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FLAPPY_CHAMPION_TRAIL_MAX_POINTS,
|
|
3
|
+
FLAPPY_TRAIL_MAX_POINTS,
|
|
4
|
+
} from '../../../constants/constants';
|
|
5
|
+
import type { TrailPoint } from '../../browser-entry.types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Appends one trail point while enforcing the maximum retained history length.
|
|
9
|
+
*
|
|
10
|
+
* Playback trails are intentionally modeled as short rolling histories rather
|
|
11
|
+
* than unbounded path logs. That keeps the neon afterimage readable, prevents
|
|
12
|
+
* old turns from dominating the current frame, and avoids per-frame growth in a
|
|
13
|
+
* long-running browser session.
|
|
14
|
+
*
|
|
15
|
+
* @param trailPoints - Mutable trail collection.
|
|
16
|
+
* @param frameIndex - Source frame index.
|
|
17
|
+
* @param yPosition - Bird y position.
|
|
18
|
+
* @param maxRetainedPoints - Optional maximum retained trail history length.
|
|
19
|
+
* @returns Nothing.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const trailPoints = [{ frameIndex: 10, yPx: 140 }];
|
|
24
|
+
* pushTrailPoint(trailPoints, 11, 136, 2);
|
|
25
|
+
* // trailPoints now contains the two newest samples only.
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function pushTrailPoint(
|
|
29
|
+
trailPoints: TrailPoint[],
|
|
30
|
+
frameIndex: number,
|
|
31
|
+
yPosition: number,
|
|
32
|
+
maxRetainedPoints: number = FLAPPY_TRAIL_MAX_POINTS,
|
|
33
|
+
): void {
|
|
34
|
+
trailPoints.push({ frameIndex, yPx: yPosition });
|
|
35
|
+
if (trailPoints.length > maxRetainedPoints) {
|
|
36
|
+
trailPoints.splice(0, trailPoints.length - maxRetainedPoints);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Appends one point to the champion-only short trail history.
|
|
42
|
+
*
|
|
43
|
+
* The browser highlights the current leader with a shorter, denser trail than
|
|
44
|
+
* the rest of the flock. Using a dedicated helper keeps that policy explicit in
|
|
45
|
+
* the call site instead of scattering champion-specific retention numbers
|
|
46
|
+
* through the playback renderer.
|
|
47
|
+
*
|
|
48
|
+
* @param trailPoints - Mutable champion trail collection.
|
|
49
|
+
* @param frameIndex - Source frame index.
|
|
50
|
+
* @param yPosition - Bird y position.
|
|
51
|
+
* @returns Nothing.
|
|
52
|
+
*/
|
|
53
|
+
export function pushChampionTrailPoint(
|
|
54
|
+
trailPoints: TrailPoint[],
|
|
55
|
+
frameIndex: number,
|
|
56
|
+
yPosition: number,
|
|
57
|
+
): void {
|
|
58
|
+
pushTrailPoint(
|
|
59
|
+
trailPoints,
|
|
60
|
+
frameIndex,
|
|
61
|
+
yPosition,
|
|
62
|
+
FLAPPY_CHAMPION_TRAIL_MAX_POINTS,
|
|
63
|
+
);
|
|
64
|
+
}
|
package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.opacity.utils.test.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PlaybackEdgeBounds } from '../playback.types';
|
|
2
|
+
import {
|
|
3
|
+
clamp01,
|
|
4
|
+
resolveEdgeOpacityFactor,
|
|
5
|
+
resolveTrailLifetimeOpacityFactor,
|
|
6
|
+
} from './playback.trail.opacity.utils';
|
|
7
|
+
|
|
8
|
+
describe('resolveEdgeOpacityFactor', () => {
|
|
9
|
+
it('returns full opacity when the point is safely inside the fade band', () => {
|
|
10
|
+
expect(resolveEdgeOpacityFactor(100, 100, createEdgeBounds())).toBe(1);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('returns zero opacity when the point is on the edge', () => {
|
|
14
|
+
expect(resolveEdgeOpacityFactor(0, 100, createEdgeBounds())).toBe(0);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('resolveTrailLifetimeOpacityFactor', () => {
|
|
19
|
+
it('returns half opacity for a midpoint trail age', () => {
|
|
20
|
+
expect(resolveTrailLifetimeOpacityFactor(5, 10)).toBe(0.5);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('clamp01', () => {
|
|
25
|
+
it('caps values above one to the upper bound', () => {
|
|
26
|
+
expect(clamp01(2)).toBe(1);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
function createEdgeBounds(): PlaybackEdgeBounds {
|
|
31
|
+
return {
|
|
32
|
+
leftXPx: 0,
|
|
33
|
+
rightXPx: 200,
|
|
34
|
+
topYPx: 0,
|
|
35
|
+
bottomYPx: 200,
|
|
36
|
+
};
|
|
37
|
+
}
|
package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.opacity.utils.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { FLAPPY_TRAIL_EDGE_FADE_DISTANCE_PX } from '../../../constants/constants';
|
|
2
|
+
import type { PlaybackEdgeBounds } from '../playback.types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Converts distance-to-edge into a normalized opacity factor.
|
|
6
|
+
*
|
|
7
|
+
* Trail points fade as they approach the viewport border so the rendered path
|
|
8
|
+
* feels cropped by the camera instead of abruptly chopped off. This mirrors the
|
|
9
|
+
* common animation principle of easing visual intensity near a frame boundary.
|
|
10
|
+
*
|
|
11
|
+
* Returns 0 exactly on or beyond an edge and rises to 1 once distance exceeds
|
|
12
|
+
* the configured fade band.
|
|
13
|
+
*
|
|
14
|
+
* @param pointXPx - Point x position.
|
|
15
|
+
* @param pointYPx - Point y position.
|
|
16
|
+
* @param edgeBounds - Visible world bounds used for edge distance checks.
|
|
17
|
+
* @returns Opacity multiplier in [0, 1].
|
|
18
|
+
*/
|
|
19
|
+
export function resolveEdgeOpacityFactor(
|
|
20
|
+
pointXPx: number,
|
|
21
|
+
pointYPx: number,
|
|
22
|
+
edgeBounds: PlaybackEdgeBounds,
|
|
23
|
+
): number {
|
|
24
|
+
const distanceToLeftEdgePx = pointXPx - edgeBounds.leftXPx;
|
|
25
|
+
const distanceToRightEdgePx = edgeBounds.rightXPx - pointXPx;
|
|
26
|
+
const distanceToTopEdgePx = pointYPx - edgeBounds.topYPx;
|
|
27
|
+
const distanceToBottomEdgePx = edgeBounds.bottomYPx - pointYPx;
|
|
28
|
+
|
|
29
|
+
const nearestEdgeDistancePx = Math.min(
|
|
30
|
+
distanceToLeftEdgePx,
|
|
31
|
+
distanceToRightEdgePx,
|
|
32
|
+
distanceToTopEdgePx,
|
|
33
|
+
distanceToBottomEdgePx,
|
|
34
|
+
);
|
|
35
|
+
const fadeProgress =
|
|
36
|
+
nearestEdgeDistancePx / FLAPPY_TRAIL_EDGE_FADE_DISTANCE_PX;
|
|
37
|
+
return clamp01(fadeProgress);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Converts trail age into a normalized opacity factor.
|
|
42
|
+
*
|
|
43
|
+
* This helper implements the other half of the afterimage effect: recent trail
|
|
44
|
+
* samples should read as energetic and bright, while older samples should fade
|
|
45
|
+
* away smoothly so the viewer's eye stays anchored to the current flock motion.
|
|
46
|
+
*
|
|
47
|
+
* Oldest retained history approaches 0 opacity; newest approaches 1.
|
|
48
|
+
*
|
|
49
|
+
* @param frameOffset - Frames between this point and newest trail point.
|
|
50
|
+
* @param maxTrailFrameOffset - Oldest age offset currently retained by trail.
|
|
51
|
+
* @returns Opacity multiplier in [0, 1].
|
|
52
|
+
*/
|
|
53
|
+
export function resolveTrailLifetimeOpacityFactor(
|
|
54
|
+
frameOffset: number,
|
|
55
|
+
maxTrailFrameOffset: number,
|
|
56
|
+
): number {
|
|
57
|
+
const normalizedLifetimeProgress =
|
|
58
|
+
1 - frameOffset / Math.max(1, maxTrailFrameOffset);
|
|
59
|
+
return clamp01(normalizedLifetimeProgress);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Clamps a number to the inclusive [0, 1] range.
|
|
64
|
+
*
|
|
65
|
+
* The trail renderer combines several normalized fade factors, so keeping this
|
|
66
|
+
* utility local to the module makes the intent obvious: every opacity channel
|
|
67
|
+
* must remain safe for direct canvas alpha use.
|
|
68
|
+
*
|
|
69
|
+
* @param value - Candidate value.
|
|
70
|
+
* @returns Clamped value.
|
|
71
|
+
*/
|
|
72
|
+
export function clamp01(value: number): number {
|
|
73
|
+
return Math.max(0, Math.min(1, value));
|
|
74
|
+
}
|