From d48475b48300ed4a066f7bfa6d74242980d2fc8a Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Thu, 5 Feb 2026 17:00:26 +0100 Subject: [PATCH] Removed IReceptor --- Cluster.cs | 30 +++++++++++++++--------------- ClusterPrefab.cs | 2 +- Editor/ClusterInspector.cs | 10 +++++----- INucleus.cs | 10 +++++----- MemoryCell.cs | 2 +- Neuron.cs | 4 ++-- Nucleus.cs | 4 ++-- NucleusArray.cs | 10 +++++----- Selector.cs | 2 +- 9 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Cluster.cs b/Cluster.cs index 5cacf3b..780b71a 100644 --- a/Cluster.cs +++ b/Cluster.cs @@ -80,7 +80,7 @@ public class Cluster : INucleus { // Copy nucleus arrays for (int nucleusIx = 0; nucleusIx < prefabNuclei.Length; nucleusIx++) { - IReceptor prefabReceptor = prefabNuclei[nucleusIx]; + INucleus prefabReceptor = prefabNuclei[nucleusIx]; if (prefabReceptor is not INucleus prefabNucleus) continue; @@ -92,9 +92,9 @@ public class Cluster : INucleus { // We clone the array only for the first entry NucleusArray clonedArray = new(prefabNucleus.array.nuclei.Length, "array"); int arrayIx = 0; - foreach (IReceptor prefabArrayNucleus in prefabNucleus.array.nuclei) { + foreach (INucleus prefabArrayNucleus in prefabNucleus.array.nuclei) { int arrayNucleusIx = GetNucleusIndex(prefabNuclei, prefabArrayNucleus); - IReceptor clonedArrayNucleus = clonedNuclei[arrayNucleusIx]; + INucleus clonedArrayNucleus = clonedNuclei[arrayNucleusIx]; clonedArray.nuclei[arrayIx] = clonedArrayNucleus; arrayIx++; } @@ -110,9 +110,9 @@ public class Cluster : INucleus { } // Sort the nuclei in a correct evaluation order - private List TopologicalSort(List nodes) { - Dictionary inDegree = new(); - foreach (IReceptor node in nodes) + private List TopologicalSort(List nodes) { + Dictionary inDegree = new(); + foreach (INucleus node in nodes) inDegree[node] = 0; // Initialize in-degree to zero // Calculate in-degrees @@ -127,7 +127,7 @@ public class Cluster : INucleus { queue.Enqueue(node); } - List sortedOrder = new(); + List sortedOrder = new(); while (queue.Count > 0) { INucleus current = queue.Dequeue(); sortedOrder.Add(current); // Process the node @@ -146,7 +146,7 @@ public class Cluster : INucleus { return sortedOrder; } - public virtual IReceptor Clone() { + public virtual INucleus Clone() { //Neuron clone = new(this.cluster, this.name) { Neuron clone = new(this.parent, this.name) { array = this.array, @@ -162,14 +162,14 @@ public class Cluster : INucleus { return clone; } - public IReceptor ShallowCloneTo(Cluster parent) { + public INucleus ShallowCloneTo(Cluster parent) { Cluster clone = new(this.prefab, parent) { name = this.name, }; return clone; } - private int GetNucleusIndex(IReceptor[] nucleiArray, IReceptor nucleus) { + private int GetNucleusIndex(INucleus[] nucleiArray, INucleus nucleus) { for (int i = 0; i < nucleiArray.Length; i++) { if (nucleus == nucleiArray[i]) return i; @@ -188,14 +188,14 @@ public class Cluster : INucleus { public List nuclei = new(); // the nuclei sorted using topological sorting // to ensure that the cluster is computer in the right order - public List sortedNuclei; + public List sortedNuclei; public List _inputs = null; public virtual List inputs { get { if (this._inputs == null) { this._inputs = new(); - foreach (IReceptor receptor in this.nuclei) { + foreach (INucleus receptor in this.nuclei) { if (receptor is INucleus nucleus) { // inputs have no incoming synapses yet. if (nucleus.synapses.Count == 0) @@ -224,7 +224,7 @@ public class Cluster : INucleus { } public bool TryGetNucleus(string nucleusName, out Nucleus foundNucleus) { - foreach (IReceptor receptor in this.nuclei) { + foreach (INucleus receptor in this.nuclei) { if (receptor is Nucleus nucleus) if (nucleus.name == nucleusName) { foundNucleus = nucleus; @@ -236,7 +236,7 @@ public class Cluster : INucleus { } public Nucleus GetNucleus(string nucleusName) { - foreach (IReceptor receptor in this.nuclei) { + foreach (INucleus receptor in this.nuclei) { if (receptor is Nucleus nucleus) if (nucleus.name == nucleusName) return nucleus; @@ -341,7 +341,7 @@ public class Cluster : INucleus { //this.inputs[0].UpdateState(sum); this.inputs[0].UpdateStateIsolated(sum); - foreach (IReceptor receptor in this.sortedNuclei) { + foreach (INucleus receptor in this.sortedNuclei) { if (receptor is INucleus nucleus && nucleus != this.inputs[0]) { //if (nucleus.isSleeping == false) nucleus.UpdateStateIsolated(); diff --git a/ClusterPrefab.cs b/ClusterPrefab.cs index 5116e81..694efaf 100644 --- a/ClusterPrefab.cs +++ b/ClusterPrefab.cs @@ -17,7 +17,7 @@ public class ClusterPrefab : ScriptableObject { get { if (this._inputs == null) { this._inputs = new(); - foreach (IReceptor receptor in this.nuclei) { + foreach (INucleus receptor in this.nuclei) { if (receptor is INucleus nucleus) { // inputs have no incoming synapses yet. if (nucleus.synapses.Count == 0) diff --git a/Editor/ClusterInspector.cs b/Editor/ClusterInspector.cs index e3020cd..333f8a5 100644 --- a/Editor/ClusterInspector.cs +++ b/Editor/ClusterInspector.cs @@ -71,7 +71,7 @@ public class ClusterInspector : Editor { INucleus currentNucleus; GameObject gameObject; private List layers = new(); - private readonly Dictionary neuroidPositions = new(); + private readonly Dictionary neuroidPositions = new(); private bool expandArray = false; ClusterWrapper currentWrapper; @@ -165,7 +165,7 @@ public class ClusterInspector : Editor { if (selectedNucleus.synapses != null) { foreach (Synapse synapse in selectedNucleus.synapses) { - IReceptor input = synapse.nucleus; + INucleus input = synapse.nucleus; AddToLayer(currentLayer, input); // Debug.Log($"layer {layerIx} nucleus {input.name}"); } @@ -175,7 +175,7 @@ public class ClusterInspector : Editor { } } - private void AddToLayer(NeuroidLayer layer, IReceptor nucleus) { + private void AddToLayer(NeuroidLayer layer, INucleus nucleus) { if (nucleus == null) return; layer.neuroids.Add(nucleus); @@ -449,7 +449,7 @@ public class ClusterInspector : Editor { GUI.Box(tooltipRect, tooltip); } - private void HandleClicked(IReceptor nucleus) { + private void HandleClicked(INucleus nucleus) { if (nucleus == this.currentNucleus) { if (nucleus is INucleus n) { expandArray = !expandArray; @@ -734,7 +734,7 @@ public class ClusterInspector : Editor { public class NeuroidLayer { public int ix = 0; - public List neuroids = new(); + public List neuroids = new(); } public class ClusterWrapper : ScriptableObject { diff --git a/INucleus.cs b/INucleus.cs index 7e0f2ee..4869d33 100644 --- a/INucleus.cs +++ b/INucleus.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Unity.Mathematics; -public interface INucleus : IReceptor { +public interface INucleus { #region static struct @@ -48,10 +48,10 @@ public interface INucleus : IReceptor { #endregion dynamic - public IReceptor ShallowCloneTo(Cluster parent); - public IReceptor Clone(); + public INucleus ShallowCloneTo(Cluster parent); + public INucleus Clone(); } -public interface IReceptor { -} +// public interface IReceptor { +// } diff --git a/MemoryCell.cs b/MemoryCell.cs index 643b039..3397bff 100644 --- a/MemoryCell.cs +++ b/MemoryCell.cs @@ -13,7 +13,7 @@ public class MemoryCell : Neuron, INucleus { // this.parent?.nuclei.Add(this); // } - public override IReceptor ShallowCloneTo(Cluster newParent) { + public override INucleus ShallowCloneTo(Cluster newParent) { MemoryCell clone = new(newParent, this.name) { array = this.array, curve = this.curve, diff --git a/Neuron.cs b/Neuron.cs index 2d29e3f..ca6ee25 100644 --- a/Neuron.cs +++ b/Neuron.cs @@ -181,7 +181,7 @@ public class Neuron : Nucleus, INucleus { #endregion Runtime state // this clone the nucleus without the synapses and receivers - public override IReceptor ShallowCloneTo(Cluster newParent) { + public override INucleus ShallowCloneTo(Cluster newParent) { Neuron clone = new(newParent, this.name) { array = null, curve = this.curve, @@ -192,7 +192,7 @@ public class Neuron : Nucleus, INucleus { return clone; } - public override IReceptor Clone() { + public override INucleus Clone() { //Neuron clone = new(this.cluster, this.name) { Neuron clone = new(this.parent, this.name) { array = this.array, diff --git a/Nucleus.cs b/Nucleus.cs index 605a16d..7511710 100644 --- a/Nucleus.cs +++ b/Nucleus.cs @@ -32,9 +32,9 @@ public abstract class Nucleus : INucleus { public int stale = 1000; // Cannot clone an abstract nucleus... - public virtual IReceptor ShallowCloneTo(Cluster parent) { return null; } + public virtual INucleus ShallowCloneTo(Cluster parent) { return null; } // Cannot clone an abstract nucleus... - public virtual IReceptor Clone() { return null; } + public virtual INucleus Clone() { return null; } #region Synapses diff --git a/NucleusArray.cs b/NucleusArray.cs index b16ad97..36d2417 100644 --- a/NucleusArray.cs +++ b/NucleusArray.cs @@ -5,8 +5,8 @@ using UnityEngine; [System.Serializable] public class NucleusArray { [SerializeReference] - private IReceptor[] _nuclei; - public IReceptor[] nuclei { + private INucleus[] _nuclei; + public INucleus[] nuclei { get { return _nuclei; } @@ -34,7 +34,7 @@ public class NucleusArray { return; } int newLength = this._nuclei.Length + 1; - IReceptor[] newArray = new INucleus[newLength]; + INucleus[] newArray = new INucleus[newLength]; for (int i = 0; i < this._nuclei.Length; i++) newArray[i] = this._nuclei[i]; @@ -50,7 +50,7 @@ public class NucleusArray { Debug.LogWarning("Perceptoid array cannot be empty"); return; } - IReceptor[] newPerceptei = new INucleus[newLength]; + INucleus[] newPerceptei = new INucleus[newLength]; for (int i = 0; i < newLength; i++) newPerceptei[i] = this._nuclei[i]; // Delete the last perception @@ -67,7 +67,7 @@ public class NucleusArray { CleanupReceivers(); if (!thingReceivers.TryGetValue(thingId, out INucleus selectedReceiver)) { Debug.Log($"No receiver found for {thingId}"); - foreach (IReceptor receptor in this.nuclei) { + foreach (INucleus receptor in this.nuclei) { if (receptor is not INucleus receiver) continue; diff --git a/Selector.cs b/Selector.cs index cb8a2ec..8cfe378 100644 --- a/Selector.cs +++ b/Selector.cs @@ -7,7 +7,7 @@ public class Selector : Neuron { public Selector(Cluster parent, string name) : base(parent, name) { } public Selector(ClusterPrefab parent, string name) : base(parent, name) {} - public override IReceptor ShallowCloneTo(Cluster newParent) { + public override INucleus ShallowCloneTo(Cluster newParent) { Selector clone = new(newParent, this.name) { array = this.array, curve = this.curve,