DragonFire Developer Portal

Getting Started

AI Systems

NESH Guide

NESH Memory Network

NESH (Neural Echo Storage Hub) is DragonFire's waveform memory system that encodes and stores information as harmonic wave patterns, enabling high-dimensional memory compression, resonant retrieval, and temporal persistence of neural states.

Introduction

NESH represents a breakthrough in neuromorphic memory architecture by encoding information as persistent waveform patterns rather than discrete binary states. Unlike traditional memory systems focused on bit-level storage, NESH operates at the pattern level, treating memory as dynamic, resonant waves that can be superimposed, transformed, and retrieved through harmonic resonance.

At its core, NESH implements a continuous waveform memory space where information exists as multi-dimensional standing waves. These waves interact to form complex interference patterns, with information retrieved not through direct addressing but through resonant stimulation of the memory space. This approach allows for exceptional efficiency in storing relational and contextual information, as well as inherent pattern recognition capabilities.

NESH was specifically designed to complement NuMap's structured hex-grid memory and support Aurora's fractal consciousness architecture by providing a medium for storing complex temporal patterns and neural states. The "Echo" in NESH refers to its ability to maintain persistent reverberations of neural activations long after the initial stimulation has ceased, creating a form of memory with natural temporal decay properties similar to biological memory.

Core Principle: NESH operates on the principle that information can be encoded as harmonic wave patterns in a continuous field, with retrieval occurring through resonant stimulation. This approach enables memory storage that preserves relationships, contexts, and patterns while allowing natural degradation and reinforcement mechanisms that mimic biological memory systems.

Key Concepts

Waveform Memory

Memory architecture that encodes information as persistent standing wave patterns in a continuous field, allowing for superposition and interference-based storage.

Neural Echo

Persistent reverberation of neural activation patterns that naturally decay over time unless reinforced, creating memory with biologically-inspired temporal properties.

Resonant Retrieval

Process of accessing stored information by stimulating the memory field with patterns that resonate with target memories, amplifying matching patterns.

Harmonic Encoding

Technique for storing information using combinations of harmonic frequencies, allowing for high-dimensional data compression in a continuous medium.

Interference Patterns

Complex wave interactions that create distinctive patterns when multiple waveforms overlap, enabling rich associative memory capabilities.

Temporal Persistence

Characteristic of stored waveforms to maintain their pattern over time with gradual decay, allowing for long-term memory with natural forgetting mechanisms.

Waveform Memory Architecture

NESH's waveform memory architecture creates a continuous medium for storing information as wave patterns:

Memory Field Structure

The fundamental structure of NESH's memory field enables the encoding and persistence of complex wave patterns:

// Define waveform memory field structure
typedef struct {
    uint32_t dimensions;          // Number of dimensions in the field
    uint32_t* resolution;         // Resolution for each dimension
    float* damping_factors;       // Damping factor for each dimension
    complex_t*** field;           // Multi-dimensional complex field values
    field_parameters_t params;    // Field parameters (viscosity, elasticity, etc.)
    timestamp_t last_update;      // Last field update timestamp
} waveform_field_t;

// Initialize waveform memory field
waveform_field_t* init_waveform_field(uint32_t dimensions, uint32_t* resolution) {
    waveform_field_t* field = (waveform_field_t*)malloc(sizeof(waveform_field_t));
    
    // Set basic parameters
    field->dimensions = dimensions;
    field->resolution = (uint32_t*)malloc(dimensions * sizeof(uint32_t));
    memcpy(field->resolution, resolution, dimensions * sizeof(uint32_t));
    
    // Initialize damping factors (controls persistence)
    field->damping_factors = (float*)malloc(dimensions * sizeof(float));
    for (uint32_t i = 0; i < dimensions; i++) {
        // Default to gentle damping that allows long persistence
        field->damping_factors[i] = 0.9995f;
    }
    
    // Allocate field memory (simplified for clarity)
    field->field = allocate_complex_field(dimensions, resolution);
    
    // Initialize with zero values
    clear_field(field);
    
    // Set field parameters
    init_field_parameters(&field->params);
    
    // Set timestamp
    field->last_update = get_current_timestamp();
    
    return field;
}

