cc9a845 Fix sleeping for product combinator e4ba7f8 Better cross-cluster monitoring 4f8a6ab Improved (but not fixed) cross-cluster monitoring b12616b Fix neuron output visualisation 96439cc Visualize all outputs d583e67 WIP cluster references/instance 04bab92 Fix links to multiple cluster neurons & cleanup e17a249 Cross-cluster editor links 0ab2d21 Migrating and cleaning up b6630ad First steps to using instanceCount for clusters 8801fa2 Cluster reimport fixes befb69d full graph with collapsed clusters 1a1919f Fix expansion of clsuter arrays c708f4d Improved clusterarray support c2e4e1b Fix Cluster array extension 02047a4 Adde full graph scrollbar 471ed36 Completed full graph integration 830e3e7 Added full graph view mode 249e888 Improve full graph view 308a6a1 The Entities are battling 75d9d1c Cleanup c8f0f0c Fix aging of neurons e2e169c small fixes 619ced6 Removed the use of Receptors 19f9296 Simplifications bc0a796 Integrated clusterarray in cluster e40dd23 Fixed clusterViewer for clusterarrays b0f4b41 Status quo adding clusterArrays 1fc75a8 Added ClusterArray 0023920 Cover seeking(-ish) behaviour 1c7b8e7 Added Tanh Activation a99d40c BrainViewer added db43655 Pew pew! 18ef4cd Merge commit '89017475984bbbf1899fb38846c5bb0e7775dedd' into NanoBrain git-subtree-dir: NanoBrain git-subtree-split: cc9a845b643ffb4a9abe4f7da787ac5c5b14dae8
60 lines
2.1 KiB
C#
60 lines
2.1 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace NanoBrain {
|
|
|
|
/// <summary>
|
|
/// The NanoBrain Unity Componnent
|
|
/// </summary>
|
|
/// This implements the top-level NanoBrain Cluster
|
|
public class Brain : MonoBehaviour {
|
|
/// <summary>
|
|
/// The Cluster prefab from which the cluster is created
|
|
/// </summary>
|
|
public ClusterPrefab brainPrefab;
|
|
|
|
[NonSerialized]
|
|
private Cluster brainInstance;
|
|
/// <summary>
|
|
/// The cluster isntance
|
|
/// </summary>
|
|
public Cluster brain {
|
|
get {
|
|
if (brainInstance == null && brainPrefab != null) {
|
|
brainInstance = new Cluster(brainPrefab) {
|
|
name = brainPrefab.name
|
|
};
|
|
} else if (brainInstance != null && brainPrefab == null) {
|
|
brainInstance = null;
|
|
}
|
|
return brainInstance;
|
|
}
|
|
}
|
|
|
|
// public Cluster InitializeBrain() {
|
|
// brainInstance = new Cluster(brainPrefab) {
|
|
// name = brainPrefab.name
|
|
// };
|
|
// return brainInstance;
|
|
// }
|
|
|
|
/// <summary>
|
|
/// Update the weight for all Synapses coming from the Neuron with the given name
|
|
/// </summary>
|
|
/// <param name="brain">The cluster in which the synapses are updated</param>
|
|
/// <param name="name">The name of the Neuron for which the weights are updated</param>
|
|
/// <param name="weight">The new Synapse weight</param>
|
|
public static void UpdateWeight(Cluster brain, string name, float weight) {
|
|
Nucleus root = brain.defaultOutput;
|
|
foreach (Synapse synapse in root.synapses) {
|
|
if (synapse.neuron.name == name) {
|
|
if (synapse.weight != weight) {
|
|
synapse.weight = weight;
|
|
// Debug.Log($"Updated weight for {name}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
} |