@reicek/neataptic-ts 0.1.21 → 0.1.22
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 +29 -0
- package/.github/agents/docs-scout.agent.md +29 -0
- package/.github/agents/plan-scout.agent.md +29 -0
- package/.github/agents/solid-split.agent.md +138 -0
- package/.github/copilot-instructions.md +103 -0
- package/package.json +6 -3
- package/plans/ES2023 migration +13 -8
- package/plans/Evolution_Training_Interoperability_Contracts.md +1 -1
- 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/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 +101 -223
- package/src/architecture/README.md +57 -185
- package/src/architecture/layer/README.md +38 -38
- package/src/architecture/network/README.md +33 -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/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/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/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 +562 -568
- 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/Trace-20260309T191949.json +24124 -0
- package/test/examples/flappy_bird/browser-entry/README.md +1129 -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 +6 -399
- package/test/examples/flappy_bird/browser-entry/browser-entry.playback.utils.ts +1 -717
- package/test/examples/flappy_bird/browser-entry/browser-entry.spawn.utils.ts +11 -31
- package/test/examples/flappy_bird/browser-entry/browser-entry.visualization.utils.ts +15 -893
- package/test/examples/flappy_bird/browser-entry/host/README.md +307 -0
- package/test/examples/flappy_bird/browser-entry/host/host.resize.service.ts +1 -295
- package/test/examples/flappy_bird/browser-entry/host/host.ts +562 -6
- package/test/examples/flappy_bird/browser-entry/host/resize/README.md +274 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.constants.ts +31 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.services.ts +360 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.ts +117 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types.ts +63 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.utils.ts +250 -0
- package/test/examples/flappy_bird/browser-entry/network-view/README.md +399 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.topology.utils.ts +255 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.ts +802 -7
- package/test/examples/flappy_bird/browser-entry/playback/README.md +684 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/README.md +277 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +770 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.cache.services.ts +178 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.constants.ts +107 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.utils.ts +518 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.math.utils.ts +117 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.utils.ts +233 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.services.ts +211 -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 +212 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.utils.ts +81 -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 +62 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.services.ts +244 -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 +68 -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 +310 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.service.ts +92 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.services.ts +272 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.types.ts +39 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.utils.ts +493 -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 +4 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.snapshot.utils.ts +44 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.service.ts +39 -122
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.services.ts +272 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.types.ts +62 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.utils.ts +11 -4
- package/test/examples/flappy_bird/browser-entry/playback/playback.ts +409 -8
- package/test/examples/flappy_bird/browser-entry/playback/playback.types.ts +4 -12
- package/test/examples/flappy_bird/browser-entry/runtime/README.md +235 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.evolution-launch.service.ts +45 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.lifecycle.service.ts +81 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.startup.service.ts +74 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.ts +31 -121
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.types.ts +36 -0
- package/test/examples/flappy_bird/browser-entry/visualization/README.md +557 -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 +957 -19
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.legend.utils.ts +138 -3
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.topology.utils.ts +3 -27
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.ts +1 -23
- package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +156 -0
- package/test/examples/flappy_bird/constants/README.md +1179 -0
- package/test/examples/flappy_bird/constants/constants.network-view.ts +24 -0
- package/test/examples/flappy_bird/constants/constants.palette.ts +7 -0
- package/test/examples/flappy_bird/constants/constants.starfield.ts +78 -3
- package/test/examples/flappy_bird/environment/README.md +143 -0
- package/test/examples/flappy_bird/environment/environment.observation.utils.ts +1 -19
- package/test/examples/flappy_bird/environment/environment.step.service.ts +3 -66
- package/test/examples/flappy_bird/evaluation/README.md +130 -0
- package/test/examples/flappy_bird/evaluation/evaluation.fitness.utils.ts +1 -1
- package/test/examples/flappy_bird/evaluation/evaluation.rollout.service.ts +5 -375
- package/test/examples/flappy_bird/evaluation/rollout/README.md +291 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.constants.ts +30 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.service.ts +58 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.services.ts +310 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.types.ts +56 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.utils.ts +368 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +618 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.playback.service.ts +7 -7
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.frame.service.ts +364 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.types.ts +14 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.utils.ts +4 -201
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.ts +184 -345
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.warm-start.service.ts +291 -0
- package/test/examples/flappy_bird/flappy.simulation.shared.utils.ts +5 -0
- package/test/examples/flappy_bird/simulation-shared/README.md +417 -0
- package/test/examples/flappy_bird/simulation-shared/observation/README.md +183 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.features.utils.ts +301 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.ts +9 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.vector.utils.ts +59 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.observation.utils.ts +5 -403
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.spawn.utils.ts +20 -6
- package/test/examples/flappy_bird/{evaluation/evaluation.statistics.utils.ts → simulation-shared/simulation-shared.statistics.utils.ts} +23 -8
- package/test/examples/flappy_bird/trainer/README.md +563 -0
- package/test/examples/flappy_bird/trainer/evaluation/README.md +199 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.constants.ts +9 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.services.ts +73 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.ts +165 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.types.ts +25 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.utils.ts +161 -0
- package/test/examples/flappy_bird/trainer/trainer.evaluation.service.ts +13 -0
- package/test/examples/flappy_bird/trainer/trainer.report.service.services.ts +181 -0
- package/test/examples/flappy_bird/trainer/trainer.report.service.ts +126 -0
- package/test/examples/flappy_bird/trainer/trainer.selection.utils.ts +89 -0
- package/test/examples/flappy_bird/trainer/trainer.ts +11 -553
- 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
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
# flappy-evolution-worker
|
|
2
|
+
|
|
3
|
+
## flappy-evolution-worker/flappy-evolution-worker.types.ts
|
|
4
|
+
|
|
5
|
+
### SerializedNetwork
|
|
6
|
+
|
|
7
|
+
Loose JSON-compatible network payload used by worker messages.
|
|
8
|
+
|
|
9
|
+
### WorkerErrorMessage
|
|
10
|
+
|
|
11
|
+
Worker error response message.
|
|
12
|
+
|
|
13
|
+
### WorkerFrameBirdSnapshot
|
|
14
|
+
|
|
15
|
+
Render-only bird snapshot DTO posted to host.
|
|
16
|
+
|
|
17
|
+
### WorkerFramePipeSnapshot
|
|
18
|
+
|
|
19
|
+
Render-only pipe snapshot DTO posted to host.
|
|
20
|
+
|
|
21
|
+
### WorkerGenerationReadyMessage
|
|
22
|
+
|
|
23
|
+
Worker generation-ready response message.
|
|
24
|
+
|
|
25
|
+
### WorkerHeuristicObservationFeatures
|
|
26
|
+
|
|
27
|
+
Structured features used by heuristic generation-0 teacher policy.
|
|
28
|
+
|
|
29
|
+
### WorkerInitMessage
|
|
30
|
+
|
|
31
|
+
Worker init request message.
|
|
32
|
+
|
|
33
|
+
### WorkerPlaybackFrameSnapshot
|
|
34
|
+
|
|
35
|
+
Full frame snapshot payload posted to host.
|
|
36
|
+
|
|
37
|
+
### WorkerPlaybackState
|
|
38
|
+
|
|
39
|
+
Mutable simulation state stored between worker playback requests.
|
|
40
|
+
|
|
41
|
+
### WorkerPlaybackStepMessage
|
|
42
|
+
|
|
43
|
+
Worker playback-step response message.
|
|
44
|
+
|
|
45
|
+
### WorkerPopulationBird
|
|
46
|
+
|
|
47
|
+
Mutable bird state tracked by the worker playback simulation.
|
|
48
|
+
|
|
49
|
+
### WorkerPopulationPipe
|
|
50
|
+
|
|
51
|
+
Mutable pipe state tracked by the worker playback simulation.
|
|
52
|
+
|
|
53
|
+
### WorkerRequestGenerationMessage
|
|
54
|
+
|
|
55
|
+
Worker request asking to evolve one generation.
|
|
56
|
+
|
|
57
|
+
### WorkerRequestMessage
|
|
58
|
+
|
|
59
|
+
Union of inbound worker request messages.
|
|
60
|
+
|
|
61
|
+
### WorkerRequestPlaybackStepMessage
|
|
62
|
+
|
|
63
|
+
Worker request asking to advance playback by N simulation steps.
|
|
64
|
+
|
|
65
|
+
### WorkerResponseMessage
|
|
66
|
+
|
|
67
|
+
Union of outbound worker response messages.
|
|
68
|
+
|
|
69
|
+
### WorkerStartPlaybackMessage
|
|
70
|
+
|
|
71
|
+
Worker request asking to initialize playback state.
|
|
72
|
+
|
|
73
|
+
### WorkerStopMessage
|
|
74
|
+
|
|
75
|
+
Worker stop request message.
|
|
76
|
+
|
|
77
|
+
## flappy-evolution-worker/flappy-evolution-worker.simulation.types.ts
|
|
78
|
+
|
|
79
|
+
### WorkerPlaybackFrameContext
|
|
80
|
+
|
|
81
|
+
Shared mutable inputs for one worker playback frame simulation pass.
|
|
82
|
+
|
|
83
|
+
## flappy-evolution-worker/flappy-evolution-worker.ts
|
|
84
|
+
|
|
85
|
+
### beginWorkerGenerationRequest
|
|
86
|
+
|
|
87
|
+
`(workerMutableRuntimeState: WorkerMutableRuntimeState) => void`
|
|
88
|
+
|
|
89
|
+
Begins one asynchronous generation request and captures failures.
|
|
90
|
+
|
|
91
|
+
Parameters:
|
|
92
|
+
|
|
93
|
+
- `workerMutableRuntimeState` - - Mutable worker runtime state.
|
|
94
|
+
|
|
95
|
+
Returns: Nothing.
|
|
96
|
+
|
|
97
|
+
### beginWorkerInitialization
|
|
98
|
+
|
|
99
|
+
`(workerMutableRuntimeState: WorkerMutableRuntimeState, initPayload: { populationSize: number; elitismCount: number; rngSeed: number; }) => void`
|
|
100
|
+
|
|
101
|
+
Begins worker initialization and captures asynchronous failures.
|
|
102
|
+
|
|
103
|
+
Parameters:
|
|
104
|
+
|
|
105
|
+
- `workerMutableRuntimeState` - - Mutable worker runtime state.
|
|
106
|
+
- `initPayload` - - Initialization payload.
|
|
107
|
+
|
|
108
|
+
Returns: Nothing.
|
|
109
|
+
|
|
110
|
+
### beginWorkerPlayback
|
|
111
|
+
|
|
112
|
+
`(workerMutableRuntimeState: WorkerMutableRuntimeState, payload: { visibleWorldWidthPx: number; visibleWorldHeightPx: number; }) => void`
|
|
113
|
+
|
|
114
|
+
Begins a new playback session from the current evolved population.
|
|
115
|
+
|
|
116
|
+
Parameters:
|
|
117
|
+
|
|
118
|
+
- `workerMutableRuntimeState` - - Mutable worker runtime state.
|
|
119
|
+
- `payload` - - Playback start payload.
|
|
120
|
+
|
|
121
|
+
Returns: Nothing.
|
|
122
|
+
|
|
123
|
+
### createWorkerMessageHandler
|
|
124
|
+
|
|
125
|
+
`(workerMutableRuntimeState: WorkerMutableRuntimeState) => (event: MessageEvent<import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerRequestMessage>) => void`
|
|
126
|
+
|
|
127
|
+
Creates the top-level worker message handler.
|
|
128
|
+
|
|
129
|
+
Parameters:
|
|
130
|
+
|
|
131
|
+
- `workerMutableRuntimeState` - - Mutable worker runtime state.
|
|
132
|
+
|
|
133
|
+
Returns: Worker message handler.
|
|
134
|
+
|
|
135
|
+
### createWorkerMutableRuntimeState
|
|
136
|
+
|
|
137
|
+
`() => WorkerMutableRuntimeState`
|
|
138
|
+
|
|
139
|
+
Creates the mutable worker runtime state container.
|
|
140
|
+
|
|
141
|
+
Returns: Mutable worker runtime state.
|
|
142
|
+
|
|
143
|
+
### createWorkerProtocolHandlers
|
|
144
|
+
|
|
145
|
+
`(workerMutableRuntimeState: WorkerMutableRuntimeState) => { markStopped: () => void; beginInitialization: (payload: { populationSize: number; elitismCount: number; rngSeed: number; }) => void; beginGenerationRequest: () => void; hasPopulation: () => boolean; startPlayback: (payload: { visibleWorldWidthPx: number; visibleWorldHeightPx: number; }) => void; hasPlaybackState: () => boolean; processPlaybackStep: (payload: { simulationSteps: number; visibleWorldWidthPx: number; visibleWorldHeightPx: number; }) => void; postWorkerMessage: typeof postWorkerMessage; }`
|
|
146
|
+
|
|
147
|
+
Creates protocol handlers bound to the mutable worker runtime state.
|
|
148
|
+
|
|
149
|
+
Parameters:
|
|
150
|
+
|
|
151
|
+
- `workerMutableRuntimeState` - - Mutable worker runtime state.
|
|
152
|
+
|
|
153
|
+
Returns: Protocol handler bundle.
|
|
154
|
+
|
|
155
|
+
### evolveAndPublishGeneration
|
|
156
|
+
|
|
157
|
+
`(workerMutableRuntimeState: WorkerMutableRuntimeState) => Promise<void>`
|
|
158
|
+
|
|
159
|
+
Evolves one generation and publishes the best-network summary message.
|
|
160
|
+
|
|
161
|
+
Educational note:
|
|
162
|
+
This method is the orchestration seam between evolutionary search and
|
|
163
|
+
browser rendering: it runs evolution, snapshots the population, and emits
|
|
164
|
+
a compact payload for UI state updates.
|
|
165
|
+
|
|
166
|
+
Returns: Promise resolved after generation payload is posted.
|
|
167
|
+
|
|
168
|
+
### initializeRuntime
|
|
169
|
+
|
|
170
|
+
`(workerMutableRuntimeState: WorkerMutableRuntimeState, initPayload: { populationSize: number; elitismCount: number; rngSeed: number; }) => Promise<void>`
|
|
171
|
+
|
|
172
|
+
Initializes the worker-local NEAT runtime used by browser evolution playback.
|
|
173
|
+
|
|
174
|
+
Educational note:
|
|
175
|
+
The runtime is configured once with deterministic RNG state and a lightweight
|
|
176
|
+
early-termination fitness rollout. Keeping this setup centralized helps ensure
|
|
177
|
+
reproducibility between runs and keeps host<->worker contracts simple.
|
|
178
|
+
|
|
179
|
+
Parameters:
|
|
180
|
+
|
|
181
|
+
- `initPayload` - - Initialization values from the browser host.
|
|
182
|
+
|
|
183
|
+
Returns: Promise resolved when runtime setup is complete.
|
|
184
|
+
|
|
185
|
+
### postWorkerMessage
|
|
186
|
+
|
|
187
|
+
`(workerMessage: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerResponseMessage) => void`
|
|
188
|
+
|
|
189
|
+
Posts a typed message from worker to host.
|
|
190
|
+
|
|
191
|
+
Parameters:
|
|
192
|
+
|
|
193
|
+
- `workerMessage` - - Outbound worker response payload.
|
|
194
|
+
|
|
195
|
+
Returns: Nothing.
|
|
196
|
+
|
|
197
|
+
### processWorkerPlaybackStepRequest
|
|
198
|
+
|
|
199
|
+
`(workerMutableRuntimeState: WorkerMutableRuntimeState, playbackStepPayload: { simulationSteps: number; visibleWorldWidthPx: number; visibleWorldHeightPx: number; }) => void`
|
|
200
|
+
|
|
201
|
+
Advances playback by a host-requested number of simulation steps.
|
|
202
|
+
|
|
203
|
+
Educational note:
|
|
204
|
+
The browser host can request multiple simulation steps per RAF to trade visual
|
|
205
|
+
smoothness against throughput. This function keeps that loop deterministic and
|
|
206
|
+
emits one compact snapshot payload per request.
|
|
207
|
+
|
|
208
|
+
Parameters:
|
|
209
|
+
|
|
210
|
+
- `playbackStepPayload` - - Host-selected simulation-step budget and viewport.
|
|
211
|
+
|
|
212
|
+
Returns: Nothing.
|
|
213
|
+
|
|
214
|
+
## flappy-evolution-worker/flappy-evolution-worker.errors.ts
|
|
215
|
+
|
|
216
|
+
### createWorkerErrorMessage
|
|
217
|
+
|
|
218
|
+
`(message: string) => import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerErrorMessage`
|
|
219
|
+
|
|
220
|
+
Creates a typed worker error response payload from a message string.
|
|
221
|
+
|
|
222
|
+
Parameters:
|
|
223
|
+
|
|
224
|
+
- `message` - - Error message text.
|
|
225
|
+
|
|
226
|
+
Returns: Worker error response message.
|
|
227
|
+
|
|
228
|
+
### createWorkerErrorMessageFromUnknown
|
|
229
|
+
|
|
230
|
+
`(error: unknown) => import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerErrorMessage`
|
|
231
|
+
|
|
232
|
+
Creates a typed worker error response payload from an unknown thrown value.
|
|
233
|
+
|
|
234
|
+
Parameters:
|
|
235
|
+
|
|
236
|
+
- `error` - - Unknown thrown value.
|
|
237
|
+
|
|
238
|
+
Returns: Worker error response message.
|
|
239
|
+
|
|
240
|
+
### FLAPPY_WORKER_INIT_FAILED_ERROR_MESSAGE
|
|
241
|
+
|
|
242
|
+
### FLAPPY_WORKER_PLAYBACK_START_REQUIRES_GENERATION_ERROR_MESSAGE
|
|
243
|
+
|
|
244
|
+
### FLAPPY_WORKER_PLAYBACK_STEP_REQUIRES_START_ERROR_MESSAGE
|
|
245
|
+
|
|
246
|
+
### resolveWorkerUnknownErrorMessage
|
|
247
|
+
|
|
248
|
+
`(error: unknown) => string`
|
|
249
|
+
|
|
250
|
+
Resolves unknown error-like values into display-safe worker error messages.
|
|
251
|
+
|
|
252
|
+
Parameters:
|
|
253
|
+
|
|
254
|
+
- `error` - - Unknown error value thrown by worker logic.
|
|
255
|
+
|
|
256
|
+
Returns: Normalized error message string.
|
|
257
|
+
|
|
258
|
+
## flappy-evolution-worker/flappy-evolution-worker.constants.ts
|
|
259
|
+
|
|
260
|
+
### flappy-evolution-worker.constants
|
|
261
|
+
|
|
262
|
+
Synthetic sample count used for generation-0 warm-start pretraining.
|
|
263
|
+
|
|
264
|
+
### FLAPPY_WORKER_GEN0_PRETRAIN_BATCH_SIZE
|
|
265
|
+
|
|
266
|
+
### FLAPPY_WORKER_GEN0_PRETRAIN_BIAS_NOISE_STDDEV
|
|
267
|
+
|
|
268
|
+
### FLAPPY_WORKER_GEN0_PRETRAIN_ITERATIONS
|
|
269
|
+
|
|
270
|
+
### FLAPPY_WORKER_GEN0_PRETRAIN_RATE
|
|
271
|
+
|
|
272
|
+
### FLAPPY_WORKER_GEN0_PRETRAIN_SAMPLE_COUNT
|
|
273
|
+
|
|
274
|
+
### FLAPPY_WORKER_GEN0_PRETRAIN_VISIBLE_WORLD_WIDTH_PX
|
|
275
|
+
|
|
276
|
+
### FLAPPY_WORKER_GEN0_PRETRAIN_WEIGHT_NOISE_STDDEV
|
|
277
|
+
|
|
278
|
+
## flappy-evolution-worker/flappy-evolution-worker.runtime.service.ts
|
|
279
|
+
|
|
280
|
+
### createInitializedWorkerRuntime
|
|
281
|
+
|
|
282
|
+
`(initPayload: { populationSize: number; elitismCount: number; rngSeed: number; }) => import("src/neat").default`
|
|
283
|
+
|
|
284
|
+
Creates and configures the worker-local NEAT runtime used by browser evolution playback.
|
|
285
|
+
|
|
286
|
+
Parameters:
|
|
287
|
+
|
|
288
|
+
- `initPayload` - - Initialization values from the browser host.
|
|
289
|
+
|
|
290
|
+
Returns: Initialized NEAT runtime.
|
|
291
|
+
|
|
292
|
+
## flappy-evolution-worker/flappy-evolution-worker.playback.service.ts
|
|
293
|
+
|
|
294
|
+
### beginWorkerPlaybackSession
|
|
295
|
+
|
|
296
|
+
`(options: { currentPopulation: import("src/architecture/network").default[]; payload: { visibleWorldWidthPx: number; visibleWorldHeightPx: number; }; createPopulationRenderState: (networks: import("src/architecture/network").default[], rng: import("test/examples/flappy_bird/rng").FlappyRng, initialVisibleWorldWidthPx: number, initialVisibleWorldHeightPx: number) => import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPlaybackState; }) => { currentPlaybackState: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPlaybackState; currentPlaybackRng: import("test/examples/flappy_bird/rng").FlappyRng; playbackWinnerIndex: number; }`
|
|
297
|
+
|
|
298
|
+
Creates a fresh worker playback session state from the current evolved population.
|
|
299
|
+
|
|
300
|
+
Parameters:
|
|
301
|
+
|
|
302
|
+
- `currentPopulation` - - Current evolved population.
|
|
303
|
+
- `payload` - - Playback start viewport payload.
|
|
304
|
+
- `createPopulationRenderState` - - Callback that builds initial simulation state.
|
|
305
|
+
|
|
306
|
+
Returns: Playback runtime state and deterministic RNG.
|
|
307
|
+
|
|
308
|
+
### processWorkerPlaybackStep
|
|
309
|
+
|
|
310
|
+
`(options: { playbackStepPayload: { simulationSteps: number; visibleWorldWidthPx: number; visibleWorldHeightPx: number; }; currentPlaybackState: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPlaybackState; currentPlaybackRng: import("test/examples/flappy_bird/rng").FlappyRng; currentPopulation: import("src/architecture/network").default[]; neatRuntime: import("src/neat").default | undefined; stepPopulationFrame: (renderState: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPlaybackState, rng: import("test/examples/flappy_bird/rng").FlappyRng, difficultyProfile: import("test/examples/flappy_bird/simulation-shared/simulation-shared.types").SharedDifficultyProfile) => number; createPlaybackSnapshot: (playbackState: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPlaybackState) => import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPlaybackFrameSnapshot; postWorkerMessage: (workerMessage: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerResponseMessage) => void; }) => { currentPlaybackState: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPlaybackState | undefined; currentPlaybackRng: import("test/examples/flappy_bird/rng").FlappyRng | undefined; currentPopulation: import("src/architecture/network").default[]; playbackWinnerIndex: number; }`
|
|
311
|
+
|
|
312
|
+
Processes one worker playback-step request including completion/finalization logic.
|
|
313
|
+
|
|
314
|
+
Parameters:
|
|
315
|
+
|
|
316
|
+
- `options` - - Playback step dependencies and mutable runtime state.
|
|
317
|
+
|
|
318
|
+
Returns: Updated playback runtime state after processing this step.
|
|
319
|
+
|
|
320
|
+
## flappy-evolution-worker/flappy-evolution-worker.protocol.service.ts
|
|
321
|
+
|
|
322
|
+
### routeWorkerProtocolMessage
|
|
323
|
+
|
|
324
|
+
`(workerMessage: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerRequestMessage, handlers: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.protocol.service").WorkerProtocolHandlers) => void`
|
|
325
|
+
|
|
326
|
+
Routes one inbound worker request message to the corresponding runtime action.
|
|
327
|
+
|
|
328
|
+
Parameters:
|
|
329
|
+
|
|
330
|
+
- `workerMessage` - - Inbound worker request payload.
|
|
331
|
+
- `handlers` - - Runtime action callbacks and state probes.
|
|
332
|
+
|
|
333
|
+
Returns: Nothing.
|
|
334
|
+
|
|
335
|
+
### WorkerProtocolHandlers
|
|
336
|
+
|
|
337
|
+
Callback bundle used by worker protocol routing.
|
|
338
|
+
|
|
339
|
+
## flappy-evolution-worker/flappy-evolution-worker.evolution.service.ts
|
|
340
|
+
|
|
341
|
+
### evolveAndBuildGenerationReadyMessage
|
|
342
|
+
|
|
343
|
+
`(options: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.evolution.service").WorkerEvolutionServiceOptions) => Promise<import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerGenerationReadyMessage>`
|
|
344
|
+
|
|
345
|
+
Evolves one generation and creates the compact generation-ready response payload.
|
|
346
|
+
|
|
347
|
+
Parameters:
|
|
348
|
+
|
|
349
|
+
- `options` - - Evolution dependencies and runtime state accessors.
|
|
350
|
+
|
|
351
|
+
Returns: Generation-ready worker response payload.
|
|
352
|
+
|
|
353
|
+
### WorkerEvolutionServiceOptions
|
|
354
|
+
|
|
355
|
+
Dependencies required to evolve one generation and prepare host payload output.
|
|
356
|
+
|
|
357
|
+
## flappy-evolution-worker/flappy-evolution-worker.warm-start.service.ts
|
|
358
|
+
|
|
359
|
+
### applyTemplateWeightsWithNoise
|
|
360
|
+
|
|
361
|
+
`(genome: import("src/architecture/network").default, template: import("src/architecture/network").default, rng: import("test/examples/flappy_bird/rng").FlappyRng, noise: { weightStdDev: number; biasStdDev: number; }) => void`
|
|
362
|
+
|
|
363
|
+
Copies template parameters into a genome and injects small Gaussian noise.
|
|
364
|
+
|
|
365
|
+
Parameters:
|
|
366
|
+
|
|
367
|
+
- `genome` - - Target genome to mutate in-place.
|
|
368
|
+
- `template` - - Trained template source network.
|
|
369
|
+
- `rng` - - Deterministic random source for noise sampling.
|
|
370
|
+
- `noise` - - Standard deviations for weight and bias perturbations.
|
|
371
|
+
|
|
372
|
+
Returns: Nothing.
|
|
373
|
+
|
|
374
|
+
### buildHeuristicPretrainSet
|
|
375
|
+
|
|
376
|
+
`(rng: import("test/examples/flappy_bird/rng").FlappyRng, sampleCount: number) => { input: number[]; output: number[]; }[]`
|
|
377
|
+
|
|
378
|
+
Builds synthetic supervised samples for generation-0 behavior cloning.
|
|
379
|
+
|
|
380
|
+
Parameters:
|
|
381
|
+
|
|
382
|
+
- `rng` - - Deterministic random source.
|
|
383
|
+
- `sampleCount` - - Requested number of synthetic samples.
|
|
384
|
+
|
|
385
|
+
Returns: Supervised dataset of input/output pairs.
|
|
386
|
+
|
|
387
|
+
### resolveHeuristicTeacherFlapDecision
|
|
388
|
+
|
|
389
|
+
`(features: import("test/examples/flappy_bird/simulation-shared/simulation-shared.types").SharedObservationFeatures) => boolean`
|
|
390
|
+
|
|
391
|
+
Heuristic teacher policy used to label synthetic pretraining samples.
|
|
392
|
+
|
|
393
|
+
Parameters:
|
|
394
|
+
|
|
395
|
+
- `features` - - Structured observation features for one synthetic state.
|
|
396
|
+
|
|
397
|
+
Returns: True when the teacher says to flap.
|
|
398
|
+
|
|
399
|
+
### sampleGaussian
|
|
400
|
+
|
|
401
|
+
`(rng: import("test/examples/flappy_bird/rng").FlappyRng) => number`
|
|
402
|
+
|
|
403
|
+
Samples one standard-normal value using the Box-Muller transform.
|
|
404
|
+
|
|
405
|
+
Parameters:
|
|
406
|
+
|
|
407
|
+
- `rng` - - Deterministic random source.
|
|
408
|
+
|
|
409
|
+
Returns: One approximately standard-normal random value.
|
|
410
|
+
|
|
411
|
+
### warmStartWorkerGenerationZeroIfNeeded
|
|
412
|
+
|
|
413
|
+
`(neatController: import("src/neat").default, warmStartState: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.warm-start.service").WorkerWarmStartState) => Promise<void>`
|
|
414
|
+
|
|
415
|
+
Applies a one-time generation-0 warm-start to improve initial demo quality.
|
|
416
|
+
|
|
417
|
+
Educational note:
|
|
418
|
+
The worker entry should stay protocol-first. This service owns the short
|
|
419
|
+
supervised bootstrap pass that nudges generation 0 away from pure noise while
|
|
420
|
+
preserving the later NEAT-driven search loop.
|
|
421
|
+
|
|
422
|
+
Parameters:
|
|
423
|
+
|
|
424
|
+
- `neatController` - - Initialized NEAT runtime.
|
|
425
|
+
- `warmStartState` - - Mutable warm-start lifecycle state.
|
|
426
|
+
|
|
427
|
+
Returns: Promise resolved when warm-start evaluation finishes.
|
|
428
|
+
|
|
429
|
+
### WorkerWarmStartState
|
|
430
|
+
|
|
431
|
+
State carried between generation requests for one worker runtime.
|
|
432
|
+
|
|
433
|
+
## flappy-evolution-worker/flappy-evolution-worker.simulation.frame.service.ts
|
|
434
|
+
|
|
435
|
+
### advanceBirdPhysics
|
|
436
|
+
|
|
437
|
+
`(frameContext: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.types").WorkerPlaybackFrameContext) => void`
|
|
438
|
+
|
|
439
|
+
Integrates bird velocity and vertical motion for one control substep.
|
|
440
|
+
|
|
441
|
+
Parameters:
|
|
442
|
+
|
|
443
|
+
- `frameContext` - - Shared frame context for this logical frame.
|
|
444
|
+
|
|
445
|
+
Returns: Nothing.
|
|
446
|
+
|
|
447
|
+
### advancePipes
|
|
448
|
+
|
|
449
|
+
`(frameContext: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.types").WorkerPlaybackFrameContext) => void`
|
|
450
|
+
|
|
451
|
+
Advances all visible pipes and culls those that have left the camera window.
|
|
452
|
+
|
|
453
|
+
Parameters:
|
|
454
|
+
|
|
455
|
+
- `frameContext` - - Shared frame context for this logical frame.
|
|
456
|
+
|
|
457
|
+
Returns: Nothing.
|
|
458
|
+
|
|
459
|
+
### commitPassedPipeProgress
|
|
460
|
+
|
|
461
|
+
`(bird: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPopulationBird, pipe: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPopulationPipe) => void`
|
|
462
|
+
|
|
463
|
+
Commits one passed-pipe progress increment for a bird when eligible.
|
|
464
|
+
|
|
465
|
+
Parameters:
|
|
466
|
+
|
|
467
|
+
- `bird` - - Mutable bird state.
|
|
468
|
+
- `pipe` - - Pipe candidate to mark as passed.
|
|
469
|
+
|
|
470
|
+
Returns: Nothing.
|
|
471
|
+
|
|
472
|
+
### incrementLivingBirdFrameCounters
|
|
473
|
+
|
|
474
|
+
`(renderState: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPlaybackState) => void`
|
|
475
|
+
|
|
476
|
+
Increments survival counters for birds that remain active at frame start.
|
|
477
|
+
|
|
478
|
+
Parameters:
|
|
479
|
+
|
|
480
|
+
- `renderState` - - Mutable playback state.
|
|
481
|
+
|
|
482
|
+
Returns: Nothing.
|
|
483
|
+
|
|
484
|
+
### resolveBirdCollisionAgainstPipe
|
|
485
|
+
|
|
486
|
+
`(bird: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPopulationBird, pipe: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPopulationPipe, frameContext: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.types").WorkerPlaybackFrameContext) => boolean`
|
|
487
|
+
|
|
488
|
+
Resolves whether a bird collides with one pipe corridor during this substep.
|
|
489
|
+
|
|
490
|
+
Parameters:
|
|
491
|
+
|
|
492
|
+
- `bird` - - Mutable bird state.
|
|
493
|
+
- `pipe` - - Pipe candidate to test.
|
|
494
|
+
- `frameContext` - - Shared frame context for this logical frame.
|
|
495
|
+
|
|
496
|
+
Returns: `true` when the bird overlaps the pipe body instead of the gap.
|
|
497
|
+
|
|
498
|
+
### resolveBirdControlActions
|
|
499
|
+
|
|
500
|
+
`(frameContext: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.types").WorkerPlaybackFrameContext) => number`
|
|
501
|
+
|
|
502
|
+
Runs policy evaluation and commits the resulting observation memory updates.
|
|
503
|
+
|
|
504
|
+
Parameters:
|
|
505
|
+
|
|
506
|
+
- `frameContext` - - Shared frame context for this logical frame.
|
|
507
|
+
|
|
508
|
+
Returns: Number of activation calls performed in the substep.
|
|
509
|
+
|
|
510
|
+
### resolveBirdOutOfBounds
|
|
511
|
+
|
|
512
|
+
`(bird: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPopulationBird, visibleWorldHeightPx: number) => boolean`
|
|
513
|
+
|
|
514
|
+
Resolves whether a bird has exceeded the vertical play area.
|
|
515
|
+
|
|
516
|
+
Parameters:
|
|
517
|
+
|
|
518
|
+
- `bird` - - Mutable bird state.
|
|
519
|
+
- `visibleWorldHeightPx` - - Current visible world height.
|
|
520
|
+
|
|
521
|
+
Returns: `true` when the bird is outside the vertical bounds.
|
|
522
|
+
|
|
523
|
+
### resolveBirdTerminationAndProgress
|
|
524
|
+
|
|
525
|
+
`(frameContext: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.types").WorkerPlaybackFrameContext) => void`
|
|
526
|
+
|
|
527
|
+
Resolves bird deaths and passed-pipe progress after motion is applied.
|
|
528
|
+
|
|
529
|
+
Parameters:
|
|
530
|
+
|
|
531
|
+
- `frameContext` - - Shared frame context for this logical frame.
|
|
532
|
+
|
|
533
|
+
Returns: Nothing.
|
|
534
|
+
|
|
535
|
+
### resolveCameraLeftXPx
|
|
536
|
+
|
|
537
|
+
`(visibleWorldWidthPx: number) => number`
|
|
538
|
+
|
|
539
|
+
Resolves the current left-edge of the visible world in world-space pixels.
|
|
540
|
+
|
|
541
|
+
Parameters:
|
|
542
|
+
|
|
543
|
+
- `visibleWorldWidthPx` - - Current visible world width.
|
|
544
|
+
|
|
545
|
+
Returns: Left edge x-position in world coordinates.
|
|
546
|
+
|
|
547
|
+
### runWorkerPopulationControlSubstep
|
|
548
|
+
|
|
549
|
+
`(frameContext: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.types").WorkerPlaybackFrameContext) => number`
|
|
550
|
+
|
|
551
|
+
Advances one control substep of the worker playback simulation.
|
|
552
|
+
|
|
553
|
+
Parameters:
|
|
554
|
+
|
|
555
|
+
- `frameContext` - - Shared frame context for this logical frame.
|
|
556
|
+
|
|
557
|
+
Returns: Number of activation calls performed in the substep.
|
|
558
|
+
|
|
559
|
+
### spawnPipeIfNeeded
|
|
560
|
+
|
|
561
|
+
`(frameContext: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.types").WorkerPlaybackFrameContext) => void`
|
|
562
|
+
|
|
563
|
+
Spawns a new pipe when the substep budget crosses the spawn boundary.
|
|
564
|
+
|
|
565
|
+
Parameters:
|
|
566
|
+
|
|
567
|
+
- `frameContext` - - Shared frame context for this logical frame.
|
|
568
|
+
|
|
569
|
+
Returns: Nothing.
|
|
570
|
+
|
|
571
|
+
### stepWorkerPopulationFrame
|
|
572
|
+
|
|
573
|
+
`(renderState: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPlaybackState, rng: import("test/examples/flappy_bird/browser-entry/browser-entry.simulation.types").RngLike, difficultyProfile: import("test/examples/flappy_bird/simulation-shared/simulation-shared.types").SharedDifficultyProfile) => number`
|
|
574
|
+
|
|
575
|
+
Advances the whole population simulation by one logical frame.
|
|
576
|
+
|
|
577
|
+
Parameters:
|
|
578
|
+
|
|
579
|
+
- `renderState` - - Mutable simulation state.
|
|
580
|
+
- `rng` - - Deterministic random source for spawn variation.
|
|
581
|
+
- `difficultyProfile` - - Active dynamic difficulty profile.
|
|
582
|
+
|
|
583
|
+
Returns: Number of policy activation calls made in this frame.
|
|
584
|
+
|
|
585
|
+
## flappy-evolution-worker/flappy-evolution-worker.snapshot.utils.ts
|
|
586
|
+
|
|
587
|
+
### createWorkerPlaybackSnapshot
|
|
588
|
+
|
|
589
|
+
`(playbackState: import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPlaybackState) => import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPlaybackFrameSnapshot`
|
|
590
|
+
|
|
591
|
+
Creates a serializable snapshot of current playback state.
|
|
592
|
+
|
|
593
|
+
Workers should send only structured-clone-safe payloads. This helper strips
|
|
594
|
+
runtime-only references (e.g., network instances, sets) and keeps only
|
|
595
|
+
renderer-relevant fields.
|
|
596
|
+
|
|
597
|
+
Parameters:
|
|
598
|
+
|
|
599
|
+
- `playbackState` - - Current mutable playback state.
|
|
600
|
+
|
|
601
|
+
Returns: Immutable frame snapshot for the host.
|
|
602
|
+
|
|
603
|
+
## flappy-evolution-worker/flappy-evolution-worker.simulation.utils.ts
|
|
604
|
+
|
|
605
|
+
### createWorkerPopulationRenderState
|
|
606
|
+
|
|
607
|
+
`(networks: import("src/architecture/network").default[], rng: import("test/examples/flappy_bird/browser-entry/browser-entry.simulation.types").RngLike, initialVisibleWorldWidthPx: number, initialVisibleWorldHeightPx: number) => import("test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types").WorkerPlaybackState`
|
|
608
|
+
|
|
609
|
+
Creates initial playback state for a population of networks.
|
|
610
|
+
|
|
611
|
+
Parameters:
|
|
612
|
+
|
|
613
|
+
- `networks` - - Population to visualize.
|
|
614
|
+
- `rng` - - Deterministic random source.
|
|
615
|
+
- `initialVisibleWorldWidthPx` - - Initial viewport width from host.
|
|
616
|
+
- `initialVisibleWorldHeightPx` - - Initial viewport height from host.
|
|
617
|
+
|
|
618
|
+
Returns: Fresh mutable playback state.
|
|
@@ -5,8 +5,11 @@ import {
|
|
|
5
5
|
resolveFramePrimaryWinnerIndex,
|
|
6
6
|
resolveLeaderPipesPassed,
|
|
7
7
|
} from '../browser-entry/browser-entry.observation.utils';
|
|
8
|
-
import { resolveDifficultyProfile } from '../browser-entry/browser-entry.spawn.utils';
|
|
9
8
|
import { FLAPPY_ENABLE_RUNTIME_INSTRUMENTATION } from '../constants/constants';
|
|
9
|
+
import {
|
|
10
|
+
resolveAdaptiveDifficultyProfile,
|
|
11
|
+
type SharedDifficultyProfile,
|
|
12
|
+
} from '../flappy.simulation.shared.utils';
|
|
10
13
|
import type {
|
|
11
14
|
WorkerPlaybackFrameSnapshot,
|
|
12
15
|
WorkerPlaybackState,
|
|
@@ -68,11 +71,7 @@ export function processWorkerPlaybackStep(options: {
|
|
|
68
71
|
stepPopulationFrame: (
|
|
69
72
|
renderState: WorkerPlaybackState,
|
|
70
73
|
rng: ReturnType<typeof createXorshift32>,
|
|
71
|
-
difficultyProfile:
|
|
72
|
-
pipeGapPx: number;
|
|
73
|
-
pipeSpeedPxPerFrame: number;
|
|
74
|
-
pipeSpawnIntervalFrames: number;
|
|
75
|
-
},
|
|
74
|
+
difficultyProfile: SharedDifficultyProfile,
|
|
76
75
|
) => number;
|
|
77
76
|
createPlaybackSnapshot: (
|
|
78
77
|
playbackState: WorkerPlaybackState,
|
|
@@ -112,8 +111,9 @@ export function processWorkerPlaybackStep(options: {
|
|
|
112
111
|
hasAliveBirds(currentPlaybackState.birds);
|
|
113
112
|
simulationStepIndex++
|
|
114
113
|
) {
|
|
115
|
-
const difficultyProfile =
|
|
114
|
+
const difficultyProfile = resolveAdaptiveDifficultyProfile(
|
|
116
115
|
resolveLeaderPipesPassed(currentPlaybackState.birds),
|
|
116
|
+
1,
|
|
117
117
|
);
|
|
118
118
|
totalActivationCalls += stepPopulationFrame(
|
|
119
119
|
currentPlaybackState,
|