Adding synapse to cluster
This commit is contained in:
parent
8d1a4c3b72
commit
296b80453f
@ -38,12 +38,15 @@ public class ClusterInstance : INucleus {
|
|||||||
|
|
||||||
#region Synapses
|
#region Synapses
|
||||||
|
|
||||||
private Synapse[] _synapses = new Synapse[0];
|
[SerializeReference]
|
||||||
|
private List<Synapse> _synapses = new();
|
||||||
public List<Synapse> synapses => new(_synapses);
|
public List<Synapse> synapses => new(_synapses);
|
||||||
|
|
||||||
public Synapse AddSynapse(IReceptor sendingNucleus, string nucleusName = null) {
|
public Synapse AddSynapse(IReceptor sendingNucleus, string nucleusName = null) {
|
||||||
if (nucleusName == null) {
|
if (nucleusName == null) {
|
||||||
this.asset.inputs[0].AddSynapse(sendingNucleus);
|
Synapse synapse = new(sendingNucleus);
|
||||||
|
this._synapses.Add(synapse);
|
||||||
|
// Nice, but this is not yet connected to the nucleusName
|
||||||
} else {
|
} else {
|
||||||
INucleus receptor = (INucleus)this.asset.nuclei.Find(nucleus => nucleus is INucleus n && nucleus.name == nucleusName);
|
INucleus receptor = (INucleus)this.asset.nuclei.Find(nucleus => nucleus is INucleus n && nucleus.name == nucleusName);
|
||||||
receptor.AddSynapse(sendingNucleus);
|
receptor.AddSynapse(sendingNucleus);
|
||||||
|
|||||||
@ -142,7 +142,7 @@ public class Neuron : INucleus {
|
|||||||
get { return _outputValue; }
|
get { return _outputValue; }
|
||||||
set {
|
set {
|
||||||
this.stale = 0;
|
this.stale = 0;
|
||||||
this._isSleeping = false;
|
// this._isSleeping = false;
|
||||||
_outputValue = value;
|
_outputValue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,14 +150,16 @@ public class Neuron : INucleus {
|
|||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
private int stale = 1000;
|
private int stale = 1000;
|
||||||
|
|
||||||
private bool _isSleeping = false;
|
// private bool _isSleeping = false;
|
||||||
public bool isSleeping => _isSleeping;
|
// public bool isSleeping => _isSleeping;
|
||||||
|
public bool isSleeping => lengthsq(this.outputValue) == 0;
|
||||||
public float lastTime { get; private set; }
|
public float lastTime { get; private set; }
|
||||||
|
|
||||||
public void UpdateNuclei() {
|
public void UpdateNuclei() {
|
||||||
this.stale++;
|
this.stale++;
|
||||||
this._isSleeping = this.stale > 2;
|
// this._isSleeping = this.stale > 2;
|
||||||
if (isSleeping)
|
// if (isSleeping)
|
||||||
|
if (this.stale > 2)
|
||||||
_outputValue = Vector3.zero;
|
_outputValue = Vector3.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -371,6 +371,11 @@ public class ClusterInspector : Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DrawNucleus(IReceptor nucleus, Vector3 position, float maxValue, float size, Color color) {
|
private void DrawNucleus(IReceptor nucleus, Vector3 position, float maxValue, float size, Color color) {
|
||||||
|
if (nucleus is MemoryCell memory) {
|
||||||
|
Handles.color = Color.white;
|
||||||
|
Handles.DrawWireDisc(position + Vector3.right * 10, Vector3.forward, size);
|
||||||
|
}
|
||||||
|
|
||||||
Handles.color = color;
|
Handles.color = color;
|
||||||
Handles.DrawSolidDisc(position, Vector3.forward, size);
|
Handles.DrawSolidDisc(position, Vector3.forward, size);
|
||||||
|
|
||||||
@ -489,8 +494,6 @@ public class ClusterInspector : Editor {
|
|||||||
this.currentNucleus.name = EditorGUILayout.TextField(this.currentNucleus.name);
|
this.currentNucleus.name = EditorGUILayout.TextField(this.currentNucleus.name);
|
||||||
if (this.currentNucleus is Neuron neuroid) {
|
if (this.currentNucleus is Neuron neuroid) {
|
||||||
if (this.currentNucleus is MemoryCell memory) {
|
if (this.currentNucleus is MemoryCell memory) {
|
||||||
// should use serializedProperty
|
|
||||||
memory.deltaValue = EditorGUILayout.Toggle("DeltaValue", memory.deltaValue);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
EditorGUILayout.BeginHorizontal();
|
EditorGUILayout.BeginHorizontal();
|
||||||
@ -652,8 +655,8 @@ public class ClusterInspector : Editor {
|
|||||||
// Nucleus n = this.currentNucleus.brain.nuclei[selectedIndex - perceptei.Count()];
|
// Nucleus n = this.currentNucleus.brain.nuclei[selectedIndex - perceptei.Count()];
|
||||||
// n.AddReceiver(this.currentNucleus);
|
// n.AddReceiver(this.currentNucleus);
|
||||||
// }
|
// }
|
||||||
IReceptor n = cluster.nuclei[selectedIndex];
|
IReceptor receptor = cluster.nuclei[selectedIndex];
|
||||||
n.AddReceiver(this.currentNucleus);
|
receptor.AddReceiver(this.currentNucleus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user