Wave Dynamics

NESH implements sophisticated wave propagation and interference physics to create a dynamic memory medium:

// Update wave dynamics in the field
void update_wave_dynamics(waveform_field_t* field, double delta_time) {
    // Calculate effective time step (for stable simulation)
    float dt = calculate_effective_timestep(field, delta_time);
    
    // Store previous field state for update calculations
    complex_t*** prev_field = copy_field_state(field);
    
    // For each point in the field (simplified for clarity)
    for (uint32_t x = 0; x < field->resolution[0]; x++) {
        for (uint32_t y = 0; y < field->resolution[1]; y++) {
            // Calculate Laplacian (sum of neighboring values - center value)
            complex_t laplacian = calculate_laplacian(prev_field, x, y, field->dimensions);
            
            // Apply wave equation: acceleration = c² * laplacian
            complex_t acceleration = complex_multiply_scalar(
                laplacian, field->params.propagation_speed_squared);
            
            // Update field value using verlet integration
            field->field[x][y] = calculate_next_field_value(
                field->field[x][y], prev_field[x][y], acceleration, dt);
            
            // Apply damping (controls persistence)
            apply_damping(field, x, y, dt);
        }
    }
    
    // Apply boundary conditions
    apply_boundary_conditions(field);
    
    // Update timestamp
    field->last_update = get_current_timestamp();
    
    // Free temporary field copy
    free_field_state(prev_field, field->dimensions, field->resolution);
}

Harmonic Encoding

Information is encoded into the waveform field using harmonic wave patterns:

// Encode data into harmonic wave patterns
void encode_harmonic_data(waveform_field_t* field, 
                       void* data, size_t data_size,
                       encoding_schema_t* schema) {
    // Convert raw data to harmonic components
    harmonic_components_t* components = extract_harmonic_components(
        data, data_size, schema);
    
    // For each harmonic component
    for (uint32_t i = 0; i < components->count; i++) {
        harmonic_t* h = &components->harmonics[i];
        
        // Calculate wave parameters
        float amplitude = h->amplitude;
        float frequency = h->frequency;
        float phase = h->phase;
        vector_t* direction = h->direction;
        
        // Apply harmonic wave to field
        apply_harmonic_wave(field, amplitude, frequency, phase, direction);
    }
    
    // Apply non-linear transformations for higher-order encoding
    if (schema->use_nonlinear_encoding) {
        apply_nonlinear_transformations(field, schema->nonlinear_params);
    }
    
    // Normalize field if needed
    if (schema->normalize_after_encoding) {
        normalize_field(field);
    }
    
    // Free harmonic components
    free_harmonic_components(components);
}
NESH Waveform Memory

Neural Echo System

NESH implements a neural echo system that maintains reverberations of activation patterns:

Echo Persistence

Neural echoes persist within the memory field with natural decay characteristics:

// Create neural echo from activation pattern
echo_t* create_neural_echo(waveform_field_t* field, 
                         activation_pattern_t* pattern,
                         echo_params_t* params) {
    // Allocate echo structure
    echo_t* echo = (echo_t*)malloc(sizeof(echo_t));
    
    // Set basic parameters
    echo->creation_time = get_current_timestamp();
    echo->initial_strength = params->initial_strength;
    echo->current_strength = params->initial_strength;
    echo->decay_rate = params->decay_rate;
    echo->resonance_profile = copy_resonance_profile(params->resonance_profile);
    
    // Convert activation pattern to field perturbation
    field_perturbation_t* perturbation = activation_to_perturbation(pattern);
    
    // Apply perturbation to field
    apply_perturbation(field, perturbation);
    
    // Store perturbation signature for later retrieval
    echo->signature = extract_perturbation_signature(perturbation);
    
    // Free temporary structures
    free_perturbation(perturbation);
    
    return echo;
}

