Cleanup
This commit is contained in:
parent
f8aaa4ca80
commit
885d649be1
12
Cluster.cs
12
Cluster.cs
@ -339,14 +339,22 @@ public class Cluster : Nucleus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Nucleus GetNucleus(string nucleusName) {
|
public Nucleus GetNucleus(string nucleusName) {
|
||||||
foreach (Nucleus receptor in this.nuclei) {
|
foreach (Nucleus nucleus in this.nuclei) {
|
||||||
if (receptor is Nucleus nucleus)
|
|
||||||
if (nucleus.name == nucleusName)
|
if (nucleus.name == nucleusName)
|
||||||
return nucleus;
|
return nucleus;
|
||||||
}
|
}
|
||||||
return null;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
#region Update
|
#region Update
|
||||||
|
|
||||||
public void UpdateFromNucleus(Nucleus startNucleus) {
|
public void UpdateFromNucleus(Nucleus startNucleus) {
|
||||||
|
|||||||
@ -45,12 +45,6 @@ public class Neuron : Nucleus {
|
|||||||
public CurvePresets curvePreset {
|
public CurvePresets curvePreset {
|
||||||
get { return _curvePreset; }
|
get { return _curvePreset; }
|
||||||
set {
|
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;
|
_curvePreset = value;
|
||||||
this.curve = GenerateCurve();
|
this.curve = GenerateCurve();
|
||||||
}
|
}
|
||||||
@ -196,7 +190,6 @@ public class Neuron : Nucleus {
|
|||||||
foreach (Synapse synapse in this.synapses)
|
foreach (Synapse synapse in this.synapses)
|
||||||
sum += synapse.weight * synapse.nucleus.outputValue;
|
sum += synapse.weight * synapse.nucleus.outputValue;
|
||||||
return sum;
|
return sum;
|
||||||
//this.outputValue = Activation(sum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float3 CombinatorProduct() {
|
public float3 CombinatorProduct() {
|
||||||
@ -204,7 +197,6 @@ public class Neuron : Nucleus {
|
|||||||
foreach (Synapse synapse in this.synapses)
|
foreach (Synapse synapse in this.synapses)
|
||||||
product *= synapse.weight * synapse.nucleus.outputValue;
|
product *= synapse.weight * synapse.nucleus.outputValue;
|
||||||
return product;
|
return product;
|
||||||
//this.outputValue = Activation(product);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float3 CombinatorMax() {
|
public float3 CombinatorMax() {
|
||||||
|
|||||||
27
Nucleus.cs
27
Nucleus.cs
@ -90,44 +90,19 @@ public abstract class Nucleus {
|
|||||||
|
|
||||||
#endregion Receivers
|
#endregion Receivers
|
||||||
|
|
||||||
// [SerializeReference]
|
|
||||||
// private NucleusArray _array;
|
|
||||||
// public NucleusArray array {
|
|
||||||
// get { return _array; }
|
|
||||||
// set { _array = value; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
#region Update
|
#region Update
|
||||||
|
|
||||||
public abstract void UpdateStateIsolated();
|
public abstract void UpdateStateIsolated();
|
||||||
|
|
||||||
public virtual void UpdateNuclei() {
|
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) {
|
public virtual void SetBias(Vector3 inputValue) {
|
||||||
//this.array.ProcessStimulus(thingId, inputValue, thingName);
|
|
||||||
// this.ProcessStimulus(inputValue);
|
|
||||||
this.stale = 0;
|
this.stale = 0;
|
||||||
this.bias = inputValue;
|
this.bias = inputValue;
|
||||||
this.parent.UpdateFromNucleus(this);
|
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
|
#endregion Update
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ public class NucleusArray {
|
|||||||
// Remove a thing-receiver connection when the nucleus is inactive
|
// Remove a thing-receiver connection when the nucleus is inactive
|
||||||
List<int> receiversToRemove = new();
|
List<int> receiversToRemove = new();
|
||||||
foreach (KeyValuePair<int, Nucleus> item in thingReceivers) {
|
foreach (KeyValuePair<int, Nucleus> item in thingReceivers) {
|
||||||
if (item.Value.isSleeping)
|
if (item.Value != null && item.Value.isSleeping)
|
||||||
receiversToRemove.Add(item.Key);
|
receiversToRemove.Add(item.Key);
|
||||||
}
|
}
|
||||||
foreach (int thingId in receiversToRemove) {
|
foreach (int thingId in receiversToRemove) {
|
||||||
|
|||||||
@ -30,7 +30,6 @@ public class Receptor : Neuron {
|
|||||||
set { _array = value; }
|
set { _array = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void UpdateStateIsolated() {
|
public override void UpdateStateIsolated() {
|
||||||
this.outputValue = this.bias;
|
this.outputValue = this.bias;
|
||||||
}
|
}
|
||||||
@ -43,7 +42,8 @@ public class Receptor : Neuron {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ProcessStimulus(Vector3 inputValue, int thingId = 0, string thingName = null) {
|
public virtual void ProcessStimulus(Vector3 inputValue, int thingId = 0, string thingName = null) {
|
||||||
|
this.array ??= new NucleusArray(this.parent);
|
||||||
this.array.ProcessStimulus(thingId, inputValue, thingName);
|
this.array.ProcessStimulus(thingId, inputValue, thingName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ public class ReceptorArray : Nucleus {
|
|||||||
// public override void ProcessStimulus(int thingId, Vector3 inputValue, string thingName = null) {
|
// public override void ProcessStimulus(int thingId, Vector3 inputValue, string thingName = null) {
|
||||||
// ProcessStimulus(inputValue, thingId, thingName);
|
// 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();
|
CleanupReceivers();
|
||||||
if (!thingReceivers.TryGetValue(thingId, out Nucleus selectedReceiver)) {
|
if (!thingReceivers.TryGetValue(thingId, out Nucleus selectedReceiver)) {
|
||||||
//Debug.Log($" no receiver found for {thingId}");
|
//Debug.Log($" no receiver found for {thingId}");
|
||||||
|
|||||||
@ -5,11 +5,11 @@ public class SelectorBrain : NanoBrain {
|
|||||||
public Vector3 input2;
|
public Vector3 input2;
|
||||||
public Vector3 output;
|
public Vector3 output;
|
||||||
|
|
||||||
public Nucleus receptor;
|
public Receptor receptor;
|
||||||
//public Nucleus receptor2;
|
//public Nucleus receptor2;
|
||||||
|
|
||||||
protected void Awake() {
|
protected void Awake() {
|
||||||
receptor = this.brain.GetNucleus("Selector");
|
receptor = this.brain.GetReceptor("Selector");
|
||||||
//receptor2 = this.brain.GetNucleus("Selector");
|
//receptor2 = this.brain.GetNucleus("Selector");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user