Skip to content

First Memory

Let’s create a small neural network and watch it come alive.

A simple associative network:

graph TD
    fire[fire<br/>E=0.9] -->|+1, s=0.8| heat[heat]
    fire -->|+1, s=0.6| light[light]
    fire -->|-1, s=0.7| ice[ice]
    heat -->|+1, s=0.5| burn[burn]
  1. Create the core memory

    Using CLI:

    Terminal window
    mfcli create fire 0.9

    Or TypeScript:

    await brain.lineage.create({ key: 'fire', energy: 0.9 })

    This creates a “fire” memory with high initial energy (0.9).

  2. Create associated memories

    Terminal window
    mfcli create heat 0.5
    mfcli create light 0.4
    mfcli create ice 0.6
    mfcli create burn 0.3
  3. Form synergy bonds

    // fire → heat (synergy)
    await brain.bond.connect({
    from: 'fire',
    to: 'heat',
    strength: 0.8,
    polarity: 1,
    })
    // fire → light (synergy)
    await brain.bond.connect({
    from: 'fire',
    to: 'light',
    strength: 0.6,
    polarity: 1,
    })
    // heat → burn (synergy)
    await brain.bond.connect({
    from: 'heat',
    to: 'burn',
    strength: 0.5,
    polarity: 1,
    })
  4. Form an antagonistic bond

    // fire → ice (antagonism)
    await brain.bond.connect({
    from: 'fire',
    to: 'ice',
    strength: 0.7,
    polarity: -1, // Negative!
    })

    Now when “fire” is stimulated, “ice” will be suppressed.

  5. Stimulate and observe

    // Before stimulation
    console.log('Before:')
    console.log('heat:', (await brain.lineage.get('heat')).energy)
    console.log('ice:', (await brain.lineage.get('ice')).energy)
    // Stimulate fire!
    await brain.lineage.stimulate({ key: 'fire', delta: 1.0 })
    // After stimulation
    console.log('\nAfter fire stimulation:')
    console.log('heat:', (await brain.lineage.get('heat')).energy)
    // Expected: ~0.9 (was 0.5, +0.4 from cascade)
    console.log('ice:', (await brain.lineage.get('ice')).energy)
    // Expected: ~0.25 (was 0.6, -0.35 from antagonism)
    console.log('burn:', (await brain.lineage.get('burn')).energy)
    // Expected: ~0.5 (2-hop cascade: fire→heat→burn)

When you stimulated “fire”:

  1. Direct cascade to “heat” (+0.4) and “light” (+0.3)
  2. Antagonistic suppression of “ice” (-0.35)
  3. Secondary cascade from “heat” to “burn” (+0.2)

The entire network responded to a single stimulus. This is synaptic propagation.

// Depressive mood: raise consciousness threshold
await brain.system.setMood(0.2)
// Now lower-energy memories become inaccessible
const burn = await brain.lineage.get('burn')
// May throw "NotFound" if burn.energy < threshold
// Each GET reinforces the memory
for (let i = 0; i < 10; i++) {
await brain.lineage.get('fire')
}
// fire.energy has increased by ~0.1 (10 × 0.01)
// Stimulate WITHOUT cascade (maintenance mode)
await brain.lineage.stimulate({
key: 'fire',
delta: 0.5,
flags: 0x01, // NO_PROPAGATE
})
// Only 'fire' affected, no neighbors touched
import { MindFry } from '@mindfry/client'
async function firstMemory() {
const brain = new MindFry({ host: 'localhost', port: 9527 })
await brain.connect()
// Create memories
await brain.lineage.create({ key: 'fire', energy: 0.9 })
await brain.lineage.create({ key: 'heat', energy: 0.5 })
await brain.lineage.create({ key: 'light', energy: 0.4 })
await brain.lineage.create({ key: 'ice', energy: 0.6 })
await brain.lineage.create({ key: 'burn', energy: 0.3 })
// Form bonds
await brain.bond.connect({ from: 'fire', to: 'heat', strength: 0.8, polarity: 1 })
await brain.bond.connect({ from: 'fire', to: 'light', strength: 0.6, polarity: 1 })
await brain.bond.connect({ from: 'fire', to: 'ice', strength: 0.7, polarity: -1 })
await brain.bond.connect({ from: 'heat', to: 'burn', strength: 0.5, polarity: 1 })
// Stimulate and observe
console.log('Before:', (await brain.lineage.get('heat')).energy)
await brain.lineage.stimulate({ key: 'fire', delta: 1.0 })
console.log('After:', (await brain.lineage.get('heat')).energy)
await brain.disconnect()
}
firstMemory()

Next: Explore Recipes for real-world patterns or dive into Architecture.