diff --git a/Cluster.cs b/Cluster.cs index c605d76..40641ef 100644 --- a/Cluster.cs +++ b/Cluster.cs @@ -99,7 +99,7 @@ public class Cluster : Nucleus { clonedArray.nuclei[arrayIx] = clonedArrayNucleus; } else { - Debug.LogError($" Could not find prefab nuclues {prefabNucleus.name} in the clones"); + Debug.LogError($" Could not find prefab nucleus {prefabNucleus.name} in the clones"); } arrayIx++; } diff --git a/ClusterReceptor.cs b/ClusterReceptor.cs index 3df0d35..5039458 100644 --- a/ClusterReceptor.cs +++ b/ClusterReceptor.cs @@ -103,7 +103,7 @@ public class ClusterReceptor : Cluster, IReceptor { nucleus.UpdateNuclei(); } - public virtual void ProcessStimulus(Vector3 inputValue, int thingId = 0, string thingName = null) { + public override void ProcessStimulus(Vector3 inputValue, int thingId = 0, string thingName = null) { this.array ??= new NucleusArray(this.parent); this.array.ProcessStimulus(thingId, inputValue, thingName); } diff --git a/Editor/ClusterInspector.cs b/Editor/ClusterInspector.cs index f0b9948..b597132 100644 --- a/Editor/ClusterInspector.cs +++ b/Editor/ClusterInspector.cs @@ -606,11 +606,11 @@ public class ClusterInspector : Editor { else expandArray = false; } - else if (nucleus is ReceptorInstance receptor) { - this.currentNucleus = receptor.receptor; - expandArray = false; - BuildLayers(); - } + // else if (nucleus is ReceptorInstance receptor) { + // this.currentNucleus = receptor.receptor; + // expandArray = false; + // BuildLayers(); + // } else { this.currentNucleus = nucleus; expandArray = false; @@ -674,21 +674,21 @@ public class ClusterInspector : Editor { if (this.currentNucleus is MemoryCell memory) { memory.staticMemory = EditorGUILayout.Toggle("Static Memory", memory.staticMemory); } - if (this.currentNucleus is ReceptorArray receptor) { - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.IntField("Receptor size", receptor.instances.Count()); - if (GUILayout.Button("Add")) { - Undo.RecordObject(prefabAsset, "Receptor add " + prefabAsset.name); - receptor.AddReceptor(this.prefab); - anythingChanged = true; - } - if (GUILayout.Button("Del")) { - Undo.RecordObject(prefabAsset, "Receptor delete " + prefabAsset.name); - receptor.RemoveReceptor(); - anythingChanged = true; - } - EditorGUILayout.EndHorizontal(); - } + // if (this.currentNucleus is ReceptorArray receptor) { + // EditorGUILayout.BeginHorizontal(); + // EditorGUILayout.IntField("Receptor size", receptor.instances.Count()); + // if (GUILayout.Button("Add")) { + // Undo.RecordObject(prefabAsset, "Receptor add " + prefabAsset.name); + // receptor.AddReceptor(this.prefab); + // anythingChanged = true; + // } + // if (GUILayout.Button("Del")) { + // Undo.RecordObject(prefabAsset, "Receptor delete " + prefabAsset.name); + // receptor.RemoveReceptor(); + // anythingChanged = true; + // } + // EditorGUILayout.EndHorizontal(); + // } if (this.currentNucleus is Receptor receptor1) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.IntField("Array size", receptor1.nucleiArray.Count()); @@ -857,28 +857,28 @@ public class ClusterInspector : Editor { void OnSceneGUI(SceneView sceneView) { if (this.gameObject != null) { - if (this.currentNucleus is ReceptorArray receptor && expandArray) { - foreach (Nucleus nucleus in receptor.instances) { + // if (this.currentNucleus is ReceptorArray receptor && expandArray) { + // foreach (Nucleus nucleus in receptor.instances) { + // Vector3 worldVector = this.gameObject.transform.TransformVector(nucleus.outputValue); + // Handles.color = Color.yellow; + // Handles.DrawLine(this.gameObject.transform.position, this.gameObject.transform.position + worldVector); + // } + // } + // else { + if (this.currentNucleus is Receptor receptor1) { + foreach (Nucleus nucleus in receptor1.nucleiArray) { Vector3 worldVector = this.gameObject.transform.TransformVector(nucleus.outputValue); Handles.color = Color.yellow; Handles.DrawLine(this.gameObject.transform.position, this.gameObject.transform.position + worldVector); } } else { - if (this.currentNucleus is Receptor receptor1) { - foreach (Nucleus nucleus in receptor1.nucleiArray) { - Vector3 worldVector = this.gameObject.transform.TransformVector(nucleus.outputValue); - Handles.color = Color.yellow; - Handles.DrawLine(this.gameObject.transform.position, this.gameObject.transform.position + worldVector); - } - } - else { - Vector3 worldVector = this.gameObject.transform.TransformVector(this.currentNucleus.outputValue); - Handles.color = Color.yellow; - Handles.DrawLine(this.gameObject.transform.position, this.gameObject.transform.position + worldVector); + Vector3 worldVector = this.gameObject.transform.TransformVector(this.currentNucleus.outputValue); + Handles.color = Color.yellow; + Handles.DrawLine(this.gameObject.transform.position, this.gameObject.transform.position + worldVector); - } } + // } } } @@ -904,9 +904,9 @@ public class ClusterInspector : Editor { case Nucleus.Type.Receptor: AddReceptorInput(nucleus); break; - case Nucleus.Type.ReceptorArray: - AddReceptorArrayInput(nucleus); - break; + // case Nucleus.Type.ReceptorArray: + // AddReceptorArrayInput(nucleus); + // break; case Nucleus.Type.ClusterReceptor: AddClusterReceptorInput(nucleus); break; @@ -993,7 +993,12 @@ public class ClusterInspector : Editor { IEnumerable nuclei = cluster.nuclei .Except(synapseNuclei); - IEnumerable nucleiNames = nuclei.Select(n => n.name); + IEnumerable nucleiNames = nuclei + .Select(n => { + int idx = n.name.IndexOf(':'); + return idx < 0 ? n.name : n.name[..idx]; + }) + .Distinct(); string[] names = nucleiNames.ToArray(); int selectedIndex = -1; @@ -1002,7 +1007,9 @@ public class ClusterInspector : Editor { return false; Nucleus nucleus = nuclei.ElementAt(selectedIndex); - if (nucleus is Neuron neuron) + if (nucleus is Receptor receptor) + receptor.AddArrayReceiver(this.currentNucleus); + else if (nucleus is Neuron neuron) neuron.AddReceiver(this.currentNucleus); else if (nucleus is Cluster subCluster) subCluster.defaultOutput.AddReceiver(this.currentNucleus); diff --git a/Neuron.cs b/Neuron.cs index 5b33597..8fcc529 100644 --- a/Neuron.cs +++ b/Neuron.cs @@ -211,16 +211,16 @@ public class Neuron : Nucleus { public float3 CombinatorMax() { float3 max = this.bias; - float maxSqrLength = lengthsq(max); + float maxLength = length(max); //Applying the weight factors foreach (Synapse synapse in this.synapses) { float3 input = synapse.weight * synapse.nucleus.outputValue; - float inputSqrlength = lengthsq(input); - if (inputSqrlength > maxSqrLength) { + float inputLength = length(input); + if (inputLength > maxLength) { max = input; - maxSqrLength = inputSqrlength; + maxLength = inputLength; } } return max; diff --git a/Nucleus.cs b/Nucleus.cs index 78fed33..cf4ff74 100644 --- a/Nucleus.cs +++ b/Nucleus.cs @@ -42,7 +42,7 @@ public abstract class Nucleus { Cluster, Pulsar, Receptor, - ReceptorArray, + // ReceptorArray, ClusterReceptor, } diff --git a/Receptor.cs b/Receptor.cs index 8d84bcb..e89837c 100644 --- a/Receptor.cs +++ b/Receptor.cs @@ -55,6 +55,15 @@ public class Receptor : Neuron, IReceptor { this.nucleiArray = IReceptorHelpers.RemoveReceptorElement(this.nucleiArray); } + // public override void AddReceiver(Nucleus receiverToAdd, float weight = 1) { + // foreach (Nucleus element in receptorToAdd.nucleiArray) { + // if (element is Neuron neuron) { + // neuron._receivers.Add(receiverToAdd); + // receiverToAdd.AddSynapse(element, weight); + // } + // } + + // } public virtual void AddArrayReceiver(Nucleus receiverToAdd, float weight = 1) { foreach (Nucleus element in this._array.nuclei) { if (element is Neuron neuron) { diff --git a/ReceptorArray.cs b/ReceptorArray.cs index 35e1a90..00c8bbb 100644 --- a/ReceptorArray.cs +++ b/ReceptorArray.cs @@ -1,3 +1,4 @@ +/* using System; using System.Collections.Generic; using System.Linq; @@ -258,4 +259,5 @@ public class ReceptorArray : Nucleus { } } } -} \ No newline at end of file +} +*/ \ No newline at end of file