Hey everyone,
I wanted to share a fun side project I’ve been building over the past month that pushes Monkey C and device memory limits in a slightly unusual direction: NeuroWorm C.elegans.
It’s a Watch Face that runs an actual, biologically accurate 302-neuron connectome simulation of the C. elegans roundworm directly on-device in real-time.
The Tech / Architecture under the hood
Instead of using a toy AI model or a pre-rendered GIF, the worm's locomotion and sensory responses are driven live by a packed synaptic matrix based on the Fenyves et al. (2020) dataset.
-
Synaptic Storage (CSR Packed): To stay within CIQ Watch Face memory limits, all synaptic weights, polarities, and target offsets are packed into tight
ByteArraybuffers (using a Compressed Sparse Row format). -
Zero-Allocation Loop: The neural integration step, single-pass spatial sampling, and physics integration run on fixed buffers allocated strictly once. No
newobjects insideonUpdate()or physics ticks to keep the GC completely dormant. -
Spatial Memory Buffer: The worm interacts with a custom
_envBufferrepresenting food pellets (which happen to be laid out as 3x5 raster matrix digits representing the current time). -
Dynamic Neurochemistry: Motor outputs are modulated by a simplified neurotransmitter bias (dopamine/serotonin decay models). When you eat pellets, a Defecation Motor Program (DMP) fires through DVB/AVL neuron triggers, leaving tiny digital "pebbles" behind. Notifications inject a brief pulse of sensory noise to trigger escape-response behavior.
It’s still a work in progress and biology is inherently chaotic, so expect some weird edge-case behavior (and occasional anxiety-induced hyper-reversals when a wall of notifications hits).
If you’re interested in checking it out or running it on your device, it's live on Connect IQ as NeuroWorm C.elegans.
https://apps.garmin.com/apps/345890da-a9d1-43d4-9c6f-8bc35ee9b19f
Would love to hear any feedback on memory optimization tricks or Monkey C math efficiency if anyone dives in!Data source: Fenyves BG, Szilágyi GS, Vassy Z, Sőti C, Csermely P (2020) PLoS Comput. Biol. 16(12): e1007974.