Cleanup
This commit is contained in:
parent
1e5a19c1ab
commit
00dea149f3
117
Cluster.cs
117
Cluster.cs
@ -7,14 +7,6 @@ using static Unity.Mathematics.math;
|
|||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Cluster : Nucleus {
|
public class Cluster : Nucleus {
|
||||||
// The ScriptableObject asset from which the runtime object has been created
|
|
||||||
|
|
||||||
// [SerializeField]
|
|
||||||
// protected string _name;
|
|
||||||
// public virtual string name {
|
|
||||||
// get => _name;
|
|
||||||
// set => _name = value;
|
|
||||||
// }
|
|
||||||
|
|
||||||
#region Init
|
#region Init
|
||||||
|
|
||||||
@ -181,8 +173,6 @@ public class Cluster : Nucleus {
|
|||||||
|
|
||||||
public ClusterPrefab prefab;
|
public ClusterPrefab prefab;
|
||||||
|
|
||||||
// public ClusterPrefab cluster { get; set; }
|
|
||||||
// public Cluster parent { get; set; }
|
|
||||||
|
|
||||||
[SerializeReference]
|
[SerializeReference]
|
||||||
public List<Nucleus> nuclei = new();
|
public List<Nucleus> nuclei = new();
|
||||||
@ -215,14 +205,6 @@ public class Cluster : Nucleus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not sure if this belongs here...
|
|
||||||
// [SerializeReference]
|
|
||||||
// private NucleusArray _array;
|
|
||||||
// public NucleusArray array {
|
|
||||||
// get { return _array; }
|
|
||||||
// set { _array = value; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public bool TryGetNucleus(string nucleusName, out Nucleus foundNucleus) {
|
public bool TryGetNucleus(string nucleusName, out Nucleus foundNucleus) {
|
||||||
foreach (Nucleus receptor in this.nuclei) {
|
foreach (Nucleus receptor in this.nuclei) {
|
||||||
if (receptor is Nucleus nucleus)
|
if (receptor is Nucleus nucleus)
|
||||||
@ -244,92 +226,14 @@ public class Cluster : Nucleus {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Synapses
|
|
||||||
|
|
||||||
// [SerializeField]
|
|
||||||
// private List<Synapse> _synapses = new();
|
|
||||||
// public List<Synapse> synapses => _synapses;
|
|
||||||
|
|
||||||
// public Synapse AddSynapse(Nucleus sendingNucleus, float weight = 1.0f) {
|
|
||||||
// Synapse synapse = new(sendingNucleus, weight);
|
|
||||||
// this._synapses.Add(synapse);
|
|
||||||
// return synapse;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Does this even exist already?
|
|
||||||
public void RemoveSynapse() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Synapses
|
|
||||||
|
|
||||||
#region Receivers
|
|
||||||
|
|
||||||
// [SerializeReference]
|
|
||||||
// private List<Nucleus> _receivers = new();
|
|
||||||
// public List<Nucleus> receivers {
|
|
||||||
// get { return _receivers; }
|
|
||||||
// set { _receivers = value; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public virtual void AddReceiver(Nucleus receivingNucleus, float weight = 1) {
|
|
||||||
// this._receivers.Add(receivingNucleus);
|
|
||||||
// receivingNucleus.AddSynapse(this, weight);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void RemoveReceiver(Nucleus receiverNucleus) {
|
|
||||||
// this._receivers.RemoveAll(receiver => receiver == receiverNucleus);
|
|
||||||
// receiverNucleus.synapses.RemoveAll(synapse => synapse.nucleus == this);
|
|
||||||
// }
|
|
||||||
|
|
||||||
#endregion Receivers
|
|
||||||
|
|
||||||
#region Runtime
|
|
||||||
|
|
||||||
// [NonSerialized]
|
|
||||||
// private int stale = 1000;
|
|
||||||
// public bool isSleeping => lengthsq(this.outputValue) == 0;
|
|
||||||
|
|
||||||
// [NonSerialized]
|
|
||||||
// protected float3 _outputValue;
|
|
||||||
// public virtual float3 outputValue {
|
|
||||||
// get { return _outputValue; }
|
|
||||||
// set {
|
|
||||||
// this.stale = 0;
|
|
||||||
// _outputValue = value;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
#region Update
|
#region Update
|
||||||
|
|
||||||
// public virtual void UpdateState() {
|
|
||||||
// UpdateState(new float3(0, 0, 0));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void UpdateState(float3 bias) {
|
|
||||||
// float3 sum = bias; // new(0, 0, 0);
|
|
||||||
|
|
||||||
// //Applying the weight factors
|
|
||||||
// foreach (Synapse synapse in this.synapses) {
|
|
||||||
// sum += synapse.weight * synapse.nucleus.outputValue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //this.inputs[0].UpdateState(sum);
|
|
||||||
// this.inputs[0].UpdateStateIsolated(sum);
|
|
||||||
// foreach (IReceptor receptor in this.sortedNuclei) {
|
|
||||||
// if (receptor is Nucleus nucleus && nucleus != this.inputs[0])
|
|
||||||
// nucleus.UpdateStateIsolated();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// UpdateResult(this.output.outputValue);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public override void UpdateStateIsolated() {
|
public override void UpdateStateIsolated() {
|
||||||
float3 bias = new(0, 0, 0);
|
float3 bias = new(0, 0, 0);
|
||||||
UpdateStateIsolated(bias);
|
UpdateStateIsolated(bias);
|
||||||
}
|
}
|
||||||
public override void UpdateStateIsolated(float3 bias) {
|
public override void UpdateStateIsolated(float3 bias) {
|
||||||
float3 sum = bias; // new(0, 0, 0);
|
float3 sum = bias;
|
||||||
|
|
||||||
//Applying the weight factors
|
//Applying the weight factors
|
||||||
foreach (Synapse synapse in this.synapses) {
|
foreach (Synapse synapse in this.synapses) {
|
||||||
@ -339,42 +243,25 @@ public class Cluster : Nucleus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//this.inputs[0].UpdateState(sum);
|
|
||||||
this.inputs[0].UpdateStateIsolated(sum);
|
this.inputs[0].UpdateStateIsolated(sum);
|
||||||
foreach (Nucleus receptor in this.sortedNuclei) {
|
foreach (Nucleus receptor in this.sortedNuclei) {
|
||||||
if (receptor is Nucleus nucleus && nucleus != this.inputs[0]) {
|
if (receptor is Nucleus nucleus && nucleus != this.inputs[0])
|
||||||
//if (nucleus.isSleeping == false)
|
|
||||||
nucleus.UpdateStateIsolated();
|
nucleus.UpdateStateIsolated();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.outputValue = this.output.outputValue;
|
this.outputValue = this.output.outputValue;
|
||||||
|
|
||||||
UpdateNuclei();
|
UpdateNuclei();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public virtual void UpdateResult(Vector3 result) {
|
|
||||||
// // float d = Vector3.Distance(result, this.outputValue);
|
|
||||||
// // if (d < 0.5f) {
|
|
||||||
// // //Debug.Log($"insignificant update: {d}");
|
|
||||||
// // return;
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// this.outputValue = result;
|
|
||||||
// foreach (Nucleus receiver in this.receivers)
|
|
||||||
// receiver.UpdateState();
|
|
||||||
// }
|
|
||||||
|
|
||||||
public override void UpdateNuclei() {
|
public override void UpdateNuclei() {
|
||||||
this.stale++;
|
this.stale++;
|
||||||
if (this.stale > 5)
|
if (this.stale > 5)
|
||||||
_outputValue = Vector3.zero;
|
_outputValue = Vector3.zero;
|
||||||
|
|
||||||
//foreach (IReceptor nucleus in this.prefab.nuclei)
|
|
||||||
foreach (Nucleus nucleus in this.nuclei)
|
foreach (Nucleus nucleus in this.nuclei)
|
||||||
nucleus.UpdateNuclei();
|
nucleus.UpdateNuclei();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Update
|
#endregion Update
|
||||||
|
|
||||||
#endregion Runtime
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,30 +87,6 @@ public class NanoBrainComponent_Editor : Editor {
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void OnSceneGUI() {
|
|
||||||
// if (Application.isPlaying && board != null)
|
|
||||||
// board.OnIMGUI();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void OnSceneGui(SceneView sv) {
|
|
||||||
// if (Application.isPlaying == false)
|
|
||||||
// return;
|
|
||||||
// // May need some throttling here...
|
|
||||||
// if (board != null) {
|
|
||||||
// Debug.Log(".");
|
|
||||||
// board.OnIMGUI();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // EditorApplication.delayCall = UpdateInspectorUI;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void UpdateInspectorUI() {
|
|
||||||
// if (board != null) {
|
|
||||||
// Debug.Log(".");
|
|
||||||
// board.OnIMGUI();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
private void UpdateLayout(float containerWidth) {
|
private void UpdateLayout(float containerWidth) {
|
||||||
// if (containerWidth > 800f) {
|
// if (containerWidth > 800f) {
|
||||||
mainContainer.style.flexDirection = FlexDirection.Row;
|
mainContainer.style.flexDirection = FlexDirection.Row;
|
||||||
|
|||||||
59
INucleus.cs
59
INucleus.cs
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Unity.Mathematics;
|
|
||||||
|
|
||||||
public interface INucleus {
|
|
||||||
|
|
||||||
#region static struct
|
|
||||||
|
|
||||||
// Cluster
|
|
||||||
public ClusterPrefab cluster { get; }
|
|
||||||
public Cluster parent { get; }
|
|
||||||
|
|
||||||
// Senders
|
|
||||||
public List<Synapse> synapses { get; }
|
|
||||||
public Synapse AddSynapse(Nucleus sender, float weight = 1.0f);
|
|
||||||
|
|
||||||
public NucleusArray array { get; set; }
|
|
||||||
|
|
||||||
#endregion static struct
|
|
||||||
|
|
||||||
#region dynamic state
|
|
||||||
|
|
||||||
// public void UpdateState();
|
|
||||||
// public void UpdateState(float3 inputValue);
|
|
||||||
// public void UpdateStateIsolated();
|
|
||||||
// public void UpdateStateIsolated(float3 inputValue);
|
|
||||||
|
|
||||||
#endregion dynamic state
|
|
||||||
|
|
||||||
#region static
|
|
||||||
|
|
||||||
public string name { get; set; }
|
|
||||||
|
|
||||||
// Receivers
|
|
||||||
// public List<Nucleus> receivers { get; set; }
|
|
||||||
|
|
||||||
// public void AddReceiver(Nucleus receiver, float weight = 1);
|
|
||||||
// public void RemoveReceiver(Nucleus receiverNucleus);
|
|
||||||
|
|
||||||
#endregion static
|
|
||||||
|
|
||||||
#region dynamic
|
|
||||||
|
|
||||||
// float3 to prepare for SIMD
|
|
||||||
public float3 outputValue { get; }
|
|
||||||
|
|
||||||
public void UpdateNuclei();
|
|
||||||
public bool isSleeping { get; }
|
|
||||||
|
|
||||||
#endregion dynamic
|
|
||||||
|
|
||||||
// public INucleus ShallowCloneTo(Cluster parent);
|
|
||||||
// public INucleus Clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
// public interface IReceptor {
|
|
||||||
// }
|
|
||||||
|
|
||||||
*/
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6a8a0e8965cea660abff254cab8a4723
|
|
||||||
@ -8,10 +8,6 @@ public class MemoryCell : Neuron {
|
|||||||
|
|
||||||
public MemoryCell(ClusterPrefab cluster, string name) : base(cluster, name) { }
|
public MemoryCell(ClusterPrefab cluster, string name) : base(cluster, name) { }
|
||||||
public MemoryCell(Cluster parent, string name) : base(parent, name) { }
|
public MemoryCell(Cluster parent, string name) : base(parent, name) { }
|
||||||
// this.parent = parent;
|
|
||||||
// this.name = name;
|
|
||||||
// this.parent?.nuclei.Add(this);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public override Nucleus ShallowCloneTo(Cluster newParent) {
|
public override Nucleus ShallowCloneTo(Cluster newParent) {
|
||||||
MemoryCell clone = new(newParent, this.name) {
|
MemoryCell clone = new(newParent, this.name) {
|
||||||
@ -29,24 +25,6 @@ public class MemoryCell : Neuron {
|
|||||||
private float3 _memorizedValue;
|
private float3 _memorizedValue;
|
||||||
private float _memorizedTime;
|
private float _memorizedTime;
|
||||||
|
|
||||||
// public override void UpdateState(float3 bias) {
|
|
||||||
// // A memorycell does not have an activation function
|
|
||||||
// float3 result = bias;
|
|
||||||
// int n = 0;
|
|
||||||
|
|
||||||
// //Applying the weight factgors
|
|
||||||
// foreach (Synapse synapse in this.synapses) {
|
|
||||||
// result += synapse.weight * synapse.nucleus.outputValue;
|
|
||||||
// if (lengthsq(synapse.nucleus.outputValue) != 0)
|
|
||||||
// n++;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (this.average)
|
|
||||||
// result /= n;
|
|
||||||
|
|
||||||
// UpdateResult(result);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public override void UpdateStateIsolated() {
|
public override void UpdateStateIsolated() {
|
||||||
float3 bias = new(0, 0, 0);
|
float3 bias = new(0, 0, 0);
|
||||||
UpdateStateIsolated(bias);
|
UpdateStateIsolated(bias);
|
||||||
@ -73,22 +51,5 @@ public class MemoryCell : Neuron {
|
|||||||
this._memorizedTime = Time.time;
|
this._memorizedTime = Time.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public override void UpdateResult(Vector3 result) {
|
|
||||||
// // output value is the previous value
|
|
||||||
// // if (this.deltaValue) {
|
|
||||||
// // float deltaTime = Time.time - this._memorizedTime;
|
|
||||||
// // this._outputValue = this._memorizedValue * deltaTime;
|
|
||||||
// // }
|
|
||||||
// //else
|
|
||||||
// this.outputValue = this._memorizedValue;
|
|
||||||
|
|
||||||
// // Store the result for the next time
|
|
||||||
// this._memorizedValue = result;
|
|
||||||
// this._memorizedTime = Time.time;
|
|
||||||
|
|
||||||
// foreach (INucleus receiver in this.receivers)
|
|
||||||
// receiver.UpdateState();
|
|
||||||
// }
|
|
||||||
|
|
||||||
#endregion State
|
#endregion State
|
||||||
}
|
}
|
||||||
|
|||||||
12
NanoBrain.cs
12
NanoBrain.cs
@ -13,22 +13,10 @@ public class NanoBrain : MonoBehaviour {
|
|||||||
name = defaultBrain.name + " (Instance)"
|
name = defaultBrain.name + " (Instance)"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// SwarmControl sc = FindFirstObjectByType<SwarmControl>();
|
|
||||||
// if (sc != null) {
|
|
||||||
// UpdateWeight(brainInstance, "Containment", sc.containmentForce);
|
|
||||||
// UpdateWeight(brainInstance, "Cohesion", sc.cohesionForce);
|
|
||||||
// UpdateWeight(brainInstance, "Separation", sc.separationForce);
|
|
||||||
// UpdateWeight(brainInstance, "Alignment", sc.alignmentForce);
|
|
||||||
// }
|
|
||||||
return brainInstance;
|
return brainInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void Awake() {
|
|
||||||
// brainInstance = new Cluster(defaultBrain);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
public static void UpdateWeight(Cluster brain, string name, float weight) {
|
public static void UpdateWeight(Cluster brain, string name, float weight) {
|
||||||
Nucleus root = brain.output;
|
Nucleus root = brain.output;
|
||||||
foreach (Synapse synapse in root.synapses) {
|
foreach (Synapse synapse in root.synapses) {
|
||||||
|
|||||||
133
Neuron.cs
133
Neuron.cs
@ -24,31 +24,6 @@ public class Neuron : Nucleus {
|
|||||||
// Debug.LogError("No neuroid network");
|
// Debug.LogError("No neuroid network");
|
||||||
}
|
}
|
||||||
|
|
||||||
// [SerializeField]
|
|
||||||
// protected string _name;
|
|
||||||
// public virtual string name {
|
|
||||||
// get => _name;
|
|
||||||
// set => _name = value;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [SerializeField]
|
|
||||||
// private List<Synapse> _synapses = new();
|
|
||||||
// public List<Synapse> synapses => _synapses;
|
|
||||||
|
|
||||||
// [SerializeReference]
|
|
||||||
// private List<INucleus> _receivers = new();
|
|
||||||
// public List<INucleus> receivers {
|
|
||||||
// get { return _receivers; }
|
|
||||||
// set { _receivers = value; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [SerializeReference]
|
|
||||||
// private NucleusArray _array;
|
|
||||||
// public NucleusArray array {
|
|
||||||
// get { return _array; }
|
|
||||||
// set { _array = value; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
#region Serialization
|
#region Serialization
|
||||||
|
|
||||||
public enum CurvePresets {
|
public enum CurvePresets {
|
||||||
@ -102,9 +77,6 @@ public class Neuron : Nucleus {
|
|||||||
|
|
||||||
#region Runtime state (not serialized)
|
#region Runtime state (not serialized)
|
||||||
|
|
||||||
// public ClusterPrefab cluster { get; set; }
|
|
||||||
// public Cluster parent { get; set; }
|
|
||||||
|
|
||||||
#region Activation
|
#region Activation
|
||||||
|
|
||||||
public static class Presets {
|
public static class Presets {
|
||||||
@ -153,31 +125,6 @@ public class Neuron : Nucleus {
|
|||||||
|
|
||||||
#endregion Activation
|
#endregion Activation
|
||||||
|
|
||||||
// protected float3 _outputValue;
|
|
||||||
// public virtual float3 outputValue {
|
|
||||||
// get { return _outputValue; }
|
|
||||||
// set {
|
|
||||||
// this.stale = 0;
|
|
||||||
// // this._isSleeping = false;
|
|
||||||
// _outputValue = value;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [NonSerialized]
|
|
||||||
// private int stale = 1000;
|
|
||||||
|
|
||||||
// private bool _isSleeping = false;
|
|
||||||
// public bool isSleeping => _isSleeping;
|
|
||||||
// public bool isSleeping => lengthsq(this.outputValue) == 0;
|
|
||||||
|
|
||||||
// public void UpdateNuclei() {
|
|
||||||
// this.stale++;
|
|
||||||
// // this._isSleeping = this.stale > 2;
|
|
||||||
// // if (isSleeping)
|
|
||||||
// if (this.stale > 2)
|
|
||||||
// _outputValue = Vector3.zero;
|
|
||||||
// }
|
|
||||||
|
|
||||||
#endregion Runtime state
|
#endregion Runtime state
|
||||||
|
|
||||||
// this clone the nucleus without the synapses and receivers
|
// this clone the nucleus without the synapses and receivers
|
||||||
@ -214,16 +161,6 @@ public class Neuron : Nucleus {
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public virtual void AddReceiver(INucleus receivingNucleus, float weight = 1) {
|
|
||||||
// this._receivers.Add(receivingNucleus);
|
|
||||||
// receivingNucleus.AddSynapse(this, weight);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void RemoveReceiver(INucleus receiverNucleus) {
|
|
||||||
// this._receivers.RemoveAll(receiver => receiver == receiverNucleus);
|
|
||||||
// receiverNucleus.synapses.RemoveAll(synapse => synapse.nucleus == this);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static void Delete(Nucleus nucleus) {
|
public static void Delete(Nucleus nucleus) {
|
||||||
foreach (Synapse synapse in nucleus.synapses) {
|
foreach (Synapse synapse in nucleus.synapses) {
|
||||||
if (synapse.nucleus is Neuron synapse_nucleus) {
|
if (synapse.nucleus is Neuron synapse_nucleus) {
|
||||||
@ -248,59 +185,6 @@ public class Neuron : Nucleus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public Synapse AddSynapse(IReceptor sendingNucleus, float weight = 1.0f) {
|
|
||||||
// Synapse synapse = new(sendingNucleus, weight);
|
|
||||||
// this.synapses.Add(synapse);
|
|
||||||
// return synapse;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public virtual void UpdateState() {
|
|
||||||
// //UpdateState(new float3(0, 0, 0));
|
|
||||||
// this.parent?.UpdateState();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public virtual void UpdateState(float3 inputValue) {
|
|
||||||
// float3 sum = inputValue;
|
|
||||||
// int n = 0;
|
|
||||||
|
|
||||||
// //Applying the weight factgors
|
|
||||||
// foreach (Synapse synapse in this.synapses) {
|
|
||||||
// sum += synapse.weight * synapse.nucleus.outputValue;
|
|
||||||
|
|
||||||
// // Perhaps synapses should be removed when the output value goes to 0....
|
|
||||||
// if (lengthsq(synapse.nucleus.outputValue) != 0)
|
|
||||||
// n++;
|
|
||||||
// }
|
|
||||||
// if (this.average && n > 0)
|
|
||||||
// sum /= n;
|
|
||||||
|
|
||||||
// // Activation function
|
|
||||||
// Vector3 result;
|
|
||||||
// switch (this.curvePreset) {
|
|
||||||
// case CurvePresets.Linear:
|
|
||||||
// result = sum;
|
|
||||||
// break;
|
|
||||||
// case CurvePresets.Sqrt:
|
|
||||||
// result = normalize(sum) * System.MathF.Sqrt(length(sum));
|
|
||||||
// break;
|
|
||||||
// case CurvePresets.Power:
|
|
||||||
// result = normalize(sum) * System.MathF.Pow(length(sum), 2);
|
|
||||||
// break;
|
|
||||||
// case CurvePresets.Reciprocal:
|
|
||||||
// result = normalize(sum) * (1 / length(sum));
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// float activatedValue = this.curve.Evaluate(length(sum));
|
|
||||||
// result = normalize(sum) * activatedValue;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// UpdateResult(result);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public virtual void UpdateStateIsolated() {
|
|
||||||
// UpdateStateIsolated(new float3(0, 0, 0));
|
|
||||||
// }
|
|
||||||
|
|
||||||
public float3 bias = float3(0, 0, 0);
|
public float3 bias = float3(0, 0, 0);
|
||||||
public override void UpdateStateIsolated(float3 bias_unused) {
|
public override void UpdateStateIsolated(float3 bias_unused) {
|
||||||
float3 sum = this.bias;
|
float3 sum = this.bias;
|
||||||
@ -354,21 +238,4 @@ public class Neuron : Nucleus {
|
|||||||
//Debug.Log($"{this.name} processed stimulus");
|
//Debug.Log($"{this.name} processed stimulus");
|
||||||
this.bias = inputValue;
|
this.bias = inputValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public virtual void UpdateResult(Vector3 result) {
|
|
||||||
// // float d = Vector3.Distance(result, this.outputValue);
|
|
||||||
// // if (d < 0.5f) {
|
|
||||||
// // //Debug.Log($"insignificant update: {d}");
|
|
||||||
// // return;
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// this.outputValue = result;
|
|
||||||
// if (lengthsq(outputValue) != 0) {
|
|
||||||
// Debug.Log($"{this.parent.name}.{this.name}: {this.outputValue}");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// foreach (INucleus receiver in this.receivers)
|
|
||||||
// receiver.UpdateState();
|
|
||||||
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user