Simplifying stale nuclei
This commit is contained in:
parent
11ecb905ee
commit
14a786246c
@ -93,7 +93,8 @@ public class Neuroid : Nucleus {
|
|||||||
result /= this.synapses.Count;
|
result /= this.synapses.Count;
|
||||||
|
|
||||||
this.outputValue = Spherical.FromVector3(result);
|
this.outputValue = Spherical.FromVector3(result);
|
||||||
this.stale = 0;
|
//this.stale = 0;
|
||||||
|
this.Refresh();
|
||||||
|
|
||||||
foreach (Receiver receiver in this.receivers) {
|
foreach (Receiver receiver in this.receivers) {
|
||||||
if (receiver.nucleus is Neuroid neuroid)
|
if (receiver.nucleus is Neuroid neuroid)
|
||||||
|
|||||||
@ -64,10 +64,26 @@ public class Nucleus {
|
|||||||
|
|
||||||
public NanoBrainObj brain { get; set; }
|
public NanoBrainObj brain { get; set; }
|
||||||
|
|
||||||
public virtual Spherical outputValue { get; set; }
|
private Spherical _outputValue;
|
||||||
|
public Spherical outputValue //{ get; set; }
|
||||||
|
{
|
||||||
|
get { return _outputValue; }
|
||||||
|
set {
|
||||||
|
//Refresh();
|
||||||
|
this.stale = 0;
|
||||||
|
_outputValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[System.NonSerialized]
|
[System.NonSerialized]
|
||||||
public int stale = 0;
|
private int stale = 0;
|
||||||
|
public bool isSleeping => this.stale > 2;
|
||||||
|
public void Refresh() {
|
||||||
|
//this.stale = 0;
|
||||||
|
}
|
||||||
|
public void IncreaseAge() {
|
||||||
|
this.stale++;
|
||||||
|
}
|
||||||
[System.NonSerialized]
|
[System.NonSerialized]
|
||||||
public int layerIx;
|
public int layerIx;
|
||||||
|
|
||||||
@ -122,11 +138,11 @@ public class Nucleus {
|
|||||||
this.SetWeight(input, weight);
|
this.SetWeight(input, weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool isSleeping {
|
// public bool isSleeping {
|
||||||
get {
|
// get {
|
||||||
return this.stale > 2;
|
// return this.stale > 2;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public bool SynapseExists(Nucleus nucleus) {
|
public bool SynapseExists(Nucleus nucleus) {
|
||||||
foreach (Synapse synapse in synapses) {
|
foreach (Synapse synapse in synapses) {
|
||||||
|
|||||||
@ -118,7 +118,8 @@ public class Perceptoid : Neuroid {
|
|||||||
foreach (Receiver receiver in this.receivers)
|
foreach (Receiver receiver in this.receivers)
|
||||||
if (receiver.nucleus is Neuroid neuroid)
|
if (receiver.nucleus is Neuroid neuroid)
|
||||||
neuroid.SetInput(this);
|
neuroid.SetInput(this);
|
||||||
this.stale = 0;
|
//this.stale = 0;
|
||||||
|
this.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateState(int thingId, Spherical receptorValue) {
|
public void UpdateState(int thingId, Spherical receptorValue) {
|
||||||
@ -142,7 +143,8 @@ public class Perceptoid : Neuroid {
|
|||||||
foreach (Receiver receiver in this.receivers)
|
foreach (Receiver receiver in this.receivers)
|
||||||
if (receiver.nucleus is Neuroid neuroid)
|
if (receiver.nucleus is Neuroid neuroid)
|
||||||
neuroid.SetInput(this);
|
neuroid.SetInput(this);
|
||||||
this.stale = 0;
|
//this.stale = 0;
|
||||||
|
this.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -87,7 +87,8 @@ public class SensoryNeuroid : Neuroid {
|
|||||||
foreach (Receiver receiver in this.receivers)
|
foreach (Receiver receiver in this.receivers)
|
||||||
if (receiver.nucleus is Neuroid neuroid)
|
if (receiver.nucleus is Neuroid neuroid)
|
||||||
neuroid.SetInput(this);
|
neuroid.SetInput(this);
|
||||||
this.stale = 0;
|
//this.stale = 0;
|
||||||
|
this.Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +121,8 @@ public class VelocityNeuroid : Neuroid {
|
|||||||
|
|
||||||
// No activation function...
|
// No activation function...
|
||||||
this.outputValue = Spherical.FromVector3(velocity);
|
this.outputValue = Spherical.FromVector3(velocity);
|
||||||
this.stale = 0;
|
//this.stale = 0;
|
||||||
|
this.Refresh();
|
||||||
|
|
||||||
foreach (Receiver receiver in receivers) {
|
foreach (Receiver receiver in receivers) {
|
||||||
if (receiver.nucleus is Neuroid neuroid)
|
if (receiver.nucleus is Neuroid neuroid)
|
||||||
|
|||||||
@ -32,12 +32,14 @@ public class NanoBrainObj : ScriptableObject, ISerializationCallbackReceiver {
|
|||||||
|
|
||||||
public void UpdateNuclei() {
|
public void UpdateNuclei() {
|
||||||
foreach (Nucleus nucleus in nuclei) {
|
foreach (Nucleus nucleus in nuclei) {
|
||||||
nucleus.stale++;
|
//nucleus.stale++;
|
||||||
|
nucleus.IncreaseAge();
|
||||||
if (nucleus.isSleeping)
|
if (nucleus.isSleeping)
|
||||||
nucleus.outputValue = Spherical.zero;
|
nucleus.outputValue = Spherical.zero;
|
||||||
}
|
}
|
||||||
foreach (Perceptoid perception in perceptei) {
|
foreach (Perceptoid perception in perceptei) {
|
||||||
perception.stale++;
|
//perception.stale++;
|
||||||
|
perception.IncreaseAge();
|
||||||
if (perception.isSleeping)
|
if (perception.isSleeping)
|
||||||
perception.outputValue = Spherical.zero;
|
perception.outputValue = Spherical.zero;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -179,4 +179,4 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 92f34a5e4027a1dc39efd8ce63cf6aba, type: 3}
|
m_Script: {fileID: 11500000, guid: 92f34a5e4027a1dc39efd8ce63cf6aba, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::NanoBrainComponent
|
m_EditorClassIdentifier: Assembly-CSharp::NanoBrainComponent
|
||||||
defaultBrain: {fileID: 11400000, guid: af8d90b8b4b9dcad7837130c4143d91c, type: 2}
|
defaultBrain: {fileID: 11400000, guid: fc1a4800a8c531eb4855b436bc9084ae, type: 2}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ public class Swarming : Nucleus {
|
|||||||
|
|
||||||
public Neuroid output;
|
public Neuroid output;
|
||||||
|
|
||||||
public override Spherical outputValue { get => output.outputValue; set => output.outputValue = value; }
|
//public override Spherical outputValue { get => output.outputValue; set => output.outputValue = value; }
|
||||||
|
|
||||||
public Swarming(NanoBrainObj brain, Perception perception, SwarmControl sc) : base("Swarming Nucleus") {
|
public Swarming(NanoBrainObj brain, Perception perception, SwarmControl sc) : base("Swarming Nucleus") {
|
||||||
this.cohesion = new(brain, "Cohesion") { inverse = false };
|
this.cohesion = new(brain, "Cohesion") { inverse = false };
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user