Ant is walking again
This commit is contained in:
parent
c78722abce
commit
7187f61b4e
@ -180,12 +180,7 @@ namespace NanoBrain {
|
|||||||
else {
|
else {
|
||||||
string newName = EditorGUILayout.TextField(this.currentNucleus.name, boldTextFieldStyle);
|
string newName = EditorGUILayout.TextField(this.currentNucleus.name, boldTextFieldStyle);
|
||||||
if (newName != this.currentNucleus.name) {
|
if (newName != this.currentNucleus.name) {
|
||||||
Nucleus prefabNucleus = this.prefab.GetNucleus(this.currentNucleus.name);
|
|
||||||
prefabNucleus.name = newName;
|
|
||||||
// This changes it in the temporary cluster instance
|
|
||||||
this.currentNucleus.name = newName;
|
this.currentNucleus.name = newName;
|
||||||
this.prefab.cluster.RefreshOutputs();
|
|
||||||
// outputsPopup.choices = this.prefab.outputs.Select(output => output.name).ToList();
|
|
||||||
anythingChanged = true;
|
anythingChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -188,6 +188,11 @@ namespace NanoBrain {
|
|||||||
foreach (Cluster sibling in siblings)
|
foreach (Cluster sibling in siblings)
|
||||||
sibling.siblingClusters = siblingClusters;
|
sibling.siblingClusters = siblingClusters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that all neurons are computed to initialize bias
|
||||||
|
foreach (Nucleus clonedNucleus in clonedNuclei) {
|
||||||
|
clonedNucleus.UpdateStateIsolated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
for (int nucleusIx = 0; nucleusIx < clonedNuclei.Length; nucleusIx++) {
|
for (int nucleusIx = 0; nucleusIx < clonedNuclei.Length; nucleusIx++) {
|
||||||
@ -613,31 +618,26 @@ namespace NanoBrain {
|
|||||||
if (neuron.synapses.Count == 0)
|
if (neuron.synapses.Count == 0)
|
||||||
this._inputs.Add(nucleus);
|
this._inputs.Add(nucleus);
|
||||||
}
|
}
|
||||||
ComputeOrders();
|
RefreshComputeOrders();
|
||||||
}
|
}
|
||||||
return this._inputs;
|
return this._inputs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<Nucleus, List<Nucleus>> computeOrders = new();
|
private Dictionary<Nucleus, List<Nucleus>> _computeOrders;
|
||||||
private void ComputeOrders() {
|
public Dictionary<Nucleus, List<Nucleus>> computeOrders {
|
||||||
foreach (Nucleus nucleus in this.nuclei) {
|
get {
|
||||||
// if (nucleus is Cluster cluster) {
|
if (_computeOrders == null || _computeOrders.Count == 0) {
|
||||||
// List<Synapse> synapses = this.CollectSynapsesTo(cluster);
|
_computeOrders = new();
|
||||||
// foreach (Synapse synapse in synapses) {
|
foreach (Nucleus nucleus in this.nuclei)
|
||||||
// computeOrders[synapse.neuron] = TopologicalSort2(synapse.neuron);
|
_computeOrders[nucleus] = TopologicalSort2(nucleus);
|
||||||
// Debug.Log($"{this.baseName}: Order for {cluster.baseName}.{synapse.neuron.name}");
|
}
|
||||||
// }
|
return _computeOrders;
|
||||||
// // List<Nucleus> receivers = cluster.CollectReceivers();
|
|
||||||
// // foreach (Nucleus receiver in receivers)
|
|
||||||
// // computeOrders[receiver] = TopologicalSort2(receiver);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
computeOrders[nucleus] = TopologicalSort2(nucleus);
|
|
||||||
//Debug.Log($"{this.baseName} Order for {nucleus.name}");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void RefreshComputeOrders() {
|
||||||
|
this._computeOrders = null;
|
||||||
|
}
|
||||||
|
|
||||||
private List<Nucleus> TopologicalSort2(Nucleus startNode) {
|
private List<Nucleus> TopologicalSort2(Nucleus startNode) {
|
||||||
Dictionary<Nucleus, int> inDegree = new();
|
Dictionary<Nucleus, int> inDegree = new();
|
||||||
@ -711,7 +711,7 @@ namespace NanoBrain {
|
|||||||
protected List<Neuron> _outputs = null;
|
protected List<Neuron> _outputs = null;
|
||||||
public List<Neuron> outputs {
|
public List<Neuron> outputs {
|
||||||
get {
|
get {
|
||||||
if (this._outputs == null) {
|
if (this._outputs == null || this._outputs.Count == 0) {
|
||||||
this._outputs = new();
|
this._outputs = new();
|
||||||
foreach (Nucleus nucleus in this.nuclei) {
|
foreach (Nucleus nucleus in this.nuclei) {
|
||||||
if (nucleus is Neuron neuron && neuron.receivers.Count == 0)
|
if (nucleus is Neuron neuron && neuron.receivers.Count == 0)
|
||||||
@ -911,6 +911,7 @@ namespace NanoBrain {
|
|||||||
|
|
||||||
public void Refresh() {
|
public void Refresh() {
|
||||||
RefreshOutputs();
|
RefreshOutputs();
|
||||||
|
RefreshComputeOrders();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,7 +50,6 @@ namespace NanoBrain {
|
|||||||
/// It does not have a synapse and therefore no weight of source nucleus
|
/// It does not have a synapse and therefore no weight of source nucleus
|
||||||
public Vector3 bias = Vector3.zero;
|
public Vector3 bias = Vector3.zero;
|
||||||
|
|
||||||
|
|
||||||
#region Synapses
|
#region Synapses
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
@ -329,7 +328,6 @@ namespace NanoBrain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void CloneFields(Neuron clone) {
|
protected virtual void CloneFields(Neuron clone) {
|
||||||
clone.parent = this.parent;
|
|
||||||
clone.bias = this.bias;
|
clone.bias = this.bias;
|
||||||
clone.combinator = this.combinator;
|
clone.combinator = this.combinator;
|
||||||
clone.curve = this.curve;
|
clone.curve = this.curve;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user