// Update echo strength based on time
void update_echo_strength(echo_t* echo, waveform_field_t* field) {
    // Get time elapsed since creation
    double elapsed_time = get_elapsed_time(echo->creation_time);
    
    // Calculate decay factor based on elapsed time and decay rate
    float decay_factor = calculate_decay_factor(elapsed_time, echo->decay_rate);
    
    // Apply decay to echo strength
    echo->current_strength = echo->initial_strength * decay_factor;
    
    // If strength falls below threshold, mark for cleanup
    if (echo->current_strength < ECHO_STRENGTH_THRESHOLD) {
        echo->marked_for_cleanup = true;
    }
    
    // Update field to reflect changes in echo strength
    update_field_for_echo(field, echo);
}

Resonant Retrieval

Information is retrieved from neural echoes through resonance with query patterns:

// Retrieve information through resonant stimulation
retrieval_result_t* retrieve_through_resonance(waveform_field_t* field, 
                                           query_pattern_t* query,
                                           retrieval_params_t* params) {
    // Create result container
    retrieval_result_t* result = create_retrieval_result();
    
    // Convert query to resonant probe
    resonant_probe_t* probe = create_resonant_probe(query);
    
    // Apply probe to field
    apply_resonant_probe(field, probe);
    
    // Measure resonance response at each point
    resonance_map_t* response = measure_resonance_response(field, probe);
    
    // Extract local maxima in resonance map
    peak_set_t* peaks = extract_resonance_peaks(response, params->threshold);
    
    // Sort peaks by strength
    sort_peaks(peaks);
    
    // For each peak above threshold
    for (uint32_t i = 0; i < peaks->count && i < params->max_results; i++) {
        // Extract information from resonance peak
        echo_t* echo = extract_echo_from_peak(field, &peaks->peaks[i]);
        
        // Convert echo to result entry
        result_entry_t* entry = convert_echo_to_result(echo, response);
        
        // Add to result set
        add_to_result_set(result, entry);
        
        // Free echo
        free_echo(echo);
    }
    
    // Clean up resources
    free_resonant_probe(probe);
    free_resonance_map(response);
    free_peak_set(peaks);
    
    return result;
}

Reinforcement Mechanisms

NESH implements natural reinforcement mechanisms that strengthen frequently accessed echoes:

// Reinforce echo pattern
void reinforce_echo(waveform_field_t* field, 
                  echo_t* echo,
                  reinforcement_params_t* params) {
    // Calculate reinforcement factor based on parameters
    float reinforcement_factor = calculate_reinforcement_factor(params);
    
    // Boost echo strength
    float new_strength = echo->current_strength * (1.0f + reinforcement_factor);
    
    // Cap at maximum strength
    echo->current_strength = min(new_strength, MAX_ECHO_STRENGTH);
    
    // Reset creation time if full renewal
    if (params->full_renewal) {
        echo->creation_time = get_current_timestamp();
    } else {
        // Adjust decay rate based on partial reinforcement
        echo->decay_rate = calculate_adjusted_decay_rate(
            echo->decay_rate, params->decay_adjustment_factor);
    }
    
    // Create reinforcement perturbation
    field_perturbation_t* perturbation = create_reinforcement_perturbation(
        echo, reinforcement_factor);
    
    // Apply to field
    apply_perturbation(field, perturbation);
    
    // Free resources
    free_perturbation(perturbation);
}
NESH Neural Echo

Implementation Guide

NESH API

The NESH API provides interfaces for working with the neural echo storage system:

