From 68b43ee476a450a6dfee9d41553c7cabda32c032 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Fri, 14 Aug 2026 17:01:25 +0200 Subject: [PATCH] Cleanup old sleep --- Runtime/Scripts/Core/Neuron.cs | 40 +++++++++++++++--------------- Runtime/Scripts/Core/Population.cs | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Runtime/Scripts/Core/Neuron.cs b/Runtime/Scripts/Core/Neuron.cs index 5d4e4ac..3b60353 100644 --- a/Runtime/Scripts/Core/Neuron.cs +++ b/Runtime/Scripts/Core/Neuron.cs @@ -121,7 +121,7 @@ namespace NanoBrain { /// public virtual void SetBias(Vector3 inputValue) { this.bias = inputValue; - this.lastUpdate = Time.time; + // this.lastUpdate = Time.time; this.parent?.UpdateFromNucleus(this); } @@ -251,30 +251,30 @@ namespace NanoBrain { /// /// True when the neuron is not persisting and has not be updated for timeToSleep seconds /// - public virtual bool isSleeping => false; //!persistOutput && (Time.time - this.lastUpdate > timeToSleep); + //public virtual bool isSleeping => false; //!persistOutput && (Time.time - this.lastUpdate > timeToSleep); /// /// Check if the neuron is sleeping. /// /// This will reset the output value if it is sleeping - public void SleepCheck() { - if (this.isSleeping && this.outputSqrMagnitude > 0) { -#if UNITY_MATHEMATICS - this._outputValue = new float3(0, 0, 0); -#else - this._outputValue = new Vector3(0,0,0); -#endif - } - } +// public void SleepCheck() { +// if (this.isSleeping && this.outputSqrMagnitude > 0) { +// #if UNITY_MATHEMATICS +// this._outputValue = new float3(0, 0, 0); +// #else +// this._outputValue = new Vector3(0,0,0); +// #endif +// } +// } /// /// The time at which the last update has been done /// - [HideInInspector] - public float lastUpdate = 0; + // [HideInInspector] + // public float lastUpdate = 0; /// /// Time in seconds after the last update the neuron can go to sleep /// - public static readonly float timeToSleep = 0.5f; + // public static readonly float timeToSleep = 0.5f; /// /// When true, Unity will pause exection when this neuron is updated @@ -402,7 +402,7 @@ namespace NanoBrain { } this.combination = Combinator(this.bias, this.synapses); this.outputValue = Activator(this.combination); - this.lastUpdate = Time.time; + // this.lastUpdate = Time.time; } #region Combinator @@ -437,8 +437,8 @@ namespace NanoBrain { public static float3 CombinatorSum(float3 bias, List synapses) { float3 sum = bias; foreach (Synapse synapse in synapses) { - synapse.neuron.SleepCheck(); - sum += synapse.weight * synapse.neuron.outputValue; + // synapse.neuron.SleepCheck(); + sum += synapse.weight * synapse.neuron._outputValue; } return sum; } @@ -452,8 +452,8 @@ namespace NanoBrain { public static float3 CombinatorProduct(float3 bias, List synapses) { float3 product = bias; foreach (Synapse synapse in synapses) { - synapse.neuron.SleepCheck(); - product *= synapse.weight * synapse.neuron.outputValue; + // synapse.neuron.SleepCheck(); + product *= synapse.weight * synapse.neuron._outputValue; } return product; } @@ -798,7 +798,7 @@ namespace NanoBrain { /// /// The value of the stimulus public virtual void ProcessStimulus(Vector3 inputValue, float autoResetDelay = 0) { - this.lastUpdate = Time.time; + // this.lastUpdate = Time.time; this.bias = inputValue; this.parent?.UpdateFromNucleus(this); this.resetStimulus ??= ResetStimulus; diff --git a/Runtime/Scripts/Core/Population.cs b/Runtime/Scripts/Core/Population.cs index 5b4c6ae..f854db5 100644 --- a/Runtime/Scripts/Core/Population.cs +++ b/Runtime/Scripts/Core/Population.cs @@ -88,7 +88,7 @@ namespace NanoBrain { member.brain.CopyWeightsFrom(ants[parent1].brain); member.brain.ProcessWeightsFrom(ants[parent2].brain, Average); // LogTrainableWeights(member.brain); - member.brain.GaussianAdditiveMutation(1e-1f); + member.brain.GaussianAdditiveMutation(1e-2f); // LogTrainableWeights(member.brain); }