@almadar/std 16.173.0 → 16.174.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/behaviors/lolo/infra/atoms/std-cross-reference.lolo +2 -4
  2. package/behaviors/lolo/ui/core/atoms/std-board.lolo +5 -9
  3. package/behaviors/lolo/ui/core/atoms/std-browse.lolo +8 -1
  4. package/behaviors/lolo/ui/core/atoms/std-esign-flow.lolo +2 -2
  5. package/behaviors/lolo/ui/core/atoms/std-event-log.lolo +3 -7
  6. package/behaviors/lolo/ui/core/atoms/std-form-advanced.lolo +1 -1
  7. package/behaviors/lolo/ui/core/atoms/std-image-upload-multi.lolo +1 -1
  8. package/behaviors/lolo/ui/core/atoms/std-list.lolo +3 -3
  9. package/behaviors/lolo/ui/core/atoms/std-modal.lolo +2 -2
  10. package/behaviors/lolo/ui/core/atoms/std-multi-party-flow.lolo +2 -4
  11. package/behaviors/lolo/ui/core/atoms/std-rating-review.lolo +5 -13
  12. package/behaviors/lolo/ui/core/atoms/std-recurrence.lolo +3 -7
  13. package/behaviors/lolo/ui/core/atoms/std-saved-search.lolo +1 -1
  14. package/behaviors/lolo/ui/core/atoms/std-signature-capture.lolo +2 -2
  15. package/behaviors/lolo/ui/core/atoms/std-step-flow.lolo +2 -4
  16. package/behaviors/lolo/ui/core/atoms/std-tag-taxonomy.lolo +1 -1
  17. package/behaviors/lolo/ui/core/atoms/std-thread.lolo +2 -2
  18. package/behaviors/lolo/ui/core/atoms/std-vote.lolo +2 -2
  19. package/behaviors/lolo/ui/core/atoms/std-wizard.lolo +3 -7
  20. package/behaviors/lolo/ui/core/atoms/ui-atlas-image.lolo +1 -1
  21. package/behaviors/lolo/ui/core/atoms/ui-atlas-panel.lolo +1 -1
  22. package/behaviors/lolo/ui/core/atoms/ui-center.lolo +1 -1
  23. package/behaviors/lolo/ui/core/atoms/ui-hstack.lolo +1 -1
  24. package/behaviors/lolo/ui/core/atoms/ui-icon.lolo +1 -1
  25. package/behaviors/lolo/ui/core/atoms/ui-stack.lolo +1 -1
  26. package/behaviors/lolo/ui/core/atoms/ui-typography.lolo +1 -1
  27. package/behaviors/lolo/ui/core/atoms/ui-vstack.lolo +1 -1
  28. package/behaviors/lolo/ui/core/molecules/ui-content-renderer.lolo +1 -1
  29. package/behaviors/lolo/ui/core/molecules/ui-form-layout.lolo +1 -1
  30. package/behaviors/lolo/ui/core/molecules/ui-grid.lolo +1 -1
  31. package/behaviors/lolo/ui/core/organisms/ui-chat-bar.lolo +1 -1
  32. package/behaviors/lolo/ui/core/organisms/ui-dashboard-grid.lolo +1 -1
  33. package/behaviors/lolo/ui/core/organisms/ui-detail-panel.lolo +1 -1
  34. package/behaviors/lolo/ui/core/organisms/ui-entity-cards.lolo +1 -1
  35. package/behaviors/lolo/ui/core/organisms/ui-entity-list.lolo +1 -1
  36. package/behaviors/lolo/ui/core/organisms/ui-entity-table.lolo +1 -1
  37. package/behaviors/lolo/ui/core/organisms/ui-form-section.lolo +9 -3
  38. package/behaviors/lolo/ui/core/organisms/ui-form.lolo +9 -3
  39. package/behaviors/lolo/ui/core/organisms/ui-master-detail.lolo +1 -1
  40. package/behaviors/lolo/ui/core/organisms/ui-media-gallery.lolo +1 -1
  41. package/behaviors/lolo/ui/core/organisms/ui-segment-renderer.lolo +7 -1
  42. package/behaviors/lolo/ui/core/organisms/ui-stat-card.lolo +1 -1
  43. package/behaviors/lolo/ui/core/organisms/ui-subagent-trace-panel.lolo +1 -1
  44. package/behaviors/lolo/ui/game/atoms/ui-action-tile.lolo +1 -1
  45. package/behaviors/lolo/ui/game/atoms/ui-draw-shape-layer.lolo +41 -9
  46. package/behaviors/lolo/ui/game/atoms/ui-draw-shape.lolo +40 -8
  47. package/behaviors/lolo/ui/game/atoms/ui-draw-sprite-layer.lolo +13 -3
  48. package/behaviors/lolo/ui/game/atoms/ui-draw-sprite.lolo +12 -2
  49. package/behaviors/lolo/ui/game/atoms/ui-draw-text-layer.lolo +3 -3
  50. package/behaviors/lolo/ui/game/atoms/ui-draw-text.lolo +2 -2
  51. package/behaviors/lolo/ui/game/organisms/std-tactics-board-3d.lolo +32 -2
  52. package/behaviors/lolo/ui/learning/atoms/std-learn-classify.lolo +1 -1
  53. package/behaviors/lolo/ui/learning/atoms/std-learn-compare.lolo +397 -0
  54. package/behaviors/lolo/ui/learning/atoms/std-learn-coupled-sim.lolo +537 -0
  55. package/behaviors/lolo/ui/learning/atoms/std-learn-estimate.lolo +419 -0
  56. package/behaviors/lolo/ui/learning/atoms/std-learn-goal-seek.lolo +591 -0
  57. package/behaviors/lolo/ui/learning/atoms/std-learn-grid-sim.lolo +425 -0
  58. package/behaviors/lolo/ui/learning/atoms/std-learn-hotspot.lolo +398 -0
  59. package/behaviors/lolo/ui/learning/atoms/std-learn-measure.lolo +325 -0
  60. package/behaviors/lolo/ui/learning/atoms/std-learn-perturb.lolo +494 -0
  61. package/behaviors/lolo/ui/learning/atoms/std-learn-predict.lolo +408 -0
  62. package/behaviors/lolo/ui/learning/atoms/std-learn-scenario.lolo +307 -0
  63. package/behaviors/lolo/ui/learning/atoms/std-learn-sim-3d.lolo +318 -0
  64. package/behaviors/lolo/ui/learning/atoms/std-learn-speed-drill.lolo +336 -0
  65. package/behaviors/lolo/ui/learning/atoms/std-learn-tour-3d.lolo +380 -0
  66. package/behaviors/lolo/ui/learning/atoms/ui-biology-canvas.lolo +43 -4
  67. package/behaviors/lolo/ui/learning/atoms/ui-chemistry-canvas.lolo +41 -4
  68. package/behaviors/lolo/ui/learning/atoms/ui-physics-canvas.lolo +43 -4
  69. package/behaviors/lolo/ui/marketing/organisms/ui-book-viewer.lolo +1 -1
  70. package/behaviors/lolo/ui/marketing/organisms/ui-case-study-organism.lolo +1 -1
  71. package/behaviors/lolo/ui/marketing/organisms/ui-feature-grid-organism.lolo +1 -1
  72. package/behaviors/lolo/ui/marketing/organisms/ui-hero-organism.lolo +1 -1
  73. package/behaviors/lolo/ui/marketing/organisms/ui-pricing-organism.lolo +1 -1
  74. package/behaviors/lolo/ui/marketing/organisms/ui-showcase-organism.lolo +1 -1
  75. package/behaviors/lolo/ui/marketing/organisms/ui-stats-organism.lolo +1 -1
  76. package/behaviors/lolo/ui/marketing/organisms/ui-step-flow-organism.lolo +1 -1
  77. package/behaviors/lolo/ui/marketing/organisms/ui-team-organism.lolo +1 -1
  78. package/behaviors/registry/agent/atoms/std-agent-session.orb +22 -1
  79. package/behaviors/registry/agent/atoms/std-agent-tool-call.orb +38 -2
  80. package/behaviors/registry/agent/atoms/std-agent-tool-loop.orb +38 -2
  81. package/behaviors/registry/agent/organisms/std-agent-rabit.orb +23 -1
  82. package/behaviors/registry/infra/atoms/std-approval-gate.orb +8 -16
  83. package/behaviors/registry/infra/atoms/std-cache-aside.orb +31 -62
  84. package/behaviors/registry/infra/atoms/std-circuit-breaker.orb +16 -32
  85. package/behaviors/registry/infra/atoms/std-cross-reference.orb +32 -4
  86. package/behaviors/registry/infra/atoms/std-data-erasure.orb +8 -16
  87. package/behaviors/registry/infra/atoms/std-mod-queue.orb +8 -16
  88. package/behaviors/registry/infra/atoms/std-rate-limiter.orb +14 -28
  89. package/behaviors/registry/infra/atoms/std-row-access-control.orb +30 -2
  90. package/behaviors/registry/ui/core/atoms/std-billable-hour.orb +1 -2
  91. package/behaviors/registry/ui/core/atoms/std-board.orb +19 -5
  92. package/behaviors/registry/ui/core/atoms/std-browse.orb +29 -7
  93. package/behaviors/registry/ui/core/atoms/std-dashboard-grid-embedded.orb +1 -2
  94. package/behaviors/registry/ui/core/atoms/std-esign-flow.orb +3 -5
  95. package/behaviors/registry/ui/core/atoms/std-esign-request.orb +3 -6
  96. package/behaviors/registry/ui/core/atoms/std-event-log.orb +17 -3
  97. package/behaviors/registry/ui/core/atoms/std-export.orb +2 -4
  98. package/behaviors/registry/ui/core/atoms/std-form-advanced.orb +1 -1
  99. package/behaviors/registry/ui/core/atoms/std-gallery.orb +9 -18
  100. package/behaviors/registry/ui/core/atoms/std-graphs.orb +15 -1
  101. package/behaviors/registry/ui/core/atoms/std-import.orb +2 -4
  102. package/behaviors/registry/ui/core/atoms/std-list.orb +4 -6
  103. package/behaviors/registry/ui/core/atoms/std-modal.orb +2 -2
  104. package/behaviors/registry/ui/core/atoms/std-multi-party-flow.orb +16 -2
  105. package/behaviors/registry/ui/core/atoms/std-pagination.orb +15 -1
  106. package/behaviors/registry/ui/core/atoms/std-rating-review.orb +19 -5
  107. package/behaviors/registry/ui/core/atoms/std-recurrence.orb +17 -3
  108. package/behaviors/registry/ui/core/atoms/std-rich-editor.orb +15 -1
  109. package/behaviors/registry/ui/core/atoms/std-scatter.orb +15 -1
  110. package/behaviors/registry/ui/core/atoms/std-signature-capture.orb +2 -2
  111. package/behaviors/registry/ui/core/atoms/std-stats.orb +15 -1
  112. package/behaviors/registry/ui/core/atoms/std-step-flow.orb +16 -2
  113. package/behaviors/registry/ui/core/atoms/std-thread.orb +2 -2
  114. package/behaviors/registry/ui/core/atoms/std-vote.orb +2 -2
  115. package/behaviors/registry/ui/core/atoms/std-wizard.orb +17 -3
  116. package/behaviors/registry/ui/core/atoms/ui-atlas-image.orb +4 -1
  117. package/behaviors/registry/ui/core/atoms/ui-atlas-panel.orb +4 -1
  118. package/behaviors/registry/ui/core/atoms/ui-center.orb +4 -1
  119. package/behaviors/registry/ui/core/atoms/ui-hstack.orb +4 -1
  120. package/behaviors/registry/ui/core/atoms/ui-icon.orb +4 -1
  121. package/behaviors/registry/ui/core/atoms/ui-stack.orb +4 -1
  122. package/behaviors/registry/ui/core/atoms/ui-typography.orb +4 -1
  123. package/behaviors/registry/ui/core/atoms/ui-vstack.orb +4 -1
  124. package/behaviors/registry/ui/core/molecules/ui-accordion.orb +3 -3
  125. package/behaviors/registry/ui/core/molecules/ui-content-renderer.orb +4 -1
  126. package/behaviors/registry/ui/core/molecules/ui-form-layout.orb +4 -1
  127. package/behaviors/registry/ui/core/molecules/ui-grid.orb +4 -1
  128. package/behaviors/registry/ui/core/molecules/ui-tabs.orb +2 -2
  129. package/behaviors/registry/ui/core/molecules/ui-wizard-container.orb +1 -1
  130. package/behaviors/registry/ui/core/organisms/ui-chat-bar.orb +4 -1
  131. package/behaviors/registry/ui/core/organisms/ui-dashboard-grid.orb +5 -2
  132. package/behaviors/registry/ui/core/organisms/ui-detail-panel.orb +5 -2
  133. package/behaviors/registry/ui/core/organisms/ui-entity-cards.orb +4 -1
  134. package/behaviors/registry/ui/core/organisms/ui-entity-list.orb +4 -1
  135. package/behaviors/registry/ui/core/organisms/ui-entity-table.orb +4 -1
  136. package/behaviors/registry/ui/core/organisms/ui-form-section.orb +34 -2
  137. package/behaviors/registry/ui/core/organisms/ui-form.orb +34 -2
  138. package/behaviors/registry/ui/core/organisms/ui-master-detail.orb +4 -1
  139. package/behaviors/registry/ui/core/organisms/ui-media-gallery.orb +4 -1
  140. package/behaviors/registry/ui/core/organisms/ui-segment-renderer.orb +24 -2
  141. package/behaviors/registry/ui/core/organisms/ui-stat-card.orb +4 -1
  142. package/behaviors/registry/ui/core/organisms/ui-subagent-trace-panel.orb +4 -1
  143. package/behaviors/registry/ui/core/organisms/ui-tabbed-container.orb +1 -1
  144. package/behaviors/registry/ui/core/organisms/ui-ui-slot-renderer.orb +1 -1
  145. package/behaviors/registry/ui/game/atoms/std-fx-particles.orb +35 -1
  146. package/behaviors/registry/ui/game/atoms/ui-action-tile.orb +4 -1
  147. package/behaviors/registry/ui/game/atoms/ui-draw-shape-layer.orb +183 -13
  148. package/behaviors/registry/ui/game/atoms/ui-draw-shape.orb +104 -9
  149. package/behaviors/registry/ui/game/atoms/ui-draw-sprite-layer.orb +56 -2
  150. package/behaviors/registry/ui/game/atoms/ui-draw-sprite.orb +36 -4
  151. package/behaviors/registry/ui/game/atoms/ui-draw-text-layer.orb +21 -2
  152. package/behaviors/registry/ui/game/atoms/ui-draw-text.orb +19 -4
  153. package/behaviors/registry/ui/game/organisms/std-tactics-board-3d.orb +173 -2
  154. package/behaviors/registry/ui/learning/atoms/std-learn-classify.orb +1 -1
  155. package/behaviors/registry/ui/learning/atoms/std-learn-compare.orb +2814 -0
  156. package/behaviors/registry/ui/learning/atoms/std-learn-coupled-sim.orb +3183 -0
  157. package/behaviors/registry/ui/learning/atoms/std-learn-estimate.orb +2394 -0
  158. package/behaviors/registry/ui/learning/atoms/std-learn-goal-seek.orb +3951 -0
  159. package/behaviors/registry/ui/learning/atoms/std-learn-grid-sim.orb +3458 -0
  160. package/behaviors/registry/ui/learning/atoms/std-learn-hotspot.orb +2646 -0
  161. package/behaviors/registry/ui/learning/atoms/std-learn-measure.orb +1979 -0
  162. package/behaviors/registry/ui/learning/atoms/std-learn-perturb.orb +2994 -0
  163. package/behaviors/registry/ui/learning/atoms/std-learn-predict.orb +2682 -0
  164. package/behaviors/registry/ui/learning/atoms/std-learn-scenario.orb +1842 -0
  165. package/behaviors/registry/ui/learning/atoms/std-learn-sim-3d.orb +1648 -0
  166. package/behaviors/registry/ui/learning/atoms/std-learn-speed-drill.orb +2307 -0
  167. package/behaviors/registry/ui/learning/atoms/std-learn-tour-3d.orb +2947 -0
  168. package/behaviors/registry/ui/learning/atoms/ui-algorithm-canvas.orb +173 -4
  169. package/behaviors/registry/ui/learning/atoms/ui-biology-canvas.orb +267 -7
  170. package/behaviors/registry/ui/learning/atoms/ui-chemistry-canvas.orb +263 -8
  171. package/behaviors/registry/ui/learning/atoms/ui-learning-canvas.orb +116 -1
  172. package/behaviors/registry/ui/learning/atoms/ui-math-canvas.orb +200 -4
  173. package/behaviors/registry/ui/learning/atoms/ui-physics-canvas.orb +264 -7
  174. package/behaviors/registry/ui/marketing/atoms/std-marketing-article.orb +1 -2
  175. package/behaviors/registry/ui/marketing/atoms/std-marketing-footer.orb +1 -2
  176. package/behaviors/registry/ui/marketing/atoms/std-marketing-split.orb +1 -2
  177. package/behaviors/registry/ui/marketing/atoms/std-marketing-stats.orb +1 -2
  178. package/behaviors/registry/ui/marketing/atoms/std-marketing-steps.orb +1 -2
  179. package/behaviors/registry/ui/marketing/atoms/std-marketing-team.orb +1 -2
  180. package/behaviors/registry/ui/marketing/organisms/ui-book-viewer.orb +4 -1
  181. package/behaviors/registry/ui/marketing/organisms/ui-case-study-organism.orb +4 -1
  182. package/behaviors/registry/ui/marketing/organisms/ui-feature-grid-organism.orb +4 -1
  183. package/behaviors/registry/ui/marketing/organisms/ui-hero-organism.orb +4 -1
  184. package/behaviors/registry/ui/marketing/organisms/ui-pricing-organism.orb +4 -1
  185. package/behaviors/registry/ui/marketing/organisms/ui-showcase-organism.orb +4 -1
  186. package/behaviors/registry/ui/marketing/organisms/ui-stats-organism.orb +4 -1
  187. package/behaviors/registry/ui/marketing/organisms/ui-step-flow-organism.orb +4 -1
  188. package/behaviors/registry/ui/marketing/organisms/ui-team-organism.orb +4 -1
  189. package/dist/behaviors/exports-reader.js +3440 -2189
  190. package/dist/behaviors/functions/index.d.ts +1751 -154
  191. package/dist/behaviors/functions/index.js +3402 -2190
  192. package/dist/behaviors/index.d.ts +1 -1
  193. package/dist/behaviors/index.js +3441 -2190
  194. package/dist/behaviors/query.js +3440 -2189
  195. package/dist/behaviors-embeddings.hash.json +3 -3
  196. package/dist/behaviors-embeddings.json +230 -178
  197. package/dist/behaviors-registry.json +4397 -171
  198. package/dist/index.d.ts +1 -1
  199. package/dist/index.js +3441 -2190
  200. package/dist/knob-embeddings.hash.json +3 -3
  201. package/dist/knob-embeddings.json +1 -1
  202. package/dist/registry/factory-signatures.json +1 -1
  203. package/package.json +2 -2
