Simplify/improve UpdateStateIsolated
This commit is contained in:
parent
6f67def8e6
commit
d562c7192b
22
Cluster.cs
22
Cluster.cs
@ -91,9 +91,10 @@ public class Cluster : Nucleus {
|
||||
foreach (Nucleus prefabArrayNucleus in prefabNucleus.array.nuclei) {
|
||||
int arrayNucleusIx = GetNucleusIndex(prefabNuclei, prefabArrayNucleus);
|
||||
if (arrayNucleusIx >= 0) {
|
||||
Nucleus clonedArrayNucleus = clonedNuclei[arrayNucleusIx];
|
||||
clonedArray.nuclei[arrayIx] = clonedArrayNucleus;
|
||||
} else {
|
||||
Nucleus clonedArrayNucleus = clonedNuclei[arrayNucleusIx];
|
||||
clonedArray.nuclei[arrayIx] = clonedArrayNucleus;
|
||||
}
|
||||
else {
|
||||
Debug.LogError($" Could not find prefab nuclues {prefabNucleus.name} in the clones");
|
||||
}
|
||||
arrayIx++;
|
||||
@ -250,11 +251,7 @@ public class Cluster : Nucleus {
|
||||
#region Update
|
||||
|
||||
public override void UpdateStateIsolated() {
|
||||
float3 bias = new(0, 0, 0);
|
||||
UpdateStateIsolated(bias);
|
||||
}
|
||||
public override void UpdateStateIsolated(float3 bias) {
|
||||
Vector3 sum = bias;
|
||||
Vector3 sum = this.bias;
|
||||
|
||||
//Applying the weight factors
|
||||
foreach (Synapse synapse in this.synapses) {
|
||||
@ -264,12 +261,11 @@ public class Cluster : Nucleus {
|
||||
}
|
||||
}
|
||||
|
||||
this.inputs[0].UpdateStateIsolated(sum);
|
||||
foreach (Nucleus receptor in this.sortedNuclei) {
|
||||
if (receptor is Nucleus nucleus && nucleus != this.inputs[0])
|
||||
nucleus.UpdateStateIsolated();
|
||||
}
|
||||
foreach (Nucleus nucleus in this.sortedNuclei)
|
||||
nucleus.UpdateStateIsolated();
|
||||
|
||||
this.outputValue = this.output.outputValue;
|
||||
this.stale = 0;
|
||||
|
||||
UpdateNuclei();
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor.UIElements;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
@ -27,6 +29,13 @@ public class NanoBrainComponent_Editor : Editor {
|
||||
|
||||
|
||||
VisualElement root = new();
|
||||
if (Application.isPlaying == false) {
|
||||
PropertyField brainField = new(brainProp) {
|
||||
label = "Nano Brain"
|
||||
};
|
||||
root.Add(brainField);
|
||||
}
|
||||
|
||||
ClusterInspector.CreateInspector(root, brain.prefab, brain.output, component.gameObject);
|
||||
|
||||
if (Application.isPlaying == false)
|
||||
|
||||
@ -25,13 +25,13 @@ public class MemoryCell : Neuron {
|
||||
private float3 _memorizedValue;
|
||||
private float _memorizedTime;
|
||||
|
||||
public override void UpdateStateIsolated() {
|
||||
float3 bias = new(0, 0, 0);
|
||||
UpdateStateIsolated(bias);
|
||||
}
|
||||
public override void UpdateStateIsolated(float3 bias) {
|
||||
// public override void UpdateStateIsolated() {
|
||||
// float3 bias = new(0, 0, 0);
|
||||
// UpdateStateIsolated(bias);
|
||||
// }
|
||||
public override void UpdateStateIsolated() { //float3 bias) {
|
||||
// A memorycell does not have an activation function
|
||||
Vector3 result = bias;
|
||||
Vector3 result = this.bias;
|
||||
int n = 0;
|
||||
|
||||
//Applying the weight factgors
|
||||
|
||||
@ -200,7 +200,7 @@ public class Neuron : Nucleus {
|
||||
}
|
||||
|
||||
//public float3 bias = float3(0, 0, 0);
|
||||
public override void UpdateStateIsolated(float3 bias_unused) {
|
||||
public override void UpdateStateIsolated() { //float3 bias_unused) {
|
||||
Vector3 sum = this.bias;
|
||||
int n = 0;
|
||||
|
||||
|
||||
@ -98,11 +98,11 @@ public abstract class Nucleus {
|
||||
|
||||
#region Update
|
||||
|
||||
public virtual void UpdateStateIsolated() {
|
||||
UpdateStateIsolated(new float3(0, 0, 0));
|
||||
}
|
||||
public abstract void UpdateStateIsolated();
|
||||
// UpdateStateIsolated(new float3(0, 0, 0));
|
||||
// }
|
||||
|
||||
public abstract void UpdateStateIsolated(float3 bias);
|
||||
//public abstract void UpdateStateIsolated(float3 bias);
|
||||
// public virtual void UpdateStateIsolated(float3 bias) {
|
||||
// }
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ public class Pulsar : Neuron {
|
||||
return clone;
|
||||
}
|
||||
|
||||
public override void UpdateStateIsolated(float3 _bias) {
|
||||
public override void UpdateStateIsolated() { //float3 _bias) {
|
||||
float3 product = this.bias;
|
||||
|
||||
//Applying the weight factors
|
||||
|
||||
@ -18,8 +18,8 @@ public class Selector : Neuron {
|
||||
return clone;
|
||||
}
|
||||
|
||||
public override void UpdateStateIsolated(float3 bias) {
|
||||
float3 max = bias;
|
||||
public override void UpdateStateIsolated() { //float3 bias) {
|
||||
float3 max = this.bias;
|
||||
float maxSqrLength = lengthsq(max);
|
||||
|
||||
//Applying the weight factors
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user