diff --git a/Assets/NanoBrain/Neuroid.cs b/Assets/NanoBrain/Neuroid.cs index ed9f88a..014533d 100644 --- a/Assets/NanoBrain/Neuroid.cs +++ b/Assets/NanoBrain/Neuroid.cs @@ -75,30 +75,19 @@ public class Neuroid : Nucleus { } public override void UpdateState() { - Vector3 sum = Vector3.zero; + Vector3 result = Vector3.zero; int n = 0; foreach (Synapse synapse in this.synapses) { - if (synapse.nucleus.isSleeping) - continue; - Vector3 outputValue = synapse.nucleus.outputValue; - float weight = synapse.weight; + // As this is the activation function, it should be evaluated in the synapse.nucleus... float activatedValue = curve.Evaluate(outputValue.magnitude); - float magnitude = weight * activatedValue; - //Spherical sVector = new(magnitude, outputValue.direction); + float magnitude = synapse.weight * activatedValue; - sum += magnitude * outputValue.normalized;//sVector.ToVector3(); + result += magnitude * outputValue.normalized; n++; } - - //Spherical result; - Vector3 result; if (average) - //result = Spherical.FromVector3(sum / n); - result = sum / n; - else - //result = Spherical.FromVector3(sum); - result = sum; + result /= n; UpdateResult(result); } diff --git a/Assets/NanoBrain/Nucleus.cs b/Assets/NanoBrain/Nucleus.cs index dbdb6ab..802ffcf 100644 --- a/Assets/NanoBrain/Nucleus.cs +++ b/Assets/NanoBrain/Nucleus.cs @@ -65,7 +65,7 @@ public class Nucleus { public NanoBrainObj brain { get; set; } private Vector3 _outputValue; - public Vector3 outputValue //{ get; set; } + public Vector3 outputValue { get { return _outputValue; } set { @@ -154,7 +154,7 @@ public class Nucleus { public virtual void UpdateState() { } public void UpdateResult(Vector3 result) { - // float d = Spherical.Distance(result, this.outputValue); + // float d = Vector3.Distance(result, this.outputValue); // if (d < 0.1f) { // //Debug.Log($"insignificant update: {d}"); // return;