diff --git a/Assets/NanoBrain/ClusterInstance.cs b/Assets/NanoBrain/ClusterInstance.cs index e54254d..1dbb40d 100644 --- a/Assets/NanoBrain/ClusterInstance.cs +++ b/Assets/NanoBrain/ClusterInstance.cs @@ -38,12 +38,15 @@ public class ClusterInstance : INucleus { #region Synapses - private Synapse[] _synapses = new Synapse[0]; + [SerializeReference] + private List _synapses = new(); public List synapses => new(_synapses); public Synapse AddSynapse(IReceptor sendingNucleus, string nucleusName = null) { if (nucleusName == null) { - this.asset.inputs[0].AddSynapse(sendingNucleus); + Synapse synapse = new(sendingNucleus); + this._synapses.Add(synapse); + // Nice, but this is not yet connected to the nucleusName } else { INucleus receptor = (INucleus)this.asset.nuclei.Find(nucleus => nucleus is INucleus n && nucleus.name == nucleusName); receptor.AddSynapse(sendingNucleus); diff --git a/Assets/NanoBrain/Neuron.cs b/Assets/NanoBrain/Neuron.cs index ff14d0c..df4e965 100644 --- a/Assets/NanoBrain/Neuron.cs +++ b/Assets/NanoBrain/Neuron.cs @@ -142,7 +142,7 @@ public class Neuron : INucleus { get { return _outputValue; } set { this.stale = 0; - this._isSleeping = false; + // this._isSleeping = false; _outputValue = value; } } @@ -150,14 +150,16 @@ public class Neuron : INucleus { [NonSerialized] private int stale = 1000; - private bool _isSleeping = false; - public bool isSleeping => _isSleeping; + // private bool _isSleeping = false; + // public bool isSleeping => _isSleeping; + public bool isSleeping => lengthsq(this.outputValue) == 0; public float lastTime { get; private set; } public void UpdateNuclei() { this.stale++; - this._isSleeping = this.stale > 2; - if (isSleeping) + // this._isSleeping = this.stale > 2; + // if (isSleeping) + if (this.stale > 2) _outputValue = Vector3.zero; } diff --git a/Assets/NanoBrain/VisualEditor/Editor/ClusterInspector.cs b/Assets/NanoBrain/VisualEditor/Editor/ClusterInspector.cs index cd4d6c7..f44105d 100644 --- a/Assets/NanoBrain/VisualEditor/Editor/ClusterInspector.cs +++ b/Assets/NanoBrain/VisualEditor/Editor/ClusterInspector.cs @@ -371,6 +371,11 @@ public class ClusterInspector : Editor { } private void DrawNucleus(IReceptor nucleus, Vector3 position, float maxValue, float size, Color color) { + if (nucleus is MemoryCell memory) { + Handles.color = Color.white; + Handles.DrawWireDisc(position + Vector3.right * 10, Vector3.forward, size); + } + Handles.color = color; Handles.DrawSolidDisc(position, Vector3.forward, size); @@ -489,8 +494,6 @@ public class ClusterInspector : Editor { this.currentNucleus.name = EditorGUILayout.TextField(this.currentNucleus.name); if (this.currentNucleus is Neuron neuroid) { if (this.currentNucleus is MemoryCell memory) { - // should use serializedProperty - memory.deltaValue = EditorGUILayout.Toggle("DeltaValue", memory.deltaValue); } else { EditorGUILayout.BeginHorizontal(); @@ -652,8 +655,8 @@ public class ClusterInspector : Editor { // Nucleus n = this.currentNucleus.brain.nuclei[selectedIndex - perceptei.Count()]; // n.AddReceiver(this.currentNucleus); // } - IReceptor n = cluster.nuclei[selectedIndex]; - n.AddReceiver(this.currentNucleus); + IReceptor receptor = cluster.nuclei[selectedIndex]; + receptor.AddReceiver(this.currentNucleus); } }