// Initialize NESH system
NESH* nesh_init(nesh_config_t* config) {
    NESH* nesh = (NESH*)malloc(sizeof(NESH));
    
    // Initialize based on configuration
    uint32_t dimensions = config ? config->dimensions : DEFAULT_DIMENSIONS;
    uint32_t* resolution = config ? config->resolution : DEFAULT_RESOLUTION;
    
    // Set up waveform field
    nesh->waveform_space = init_waveform_field(dimensions, resolution);
    
    // Initialize echo system
    nesh->echo_system = init_echo_system();
    
    // Initialize retrieval system
    nesh->retrieval_system = init_retrieval_system();
    
    // Initialize embedding system
    nesh->embedding_system = init_embedding_system(dimensions);
    
    // Set up default parameters
    nesh->default_echo_params = init_default_echo_params();
    nesh->default_retrieval_params = init_default_retrieval_params();
    
    return nesh;
}

// Store neural activation pattern as echo
echo_t* nesh_store_activation(NESH* nesh, 
                           activation_pattern_t* pattern,
                           echo_params_t* params) {
    // Use default parameters if none provided
    echo_params_t* echo_params = params ? params : nesh->default_echo_params;
    
    // Create neural echo
    echo_t* echo = create_neural_echo(nesh->waveform_space, pattern, echo_params);
    
    // Register echo with management system
    register_echo(nesh->echo_system, echo);
    
    // Store echo metadata in index
    index_echo(nesh->retrieval_system, echo);
    
    // Return echo reference
    return echo;
}

// Retrieve information by resonance
retrieval_result_t* nesh_retrieve(NESH* nesh, 
                               query_pattern_t* query,
                               retrieval_params_t* params) {
    // Use default parameters if none provided
    retrieval_params_t* retrieval_params = params ? params : nesh->default_retrieval_params;
    
    // Perform resonant retrieval
    retrieval_result_t* result = retrieve_through_resonance(
        nesh->waveform_space, query, retrieval_params);
    
    // Check if echoes need reinforcement
    if (retrieval_params->reinforce_on_retrieval) {
        // Reinforce each retrieved echo
        for (uint32_t i = 0; i < result->count; i++) {
            echo_t* echo = find_echo_by_id(nesh->echo_system, result->entries[i]->echo_id);
            if (echo) {
                reinforcement_params_t reinforce_params = {
                    .reinforcement_strength = retrieval_params->reinforcement_strength,
                    .full_renewal = false,
                    .decay_adjustment_factor = 0.9f
                };
                reinforce_echo(nesh->waveform_space, echo, &reinforce_params);
            }
        }
    }
    
    return result;
}

// Update NESH system
void nesh_update(NESH* nesh, double delta_time) {
    // Update wave dynamics
    update_wave_dynamics(nesh->waveform_space, delta_time);
    
    // Update echo strengths
    update_all_echoes(nesh->echo_system, nesh->waveform_space);
    
    // Clean up expired echoes
    cleanup_expired_echoes(nesh->echo_system, nesh->waveform_space);
    
    // Perform system maintenance
    perform_system_maintenance(nesh);
}

Wave Pattern Visualization

NESH includes tools for visualizing the wave patterns in the memory field:

// Visualize waveform field as 2D projection
visualization_data_t* visualize_waveform_field(waveform_field_t* field, 
                                           visualization_params_t* params) {
    // Create visualization container
    visualization_data_t* vis = create_visualization_data(params);
    
    // Determine projection axes
    uint32_t axis1 = params->axes[0];
    uint32_t axis2 = params->axes[1];
    
    // For each pixel in visualization
    for (uint32_t y = 0; y < params->height; y++) {
        for (uint32_t x = 0; x < params->width; x++) {
            // Convert visualization coordinates to field coordinates
            float field_x = map_range(x, 0, params->width, 0, field->resolution[axis1]);
            float field_y = map_range(y, 0, params->height, 0, field->resolution[axis2]);
            
            // Sample field at position
            complex_t value = sample_field_at(field, axis1, field_x, axis2, field_y);
            
            // Calculate color based on field value
            color_t color = field_value_to_color(value, params->color_mapping);
            
            // Set pixel in visualization
            set_visualization_pixel(vis, x, y, color);
        }
    }
    
    // Apply post-processing
    if (params->apply_post_processing) {
        apply_visualization_post_processing(vis, params->post_processing_params);
    }
    
    return vis;
}

