Fix sleeping issue
This commit is contained in:
parent
57967e3409
commit
5584123c20
@ -102,6 +102,8 @@ namespace NanoBrain.Unity {
|
|||||||
cluster = SerializedPropertyUtility.GetManagedObjectForProperty(targetObject, property.propertyPath) as Cluster;
|
cluster = SerializedPropertyUtility.GetManagedObjectForProperty(targetObject, property.propertyPath) as Cluster;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// This does not work property yet it seems
|
||||||
|
Debug.Log("Instantiate");
|
||||||
ClusterPrefab clusterPrefab = prefabProp.objectReferenceValue as ClusterPrefab;
|
ClusterPrefab clusterPrefab = prefabProp.objectReferenceValue as ClusterPrefab;
|
||||||
cluster = new(clusterPrefab);
|
cluster = new(clusterPrefab);
|
||||||
object parent = SerializedPropertyUtility.GetParentObjectAndMember(targetObject, property.propertyPath, out var memberInfo, out int outIndex);
|
object parent = SerializedPropertyUtility.GetParentObjectAndMember(targetObject, property.propertyPath, out var memberInfo, out int outIndex);
|
||||||
|
|||||||
@ -351,13 +351,13 @@ namespace NanoBrain {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// True when the neuron is not persisting and has not be updated for timeToSleep seconds
|
/// True when the neuron is not persisting and has not be updated for timeToSleep seconds
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool isSleeping => !persistOutput && (Time.time - this.lastUpdate > this.timeToSleep);
|
public virtual bool isSleeping => !persistOutput && (Time.time - this.lastUpdate > timeToSleep);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the neuron is sleeping.
|
/// Check if the neuron is sleeping.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// This will reset the output value if it is sleeping
|
/// This will reset the output value if it is sleeping
|
||||||
public void SleepCheck() {
|
public void SleepCheck() {
|
||||||
if (this.isSleeping) {
|
if (this.isSleeping && this.outputSqrMagnitude > 0) {
|
||||||
#if UNITY_MATHEMATICS
|
#if UNITY_MATHEMATICS
|
||||||
this._outputValue = new float3(0, 0, 0);
|
this._outputValue = new float3(0, 0, 0);
|
||||||
#else
|
#else
|
||||||
@ -373,7 +373,9 @@ namespace NanoBrain {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Time in seconds after the last update the neuron can go to sleep
|
/// Time in seconds after the last update the neuron can go to sleep
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly float timeToSleep = 1f;
|
public static readonly float timeToSleep = 1f;
|
||||||
|
|
||||||
|
public bool breakOnUpdate = false;
|
||||||
|
|
||||||
/// \copydoc NanoBrain::Nucleus::ShallowCloneTo
|
/// \copydoc NanoBrain::Nucleus::ShallowCloneTo
|
||||||
public override Nucleus ShallowCloneTo(Cluster parent) {
|
public override Nucleus ShallowCloneTo(Cluster parent) {
|
||||||
@ -395,6 +397,7 @@ namespace NanoBrain {
|
|||||||
clone.curve = this.curve;
|
clone.curve = this.curve;
|
||||||
clone.activator = this.activator;
|
clone.activator = this.activator;
|
||||||
clone.curveMax = this.curveMax;
|
clone.curveMax = this.curveMax;
|
||||||
|
clone.breakOnUpdate = this.breakOnUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -445,6 +448,9 @@ namespace NanoBrain {
|
|||||||
|
|
||||||
/// \copydoc NanoBrain::Nucleus::UpdateStateIsolated
|
/// \copydoc NanoBrain::Nucleus::UpdateStateIsolated
|
||||||
public override void UpdateStateIsolated() {
|
public override void UpdateStateIsolated() {
|
||||||
|
if (breakOnUpdate) {
|
||||||
|
Debug.Break();
|
||||||
|
}
|
||||||
var combination = Combinator(this.bias, this.synapses);
|
var combination = Combinator(this.bias, this.synapses);
|
||||||
this.outputValue = Activator(combination);
|
this.outputValue = Activator(combination);
|
||||||
this.lastUpdate = Time.time;
|
this.lastUpdate = Time.time;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user