@@ -0,0 +1,425 @@
1
+ app std-learn-grid-sim "1.0.0"
2
+ "Generic grid-world simulation — a tappable cellular grid evolves under a config-selected local rule: life (Conway's birth-3, survive-2-or-3), spread (anything with an active 4-neighbour activates — wavefronts, fire, contagion), or diffusion (each cell relaxes toward its neighbourhood average with decay — heat, concentration). The learner seeds the world by tapping cells directly on the canvas, then Runs, Pauses, or single-Steps the evolution, with a generation counter and live active-cell census. Rule, grid dimensions, seeds, and palette are all config-declared, so one mechanism serves emergence, percolation, epidemic fronts, heat flow, and any local-rules-global-behaviour lesson. Standalone by default; behind a lab router set matchMode and it renders only when MODE_SELECTED matches."
3
+ orbital GridSimOrbital {
4
+ type GridCellShape = {
5
+ type : "rect"!
6
+ id : string!
7
+ x : number!
8
+ y : number!
9
+ width : number!
10
+ height : number!
11
+ color : string!
12
+ fill : string!
13
+ }
14
+
15
+ entity GridSimScene [runtime] {
16
+ id : string!
17
+ active : boolean = false
18
+ title : string
19
+ cells : [number]
20
+ generation : number = 0
21
+ aliveCount : number = 0
22
+ running : boolean = false
23
+ cellShapes : [GridCellShape]
24
+ }
25
+
26
+ trait GridSimSim -> @rebindable GridSimScene [interaction, instance] {
27
+ initial: idle
28
+
29
+ state idle {
30
+ INIT -> idle when (== @config.matchMode "")
31
+ (set @entity.active true)
32
+ (set @entity.title @config.title)
33
+ (set @entity.generation 0)
34
+ (set @entity.running @config.autoRun)
35
+ (set @entity.cells (array/map (array/range 0 (* @config.rows @config.cols)) (fn (i) (if (array/includes @config.seeds @i) 1 0))))
36
+ (set @entity.aliveCount (array/len (array/filter @entity.cells (fn v (> @v 0.05)))))
37
+ (set @entity.cellShapes (array/map (array/range 0 (* @config.rows @config.cols)) (fn (i)
38
+ (let (
39
+ (r (math/floor (/ @i @config.cols)))
40
+ (c (math/mod @i @config.cols))
41
+ (v (array/nth @entity.cells @i))
42
+ (cellColor (if (> @v 0.66) @config.onColor (if (> @v 0.33) @config.midColor (if (> @v 0.05) @config.lowColor @config.offColor))))
43
+ )
44
+ { type: rect, id: (str/concat "cell-" @i), x: (+ 10 (* @c @config.cellSize)), y: (+ 10 (* @r @config.cellSize)), width: (- @config.cellSize 2), height: (- @config.cellSize 2), color: @cellColor, fill: @cellColor }))))
45
+ (render-ui main {
46
+ type: box
47
+ padding: md
48
+ children: [
49
+ { type: stack, direction: vertical, gap: md, children: [
50
+ { type: typography, variant: h4, content: @entity.title },
51
+ { type: typography, variant: body, content: @config.taskText },
52
+ { type: stack, direction: horizontal, gap: sm, children: [
53
+ { type: button, action: RUN, label: "Run", variant: primary, disabled: (if @entity.running true false) },
54
+ { type: button, action: PAUSE, label: "Pause", variant: secondary, disabled: (if @entity.running false true) },
55
+ { type: button, action: STEP, label: @config.stepLabel, variant: secondary, disabled: (if @entity.running true false) },
56
+ { type: button, action: RESET, label: "Reset", variant: ghost }
57
+ ] },
58
+ { type: learning-canvas, width: @config.width, height: @config.height, backgroundColor: @config.backgroundColor, shapes: @entity.cellShapes, interactive: true, animate: false, onShapeClick: "TAP_CELL" },
59
+ { type: typography, variant: body, content: (str/concat "Generation " (str/concat "" @entity.generation) " · active cells: " (str/concat "" @entity.aliveCount)) }
60
+ ] }
61
+ ]
62
+ })
63
+
64
+ MODE_SELECTED -> idle when (== ?mode @config.matchMode)
65
+ (set @entity.active true)
66
+ (set @entity.title @config.title)
67
+ (set @entity.generation 0)
68
+ (set @entity.running @config.autoRun)
69
+ (set @entity.cells (array/map (array/range 0 (* @config.rows @config.cols)) (fn (i) (if (array/includes @config.seeds @i) 1 0))))
70
+ (set @entity.aliveCount (array/len (array/filter @entity.cells (fn v (> @v 0.05)))))
71
+ (set @entity.cellShapes (array/map (array/range 0 (* @config.rows @config.cols)) (fn (i)
72
+ (let (
73
+ (r (math/floor (/ @i @config.cols)))
74
+ (c (math/mod @i @config.cols))
75
+ (v (array/nth @entity.cells @i))
76
+ (cellColor (if (> @v 0.66) @config.onColor (if (> @v 0.33) @config.midColor (if (> @v 0.05) @config.lowColor @config.offColor))))
77
+ )
78
+ { type: rect, id: (str/concat "cell-" @i), x: (+ 10 (* @c @config.cellSize)), y: (+ 10 (* @r @config.cellSize)), width: (- @config.cellSize 2), height: (- @config.cellSize 2), color: @cellColor, fill: @cellColor }))))
79
+ (render-ui main {
80
+ type: box
81
+ padding: md
82
+ children: [
83
+ { type: stack, direction: vertical, gap: md, children: [
84
+ { type: typography, variant: h4, content: @entity.title },
85
+ { type: typography, variant: body, content: @config.taskText },
86
+ { type: stack, direction: horizontal, gap: sm, children: [
87
+ { type: button, action: RUN, label: "Run", variant: primary, disabled: (if @entity.running true false) },
88
+ { type: button, action: PAUSE, label: "Pause", variant: secondary, disabled: (if @entity.running false true) },
89
+ { type: button, action: STEP, label: @config.stepLabel, variant: secondary, disabled: (if @entity.running true false) },
90
+ { type: button, action: RESET, label: "Reset", variant: ghost }
91
+ ] },
92
+ { type: learning-canvas, width: @config.width, height: @config.height, backgroundColor: @config.backgroundColor, shapes: @entity.cellShapes, interactive: true, animate: false, onShapeClick: "TAP_CELL" },
93
+ { type: typography, variant: body, content: (str/concat "Generation " (str/concat "" @entity.generation) " · active cells: " (str/concat "" @entity.aliveCount)) }
94
+ ] }
95
+ ]
96
+ })
97
+
98
+ RUN -> idle when (and (== @entity.active true) (== @entity.running false))
99
+ (set @entity.running true)
100
+ (render-ui main {
101
+ type: box
102
+ padding: md
103
+ children: [
104
+ { type: stack, direction: vertical, gap: md, children: [
105
+ { type: typography, variant: h4, content: @entity.title },
106
+ { type: typography, variant: body, content: @config.taskText },
107
+ { type: stack, direction: horizontal, gap: sm, children: [
108
+ { type: button, action: RUN, label: "Run", variant: primary, disabled: (if @entity.running true false) },
109
+ { type: button, action: PAUSE, label: "Pause", variant: secondary, disabled: (if @entity.running false true) },
110
+ { type: button, action: STEP, label: @config.stepLabel, variant: secondary, disabled: (if @entity.running true false) },
111
+ { type: button, action: RESET, label: "Reset", variant: ghost }
112
+ ] },
113
+ { type: learning-canvas, width: @config.width, height: @config.height, backgroundColor: @config.backgroundColor, shapes: @entity.cellShapes, interactive: true, animate: false, onShapeClick: "TAP_CELL" },
114
+ { type: typography, variant: body, content: (str/concat "Generation " (str/concat "" @entity.generation) " · active cells: " (str/concat "" @entity.aliveCount)) }
115
+ ] }
116
+ ]
117
+ })
118
+ (emit RUN_TOGGLED { running: @entity.running })
119
+
120
+ PAUSE -> idle when (and (== @entity.active true) (== @entity.running true))
121
+ (set @entity.running false)
122
+ (render-ui main {
123
+ type: box
124
+ padding: md
125
+ children: [
126
+ { type: stack, direction: vertical, gap: md, children: [
127
+ { type: typography, variant: h4, content: @entity.title },
128
+ { type: typography, variant: body, content: @config.taskText },
129
+ { type: stack, direction: horizontal, gap: sm, children: [
130
+ { type: button, action: RUN, label: "Run", variant: primary, disabled: (if @entity.running true false) },
131
+ { type: button, action: PAUSE, label: "Pause", variant: secondary, disabled: (if @entity.running false true) },
132
+ { type: button, action: STEP, label: @config.stepLabel, variant: secondary, disabled: (if @entity.running true false) },
133
+ { type: button, action: RESET, label: "Reset", variant: ghost }
134
+ ] },
135
+ { type: learning-canvas, width: @config.width, height: @config.height, backgroundColor: @config.backgroundColor, shapes: @entity.cellShapes, interactive: true, animate: false, onShapeClick: "TAP_CELL" },
136
+ { type: typography, variant: body, content: (str/concat "Generation " (str/concat "" @entity.generation) " · active cells: " (str/concat "" @entity.aliveCount)) }
137
+ ] }
138
+ ]
139
+ })
140
+ (emit RUN_TOGGLED { running: @entity.running })
141
+
142
+ STEP -> idle when (and (== @entity.active true) (== @entity.running false))
143
+ (set @entity.cells (array/map (array/range 0 (* @config.rows @config.cols)) (fn (i)
144
+ (let (
145
+ (r (math/floor (/ @i @config.cols)))
146
+ (c (math/mod @i @config.cols))
147
+ (v (array/nth @entity.cells @i))
148
+ (up (if (> @r 0) (array/nth @entity.cells (- @i @config.cols)) 0))
149
+ (down (if (< @r (- @config.rows 1)) (array/nth @entity.cells (+ @i @config.cols)) 0))
150
+ (left (if (> @c 0) (array/nth @entity.cells (- @i 1)) 0))
151
+ (right (if (< @c (- @config.cols 1)) (array/nth @entity.cells (+ @i 1)) 0))
152
+ (ul (if (and (> @r 0) (> @c 0)) (array/nth @entity.cells (- (- @i @config.cols) 1)) 0))
153
+ (ur (if (and (> @r 0) (< @c (- @config.cols 1))) (array/nth @entity.cells (+ (- @i @config.cols) 1)) 0))
154
+ (dl (if (and (< @r (- @config.rows 1)) (> @c 0)) (array/nth @entity.cells (- (+ @i @config.cols) 1)) 0))
155
+ (dr (if (and (< @r (- @config.rows 1)) (< @c (- @config.cols 1))) (array/nth @entity.cells (+ @i @config.cols 1)) 0))
156
+ (n4 (+ @up @down @left @right))
157
+ (n8 (+ @n4 @ul @ur @dl @dr))
158
+ )
159
+ (if (== @config.rule "life")
160
+ (if (if (> @v 0.5)
161
+ (if (== (math/round @n8 0) 2) true (== (math/round @n8 0) 3))
162
+ (== (math/round @n8 0) 3)) 1 0)
163
+ (if (== @config.rule "spread")
164
+ (if (if (> @v 0.5) true (> @n4 0.5)) 1 0)
165
+ (math/max 0 (* @config.decay (+ @v (* @config.diffuseRate (- (/ @n4 4) @v)))))))))))
166
+ (set @entity.generation (+ @entity.generation 1))
167
+ (set @entity.aliveCount (array/len (array/filter @entity.cells (fn v (> @v 0.05)))))
168
+ (set @entity.cellShapes (array/map (array/range 0 (* @config.rows @config.cols)) (fn (i)
169
+ (let (
170
+ (r (math/floor (/ @i @config.cols)))
171
+ (c (math/mod @i @config.cols))
172
+ (v (array/nth @entity.cells @i))
173
+ (cellColor (if (> @v 0.66) @config.onColor (if (> @v 0.33) @config.midColor (if (> @v 0.05) @config.lowColor @config.offColor))))
174
+ )
175
+ { type: rect, id: (str/concat "cell-" @i), x: (+ 10 (* @c @config.cellSize)), y: (+ 10 (* @r @config.cellSize)), width: (- @config.cellSize 2), height: (- @config.cellSize 2), color: @cellColor, fill: @cellColor }))))
176
+ (render-ui main {
177
+ type: box
178
+ padding: md
179
+ children: [
180
+ { type: stack, direction: vertical, gap: md, children: [
181
+ { type: typography, variant: h4, content: @entity.title },
182
+ { type: typography, variant: body, content: @config.taskText },
183
+ { type: stack, direction: horizontal, gap: sm, children: [
184
+ { type: button, action: RUN, label: "Run", variant: primary, disabled: (if @entity.running true false) },
185
+ { type: button, action: PAUSE, label: "Pause", variant: secondary, disabled: (if @entity.running false true) },
186
+ { type: button, action: STEP, label: @config.stepLabel, variant: secondary, disabled: (if @entity.running true false) },
187
+ { type: button, action: RESET, label: "Reset", variant: ghost }
188
+ ] },
189
+ { type: learning-canvas, width: @config.width, height: @config.height, backgroundColor: @config.backgroundColor, shapes: @entity.cellShapes, interactive: true, animate: false, onShapeClick: "TAP_CELL" },
190
+ { type: typography, variant: body, content: (str/concat "Generation " (str/concat "" @entity.generation) " · active cells: " (str/concat "" @entity.aliveCount)) }
191
+ ] }
192
+ ]
193
+ })
194
+ (emit GRID_STEPPED { generation: @entity.generation, aliveCount: @entity.aliveCount })
195
+
196
+ TAP_CELL -> idle when (== @entity.active true)
197
+ (set @entity.cells (array/map (array/range 0 (* @config.rows @config.cols)) (fn (j) (if (== @j (object/get ?payload index)) (if (> (array/nth @entity.cells @j) 0.5) 0 1) (array/nth @entity.cells @j)))))
198
+ (set @entity.aliveCount (array/len (array/filter @entity.cells (fn v (> @v 0.05)))))
199
+ (set @entity.cellShapes (array/map (array/range 0 (* @config.rows @config.cols)) (fn (i)
200
+ (let (
201
+ (r (math/floor (/ @i @config.cols)))
202
+ (c (math/mod @i @config.cols))
203
+ (v (array/nth @entity.cells @i))
204
+ (cellColor (if (> @v 0.66) @config.onColor (if (> @v 0.33) @config.midColor (if (> @v 0.05) @config.lowColor @config.offColor))))
205
+ )
206
+ { type: rect, id: (str/concat "cell-" @i), x: (+ 10 (* @c @config.cellSize)), y: (+ 10 (* @r @config.cellSize)), width: (- @config.cellSize 2), height: (- @config.cellSize 2), color: @cellColor, fill: @cellColor }))))
207
+ (render-ui main {
208
+ type: box
209
+ padding: md
210
+ children: [
211
+ { type: stack, direction: vertical, gap: md, children: [
212
+ { type: typography, variant: h4, content: @entity.title },
213
+ { type: typography, variant: body, content: @config.taskText },
214
+ { type: stack, direction: horizontal, gap: sm, children: [
215
+ { type: button, action: RUN, label: "Run", variant: primary, disabled: (if @entity.running true false) },
216
+ { type: button, action: PAUSE, label: "Pause", variant: secondary, disabled: (if @entity.running false true) },
217
+ { type: button, action: STEP, label: @config.stepLabel, variant: secondary, disabled: (if @entity.running true false) },
218
+ { type: button, action: RESET, label: "Reset", variant: ghost }
219
+ ] },
220
+ { type: learning-canvas, width: @config.width, height: @config.height, backgroundColor: @config.backgroundColor, shapes: @entity.cellShapes, interactive: true, animate: false, onShapeClick: "TAP_CELL" },
221
+ { type: typography, variant: body, content: (str/concat "Generation " (str/concat "" @entity.generation) " · active cells: " (str/concat "" @entity.aliveCount)) }
222
+ ] }
223
+ ]
224
+ })
225
+ (emit CELL_TOGGLED { index: (object/get ?payload index), aliveCount: @entity.aliveCount })
226
+
227
+ RESET -> idle when (== @entity.active true)
228
+ (set @entity.generation 0)
229
+ (set @entity.running false)
230
+ (set @entity.cells (array/map (array/range 0 (* @config.rows @config.cols)) (fn (i) (if (array/includes @config.seeds @i) 1 0))))
231
+ (set @entity.aliveCount (array/len (array/filter @entity.cells (fn v (> @v 0.05)))))
232
+ (set @entity.cellShapes (array/map (array/range 0 (* @config.rows @config.cols)) (fn (i)
233
+ (let (
234
+ (r (math/floor (/ @i @config.cols)))
235
+ (c (math/mod @i @config.cols))
236
+ (v (array/nth @entity.cells @i))
237
+ (cellColor (if (> @v 0.66) @config.onColor (if (> @v 0.33) @config.midColor (if (> @v 0.05) @config.lowColor @config.offColor))))
238
+ )
239
+ { type: rect, id: (str/concat "cell-" @i), x: (+ 10 (* @c @config.cellSize)), y: (+ 10 (* @r @config.cellSize)), width: (- @config.cellSize 2), height: (- @config.cellSize 2), color: @cellColor, fill: @cellColor }))))
240
+ (render-ui main {
241
+ type: box
242
+ padding: md
243
+ children: [
244
+ { type: stack, direction: vertical, gap: md, children: [
245
+ { type: typography, variant: h4, content: @entity.title },
246
+ { type: typography, variant: body, content: @config.taskText },
247
+ { type: stack, direction: horizontal, gap: sm, children: [
248
+ { type: button, action: RUN, label: "Run", variant: primary, disabled: (if @entity.running true false) },
249
+ { type: button, action: PAUSE, label: "Pause", variant: secondary, disabled: (if @entity.running false true) },
250
+ { type: button, action: STEP, label: @config.stepLabel, variant: secondary, disabled: (if @entity.running true false) },
251
+ { type: button, action: RESET, label: "Reset", variant: ghost }
252
+ ] },
253
+ { type: learning-canvas, width: @config.width, height: @config.height, backgroundColor: @config.backgroundColor, shapes: @entity.cellShapes, interactive: true, animate: false, onShapeClick: "TAP_CELL" },
254
+ { type: typography, variant: body, content: (str/concat "Generation " (str/concat "" @entity.generation) " · active cells: " (str/concat "" @entity.aliveCount)) }
255
+ ] }
256
+ ]
257
+ })
258
+ (emit GRID_RESET { seedCount: (array/len @config.seeds) })
259
+ }
260
+
261
+ ticks {
262
+ gridTick every 300ms
263
+ when (and (== @entity.active true) (== @entity.running true))
264
+ (set @entity.cells (array/map (array/range 0 (* @config.rows @config.cols)) (fn (i)
265
+ (let (
266
+ (r (math/floor (/ @i @config.cols)))
267
+ (c (math/mod @i @config.cols))
268
+ (v (array/nth @entity.cells @i))
269
+ (up (if (> @r 0) (array/nth @entity.cells (- @i @config.cols)) 0))
270
+ (down (if (< @r (- @config.rows 1)) (array/nth @entity.cells (+ @i @config.cols)) 0))
271
+ (left (if (> @c 0) (array/nth @entity.cells (- @i 1)) 0))
272
+ (right (if (< @c (- @config.cols 1)) (array/nth @entity.cells (+ @i 1)) 0))
273
+ (ul (if (and (> @r 0) (> @c 0)) (array/nth @entity.cells (- (- @i @config.cols) 1)) 0))
274
+ (ur (if (and (> @r 0) (< @c (- @config.cols 1))) (array/nth @entity.cells (+ (- @i @config.cols) 1)) 0))
275
+ (dl (if (and (< @r (- @config.rows 1)) (> @c 0)) (array/nth @entity.cells (- (+ @i @config.cols) 1)) 0))
276
+ (dr (if (and (< @r (- @config.rows 1)) (< @c (- @config.cols 1))) (array/nth @entity.cells (+ @i @config.cols 1)) 0))
277
+ (n4 (+ @up @down @left @right))
278
+ (n8 (+ @n4 @ul @ur @dl @dr))
279
+ )
280
+ (if (== @config.rule "life")
281
+ (if (if (> @v 0.5)
282
+ (if (== (math/round @n8 0) 2) true (== (math/round @n8 0) 3))
283
+ (== (math/round @n8 0) 3)) 1 0)
284
+ (if (== @config.rule "spread")
285
+ (if (if (> @v 0.5) true (> @n4 0.5)) 1 0)
286
+ (math/max 0 (* @config.decay (+ @v (* @config.diffuseRate (- (/ @n4 4) @v)))))))))))
287
+ (set @entity.generation (+ @entity.generation 1))
288
+ (set @entity.aliveCount (array/len (array/filter @entity.cells (fn v (> @v 0.05)))))
289
+ (set @entity.cellShapes (array/map (array/range 0 (* @config.rows @config.cols)) (fn (i)
290
+ (let (
291
+ (r (math/floor (/ @i @config.cols)))
292
+ (c (math/mod @i @config.cols))
293
+ (v (array/nth @entity.cells @i))
294
+ (cellColor (if (> @v 0.66) @config.onColor (if (> @v 0.33) @config.midColor (if (> @v 0.05) @config.lowColor @config.offColor))))
295
+ )
296
+ { type: rect, id: (str/concat "cell-" @i), x: (+ 10 (* @c @config.cellSize)), y: (+ 10 (* @r @config.cellSize)), width: (- @config.cellSize 2), height: (- @config.cellSize 2), color: @cellColor, fill: @cellColor }))))
297
+ }
298
+
299
+ listens {
300
+ MODE_SELECTED {
301
+ mode : string
302
+ }
303
+ @description "Lab router broadcast naming the active mode; this instrument renders when the mode equals matchMode, otherwise renders null."
304
+ @tier "domain"
305
+ RUN {
306
+ }
307
+ @description "Learner started the evolution; the grid advances one generation per tick until Pause."
308
+ @tier "domain"
309
+ PAUSE {
310
+ }
311
+ @description "Learner froze the evolution; tapping and single-stepping still work."
312
+ @tier "domain"
313
+ STEP {
314
+ }
315
+ @description "Learner advanced exactly one generation while paused — the microscope view of the rule."
316
+ @tier "domain"
317
+ TAP_CELL {
318
+ payload : { id : string type : string index : number! }
319
+ }
320
+ @description "Learner tapped a cell on the canvas — the canvas callback wraps its click info as payload { id, type, index }, where index is the flat cell index; the cell toggles between empty and active, seeding or editing the world."
321
+ @tier "domain"
322
+ RESET {
323
+ }
324
+ @description "Learner restored the configured seed pattern and zeroed the generation counter."
325
+ @tier "domain"
326
+ }
327
+
328
+ emits {
329
+ RUN_TOGGLED -> external {
330
+ running : boolean
331
+ }
332
+ @description "The evolution was started or paused — a composed listener (readout, grader) can subscribe; a harmless no-op when the atom runs standalone."
333
+ @tier "domain"
334
+ GRID_STEPPED -> external {
335
+ generation : number
336
+ aliveCount : number
337
+ }
338
+ @description "A single-step advanced the world by one generation, with the new active-cell census."
339
+ @synonyms "cellular automaton, game of life, grid world, emergence, local rules, spread, diffusion"
340
+ @tier "domain"
341
+ CELL_TOGGLED -> external {
342
+ index : number
343
+ aliveCount : number
344
+ }
345
+ @description "The learner toggled a cell by tapping it, with the new active-cell census."
346
+ @tier "domain"
347
+ GRID_RESET -> external {
348
+ seedCount : number
349
+ }
350
+ @description "The learner restored the world to its configured seeds."
351
+ @tier "domain"
352
+ }
353
+
354
+ config {
355
+ matchMode : string = ""
356
+ @label "Match Mode"
357
+ @description "When composed behind a lab router, the MODE_SELECTED mode value this instrument responds to. Empty string means standalone — render immediately on INIT."
358
+ @tier "presentation"
359
+ title : string = "Grid World"
360
+ @label "Title"
361
+ @description "Title shown above the grid."
362
+ @tier "presentation"
363
+ taskText : string = "Tap cells to seed the world, then Run — or Step one generation at a time to see the rule at work."
364
+ @label "Task Text"
365
+ @description "One-sentence statement of what to explore."
366
+ @tier "domain"
367
+ rule : string = "life"
368
+ @label "Rule"
369
+ @description "The local update rule: life (Conway birth-3 survive-2-3), spread (an active 4-neighbour activates a cell), or diffusion (cells relax toward the neighbourhood average with decay)."
370
+ @synonyms "game of life, contagion, wavefront, heat diffusion, cellular automaton rule"
371
+ @tier "domain"
372
+ rows : number = 12
373
+ @label "Rows"
374
+ @tier "domain"
375
+ cols : number = 16
376
+ @label "Columns"
377
+ @tier "domain"
378
+ seeds : [number] = [ 1, 18, 32, 33, 34, 88, 89, 90 ]
379
+ @label "Seeds"
380
+ @description "Flat cell indexes (row·cols + col) active at the start — the default plants a glider and a blinker. Realizations declare their own starting pattern here."
381
+ @tier "domain"
382
+ diffuseRate : number = 0.5
383
+ @label "Diffuse Rate"
384
+ @description "Diffusion rule only: how strongly a cell moves toward its neighbourhood average each generation."
385
+ @tier "domain"
386
+ decay : number = 0.995
387
+ @label "Decay"
388
+ @description "Diffusion rule only: fraction of a cell's value retained each generation."
389
+ @tier "domain"
390
+ cellSize : number = 26
391
+ @label "Cell Size"
392
+ @tier "presentation"
393
+ onColor : string = "#1d4ed8"
394
+ @label "On Color"
395
+ @tier "presentation"
396
+ midColor : string = "#60a5fa"
397
+ @label "Mid Color"
398
+ @tier "presentation"
399
+ lowColor : string = "#bfdbfe"
400
+ @label "Low Color"
401
+ @tier "presentation"
402
+ offColor : string = "#e2e8f0"
403
+ @label "Off Color"
404
+ @tier "presentation"
405
+ backgroundColor : string = "#f8fafc"
406
+ @label "Background Color"
407
+ @tier "presentation"
408
+ stepLabel : string = "Step"
409
+ @label "Step Label"
410
+ @tier "presentation"
411
+ autoRun : boolean = false
412
+ @label "Auto Run"
413
+ @description "Whether the evolution starts running immediately on load."
414
+ @tier "domain"
415
+ width : number = 436
416
+ @label "Width"
417
+ @tier "presentation"
418
+ height : number = 332
419
+ @label "Height"
420
+ @tier "presentation"
421
+ }
422
+ }
423
+
424
+ page "/learn-grid-sim" as GridSimPage -> GridSimSim
425
+ }