1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/// The actual STDP learning rule was missing from the original codebase. Which was orginally too massive for me to manually extract. So I had AI Agent cdoer break it down from original codebase into smaller pieces. So I am now making the proper changes.
/// Orginally the algorithm lived in engine.rs. The orginal codebase had plascticity but this was missing it. So weights were static and never updated in this codebase, disconnected from learning.
/// The weights don't change immediately instead it records an eligibility trace of memory. Once a reward signal arrives (dopamine), you convert the eligibility trace into actual weight changes.
///
/// R-STDP (Reward based Spike-Timing-Dependent Plasticity) parameters.
///
/// ANALOGY: This is the "learning rule" — like Hebb's Rule on a timer.
/// "Neurons that fire together wire together" but only if the timing is right.
pub const RM_STDP_TAU_PLUS: f32 = 20.0; // LTP time constant (ms / steps)
pub const RM_STDP_TAU_MINUS: f32 = 20.0; // LTD time constant (ms / steps)
pub const RM_STDP_A_PLUS: f32 = 0.01; // Max LTP amplitude
pub const RM_STDP_A_MINUS: f32 = 0.012; // Max LTD amplitude (slightly stronger → stability)
pub const RM_STDP_W_MIN: f32 = 0.0; // Minimum weight (no negative / inhibitory yet)
pub const RM_STDP_W_MAX: f32 = 2.0; // Maximum weight (prevents runaway excitation)
// Newly added struct to track the state of a single synapse's eligibility trace
// Holds Rm-STDP hyperparameters
// Makes the trace decay each step on 'EligibilityTrace' struct