viva_glyph/primitives

Primitives - The Machine Code of Instinct

These are the fundamental operations that VIVA “is born knowing”. They operate on the analog substrate (Signals/Vectors), not the quantized symbolic layer (Glyphs).

Hierarchy

QUARKS (Atoms)     ← polarity, phase, entropy, gradient
    ↓
HADRONS (Instincts) ← seek, flee, drift, resonate
    ↓
MOLECULES (Glyphs)  ← encoded emotional tokens

Analogy:

Types

A raw neural signal (unquantized emotional vector) Range usually [0.0, 1.0] per dimension

pub type Signal =
  List(Float)

Values

pub fn centroid(s: List(Float)) -> Float

CENTROID: The “center of mass” of a signal. Where is the emotional energy concentrated?

pub fn contrast(s: List(Float)) -> Float

CONTRAST: Difference between max and min values. High contrast = strong emotional differentiation.

pub fn drift(
  current: List(Float),
  decay_rate: Float,
) -> List(Float)

DRIFT: The instinct to return to neutrality (Homeostasis). Without energy input, systems settle to zero.

formula: current * (1.0 - decay_rate)

pub fn entropy_local(s: List(Float)) -> Float

ENTROPY_LOCAL: Measure of disorder/uncertainty in a signal. High entropy = chaotic/unpredictable, Low = stable/certain. Returns [0.0, 1.0] where 1.0 is maximum chaos.

pub fn flee(
  current: List(Float),
  source: List(Float),
  rate: Float,
) -> List(Float)

FLEE: The instinct to move away from a source. Used for: Fear, Disgust, Avoidance.

formula: current - (source - current) * rate

pub fn gradient(
  prev: List(Float),
  curr: List(Float),
) -> List(Float)

GRADIENT: The rate of change between two signals. Positive = increasing, Negative = decreasing. This is the “derivative” - how fast things are changing.

pub fn mix(
  a: List(Float),
  b: List(Float),
  alpha: Float,
) -> List(Float)

MIX: Combine two signals with a blend factor (alpha). mix(a, b, 0.5) is perfect average.

pub fn phase(value: Float, period: Float) -> Float

PHASE: Where we are in a cycle [0.0, 1.0]. Maps any value to its position in a unit circle. Useful for rhythmic/oscillating emotions.

pub fn polarity(value: Float) -> Float

POLARITY: The fundamental direction of a signal dimension. Returns +1.0 (positive/approach), -1.0 (negative/avoid), or 0.0 (neutral). This is the most basic “bit” - attraction vs repulsion.

pub fn polarity_vec(s: List(Float)) -> List(Float)

POLARITY_VEC: Polarity for each dimension of a signal. Returns the “emotional direction” vector.

pub fn resonate(a: List(Float), b: List(Float)) -> Float

RESONATE: The instinct to recognize similarity/harmony. Unlike simple distance, this measures directional alignment. Returns 1.0 if identical direction, 0.0 if orthogonal, -1.0 if opposite.

pub fn seek(
  current: List(Float),
  target: List(Float),
  rate: Float,
) -> List(Float)

SEEK: The instinct to move towards a target state. Used for: Desire, Attention, Goal-seeking.

formula: current + (target - current) * rate

pub fn sense(g: glyph.Glyph) -> List(Float)

Extract the raw signal from a crystallized Glyph

pub fn surge(s: List(Float)) -> Float

SURGE: The instinct to measure intensity. How “loud” is this feeling?

Search Document