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