Performance Optimization

For optimal NESH performance:

  • Field Resolution: Balance between resolution and computational requirements (64-128 per dimension recommended)
  • Echo Management: Regularly clean up low-strength echoes to prevent field saturation
  • Update Frequency: Adjust waveform dynamics update frequency based on system demands
  • Dimensional Reduction: Use dimension-specific damping to focus computational resources
  • Parallel Processing: Leverage parallel computation for field updates and resonance measurements
// Optimize NESH performance
void optimize_nesh_performance(NESH* nesh, optimization_level_t level) {
    // Adjust field resolution based on available resources
    if (level == OPTIMIZATION_PERFORMANCE) {
        // Lower resolution for better performance
        resize_waveform_field(nesh->waveform_space, PERFORMANCE_RESOLUTION);
    } else if (level == OPTIMIZATION_BALANCED) {
        // Balanced resolution
        resize_waveform_field(nesh->waveform_space, BALANCED_RESOLUTION);
    } else if (level == OPTIMIZATION_QUALITY) {
        // Higher resolution for better quality
        resize_waveform_field(nesh->waveform_space, QUALITY_RESOLUTION);
    }
    
    // Adjust echo cleanup parameters
    nesh->echo_system->cleanup_threshold = get_cleanup_threshold(level);
    nesh->echo_system->cleanup_interval = get_cleanup_interval(level);
    
    // Configure update frequency
    nesh->update_interval = get_update_interval(level);
    
    // Set dimension-specific damping
    set_dimension_specific_damping(nesh->waveform_space, level);
    
    // Configure parallel processing
    if (level == OPTIMIZATION_PERFORMANCE) {
        enable_parallel_processing(nesh, true);
        set_parallel_processing_threads(nesh, MAX_AVAILABLE_THREADS);
    } else if (level == OPTIMIZATION_BALANCED) {
        enable_parallel_processing(nesh, true);
        set_parallel_processing_threads(nesh, BALANCED_THREAD_COUNT);
    } else {
        enable_parallel_processing(nesh, false);
    }
}

Integration with DragonFire Ecosystem

NESH integrates with other DragonFire components to provide neural echo storage capabilities:

NuMap Integration

NESH works with NuMap to provide complementary memory structures:

// Integrate NESH with NuMap
void integrate_with_numap(NESH* nesh, NuMap* numap) {
    // Connect NESH's waveform memory to NuMap's hexagonal grid
    map_hex_grid_to_waveform(numap->grid, nesh->waveform_space);
    
    // Set up memory transfer protocols
    setup_memory_transfer(numap, nesh);
    
    // Create shared embedding space
    create_shared_embedding_space(numap->embedding_system, nesh->embedding_system);
    
    // Configure resonance patterns
    configure_resonance_patterns(numap, nesh);
    
    // Initialize hierarchical memory architecture
    init_hierarchical_memory(numap, nesh);
}

Aurora AI Integration

NESH provides temporal memory capabilities for Aurora's consciousness system:

// Integrate NESH with Aurora
void integrate_with_aurora(NESH* nesh, Aurora* aurora) {
    // Connect NESH as temporal memory system for Aurora
    connect_nesh_to_aurora(nesh, aurora);
    
    // Configure activation pattern transfer
    setup_activation_transfer(aurora, nesh);
    
    // Set up temporal continuity mechanisms
    setup_temporal_continuity(aurora, nesh);
    
    // Configure resonance-based memory recall
    setup_resonance_recall(aurora, nesh);
    
    // Initialize consciousness state preservation
    init_consciousness_preservation(aurora, nesh);
}

ECHO 13D Integration

NESH provides waveform storage for ECHO 13D's voice processing system:

