This commit is contained in:
Pascal Serrarens 2026-02-13 15:42:22 +01:00
parent f8aaa4ca80
commit 885d649be1
7 changed files with 20 additions and 45 deletions

View File

@ -339,10 +339,18 @@ public class Cluster : Nucleus {
}
public Nucleus GetNucleus(string nucleusName) {
foreach (Nucleus receptor in this.nuclei) {
if (receptor is Nucleus nucleus)
if (nucleus.name == nucleusName)
return nucleus;
foreach (Nucleus nucleus in this.nuclei) {
if (nucleus.name == nucleusName)
return nucleus;
}
return null;
}
public Receptor GetReceptor(string receptorName) {
foreach (Nucleus nucleus in this.nuclei) {
if (nucleus is Receptor receptor)
if (receptor.name == receptorName)
return receptor;
}
return null;
}

View File

@ -45,12 +45,6 @@ public class Neuron : Nucleus {
public CurvePresets curvePreset {
get { return _curvePreset; }
set {
// if (this.array != null && this.array.nuclei != null) {
// foreach (Neuron nucleus in this.array.nuclei.Cast<Neuron>()) {
// nucleus._curvePreset = value;
// nucleus.curve = GenerateCurve();
// }
// }
_curvePreset = value;
this.curve = GenerateCurve();
}
@ -196,7 +190,6 @@ public class Neuron : Nucleus {
foreach (Synapse synapse in this.synapses)
sum += synapse.weight * synapse.nucleus.outputValue;
return sum;
//this.outputValue = Activation(sum);
}
public float3 CombinatorProduct() {
@ -204,7 +197,6 @@ public class Neuron : Nucleus {
foreach (Synapse synapse in this.synapses)
product *= synapse.weight * synapse.nucleus.outputValue;
return product;
//this.outputValue = Activation(product);
}
public float3 CombinatorMax() {

View File

@ -90,44 +90,19 @@ public abstract class Nucleus {
#endregion Receivers
// [SerializeReference]
// private NucleusArray _array;
// public NucleusArray array {
// get { return _array; }
// set { _array = value; }
// }
#region Update
public abstract void UpdateStateIsolated();
public virtual void UpdateNuclei() {
// if (this.array == null || this.array.nuclei == null || this.array.nuclei.Length <= 1)
return;
// this.stale++;
// if (this.stale > staleValueForSleep) {
// //Debug.Log($"{this.name} goes to sleep, stale = {this.stale}");
// _outputValue = Vector3.zero;
// }
}
public virtual void ProcessStimulus(Vector3 inputValue, int thingId = 0, string thingName = null) {
//this.array.ProcessStimulus(thingId, inputValue, thingName);
// this.ProcessStimulus(inputValue);
public virtual void SetBias(Vector3 inputValue) {
this.stale = 0;
this.bias = inputValue;
this.parent.UpdateFromNucleus(this);
}
// public virtual void ProcessStimulus(int thingId, Vector3 inputValue, string thingName = null) {
// // this.array.ProcessStimulus(thingId, inputValue, thingName);
// // this.ProcessStimulus(inputValue);
// this.stale = 0;
// this.bias = inputValue;
// this.parent.UpdateFromNucleus(this);
// }
#endregion Update
}

View File

@ -130,7 +130,7 @@ public class NucleusArray {
// Remove a thing-receiver connection when the nucleus is inactive
List<int> receiversToRemove = new();
foreach (KeyValuePair<int, Nucleus> item in thingReceivers) {
if (item.Value.isSleeping)
if (item.Value != null && item.Value.isSleeping)
receiversToRemove.Add(item.Key);
}
foreach (int thingId in receiversToRemove) {

View File

@ -30,7 +30,6 @@ public class Receptor : Neuron {
set { _array = value; }
}
public override void UpdateStateIsolated() {
this.outputValue = this.bias;
}
@ -43,7 +42,8 @@ public class Receptor : Neuron {
}
}
public override void ProcessStimulus(Vector3 inputValue, int thingId = 0, string thingName = null) {
this.array.ProcessStimulus(thingId, inputValue, thingName);
public virtual void ProcessStimulus(Vector3 inputValue, int thingId = 0, string thingName = null) {
this.array ??= new NucleusArray(this.parent);
this.array.ProcessStimulus(thingId, inputValue, thingName);
}
}

View File

@ -141,7 +141,7 @@ public class ReceptorArray : Nucleus {
// public override void ProcessStimulus(int thingId, Vector3 inputValue, string thingName = null) {
// ProcessStimulus(inputValue, thingId, thingName);
// }
public override void ProcessStimulus(Vector3 inputValue, int thingId = 0, string thingName = null) {
public virtual void ProcessStimulus(Vector3 inputValue, int thingId = 0, string thingName = null) {
CleanupReceivers();
if (!thingReceivers.TryGetValue(thingId, out Nucleus selectedReceiver)) {
//Debug.Log($" no receiver found for {thingId}");

View File

@ -5,11 +5,11 @@ public class SelectorBrain : NanoBrain {
public Vector3 input2;
public Vector3 output;
public Nucleus receptor;
public Receptor receptor;
//public Nucleus receptor2;
protected void Awake() {
receptor = this.brain.GetNucleus("Selector");
receptor = this.brain.GetReceptor("Selector");
//receptor2 = this.brain.GetNucleus("Selector");
}