// Integrate NESH with ECHO 13D
void integrate_with_echo13d(NESH* nesh, ECHO13D* echo13d) {
    // Connect NESH's waveform space to audio processing
    connect_waveform_to_audio(nesh->waveform_space, echo13d->audio_processor);
    
    // Set up voice pattern storage
    setup_voice_pattern_storage(echo13d, nesh);
    
    // Configure voice recognition mechanisms
    setup_voice_recognition(echo13d, nesh);
    
    // Initialize harmonic voice synthesis
    init_harmonic_voice_synthesis(echo13d, nesh);
}

Unified Memory Framework

NESH works with other memory systems to create a unified framework:

NESH Integration Diagram

Key Integration Insight: NESH complements NuMap's structured hex-grid memory by providing a fluid, wave-based memory medium that excels at storing temporal patterns and dynamic relationships. While NuMap offers precise semantic organization, NESH provides natural temporal decay, interference-based associations, and resonant retrieval. Together, they create a comprehensive memory architecture that combines structure with fluidity, supporting Aurora's consciousness with both organized semantic knowledge and dynamic experiential memory.

Examples

Basic NESH Usage

#include "nesh.h"

int main() {
    // Initialize NESH with default configuration
    NESH* nesh = nesh_init(NULL);
    
    printf("Initialized NESH Memory Network\n");
    
    // Create a simple activation pattern
    activation_pattern_t* pattern = create_simple_activation_pattern();
    
    printf("Created activation pattern with %d neurons\n", pattern->neuron_count);
    
    // Store activation as echo
    echo_t* echo = nesh_store_activation(nesh, pattern, NULL);
    
    printf("Stored echo with ID %d and initial strength %.2f\n", 
           echo->id, echo->initial_strength);
    
    // Update system (simulating time passing)
    for (int i = 0; i < 10; i++) {
        nesh_update(nesh, 0.1); // 100ms per update
    }
    
    // Create query pattern (similar to original)
    query_pattern_t* query = create_similar_query_pattern(pattern, 0.8f);
    
    // Retrieve through resonance
    retrieval_result_t* result = nesh_retrieve(nesh, query, NULL);
    
    printf("Retrieved %d results\n", result->count);
    
    if (result->count > 0) {
        printf("Top result echo ID: %d\n", result->entries[0]->echo_id);
        printf("Match strength: %.2f\n", result->entries[0]->match_strength);
    }
    
    // Clean up resources
    free_activation_pattern(pattern);
    free_query_pattern(query);
    free_retrieval_result(result);
    nesh_free(nesh);
    
    return 0;
}

Wave Pattern Manipulation

// Demonstrate wave pattern manipulation
void demonstrate_wave_patterns() {
    // Initialize NESH with specific configuration
    nesh_config_t config = {
        .dimensions = 3,
        .resolution = (uint32_t[]){64, 64, 64}
    };
    NESH* nesh = nesh_init(&config);
    
    printf("Initialized NESH with 3D waveform field (64x64x64)\n");
    
    // Create harmonic wave components
    harmonic_components_t* components = create_harmonic_components(3);
    add_harmonic(components, 1.0f, 5.0f, 0.0f, (vector_t){1.0f, 0.0f, 0.0f});
    add_harmonic(components, 0.5f, 7.0f, PI/4, (vector_t){0.0f, 1.0f, 0.0f});
    add_harmonic(components, 0.3f, 11.0f, PI/2, (vector_t){0.0f, 0.0f, 1.0f});
    
    printf("Created harmonic components\n");
    
    // Apply components to field
    apply_harmonic_components(nesh->waveform_space, components);
    
    printf("Applied harmonic components to field\n");
    
    // Create interference pattern by adding second set of harmonics
    harmonic_components_t* components2 = create_harmonic_components(2);
    add_harmonic(components2, 0.7f, 6.0f, PI/3, (vector_t){0.7f, 0.7f, 0.0f});
    add_harmonic(components2, 0.4f, 9.0f, PI/6, (vector_t){0.5f, 0.0f, 0.5f});
    
    // Apply second set of components
    apply_harmonic_components(nesh->waveform_space, components2);
    
    printf("Applied second set of harmonics to create interference pattern\n");
    
    // Create visualization parameters
    visualization_params_t vis_params = {
        .width = 800,
        .height = 600,
        .axes = {0, 1}, // X-Y projection
        .color_mapping = COLOR_MAPPING_PHASE,
        .apply_post_processing = true
    };
    
    // Create visualization
    visualization_data_t* vis = visualize_waveform_field(
        nesh->waveform_space, &vis_params);
    
    printf("Created field visualization (%dx%d)\n", vis->width, vis->height);
    
    // Save visualization to file
    save_visualization_to_file(vis, "wave_pattern.png");
    
    printf("Saved visualization to wave_pattern.png\n");
    
    // Clean up resources
    free_harmonic_components(components);
    free_harmonic_components(components2);
    free_visualization_data(vis);
    nesh_free(nesh);
}

Temporal Memory Example

// Demonstrate temporal memory characteristics
void demonstrate_temporal_memory() {
    // Initialize NESH
    NESH* nesh = nesh_init(NULL);
    
    printf("Initialized NESH for temporal memory demonstration\n");
    
    // Create a sequence of activation patterns
    const int sequence_length = 5;
    activation_pattern_t* patterns[sequence_length];
    echo_t* echoes[sequence_length];
    
    // Create and store sequence of patterns
    for (int i = 0; i < sequence_length; i++) {
        // Create pattern with some sequential property
        patterns[i] = create_sequential_pattern(i);
        
        // Configure echo parameters with different strengths and decay rates
        echo_params_t params = {
            .initial_strength = 1.0f - (i * 0.1f), // Decreasing strength
            .decay_rate = 0.1f + (i * 0.05f)       // Increasing decay rate
        };
        
        // Store as echo
        echoes[i] = nesh_store_activation(nesh, patterns[i], ¶ms);
        
        printf("Stored pattern %d with strength %.2f and decay rate %.2f\n",
               i, params.initial_strength, params.decay_rate);
    }
    
    // Simulate time passing (10 seconds, 100ms steps)
    for (int t = 0; t < 100; t++) {
        nesh_update(nesh, 0.1);
        
        // Every 20 steps, check echo strengths
        if (t % 20 == 0) {
            printf("\nAfter %.1f seconds:\n", t * 0.1);
            for (int i = 0; i < sequence_length; i++) {
                printf("  Echo %d strength: %.3f\n", i, echoes[i]->current_strength);
            }
        }
        
        // At t=50, reinforce one of the echoes
        if (t == 50) {
            printf("\nReinforcing echo 2 at t=5.0s\n");
            reinforcement_params_t reinforce_params = {
                .reinforcement_strength = 0.5f,
                .full_renewal = true,
                .decay_adjustment_factor = 0.8f
            };
            reinforce_echo(nesh->waveform_space, echoes[2], &reinforce_params);
        }
    }
    
    // Try to retrieve using a query similar to pattern 2
    query_pattern_t* query = create_similar_query_pattern(patterns[2], 0.9f);
    
    // Set up retrieval parameters
    retrieval_params_t retrieve_params = {
        .threshold = 0.5f,
        .max_results = 3,
        .reinforce_on_retrieval = true,
        .reinforcement_strength = 0.3f
    };
    
    // Perform retrieval
    retrieval_result_t* result = nesh_retrieve(nesh, query, &retrieve_params);
    
    printf("\nRetrieval results for query similar to pattern 2:\n");
    for (uint32_t i = 0; i < result->count; i++) {
        printf("  Result %d: Echo ID %d, Match strength %.3f\n",
               i, result->entries[i]->echo_id, result->entries[i]->match_strength);
    }
    
    // Clean up resources
    for (int i = 0; i < sequence_length; i++) {
        free_activation_pattern(patterns[i]);
    }
    free_query_pattern(query);
    free_retrieval_result(result);
    nesh_free(nesh);
}

View more examples in our SDK Examples section or try the Interactive NESH Visualizer.

Next Steps