From a229ee21f002df2644aa0fca26f08b59eec6c070 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Fri, 10 Jul 2026 14:42:46 +0200 Subject: [PATCH] Boid training first steps --- Editor/Cluster_Drawer.cs | 2 +- Runtime/Scripts/Core/Cluster.cs | 41 ++++++++++++++++----------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Editor/Cluster_Drawer.cs b/Editor/Cluster_Drawer.cs index 21e4002..37a4841 100644 --- a/Editor/Cluster_Drawer.cs +++ b/Editor/Cluster_Drawer.cs @@ -25,7 +25,7 @@ namespace NanoBrain.Unity { return height; SerializedProperty prefabProp = property.FindPropertyRelative(nameof(Cluster.prefab)); - if (//prefabProp.objectReferenceValue != null && + if (prefabProp.objectReferenceValue != null && Cluster_Drawer.currentClusterView.isOpen) { height = graphHeight; } diff --git a/Runtime/Scripts/Core/Cluster.cs b/Runtime/Scripts/Core/Cluster.cs index 8abf227..7990031 100644 --- a/Runtime/Scripts/Core/Cluster.cs +++ b/Runtime/Scripts/Core/Cluster.cs @@ -99,7 +99,6 @@ namespace NanoBrain { ClonePrefab(); if (instanceCount > 1) { - Debug.Log($" InstanceCount = {instanceCount}"); List siblings = new() { this }; for (int instanceIx = 1; instanceIx < instanceCount; instanceIx++) { // Create another sibling @@ -474,27 +473,27 @@ namespace NanoBrain { return allInstances; } - public void Backpropagation(Func Observer, float target, float learningRate) { - foreach (Nucleus nucleus in this.instances[0].nuclei) { - if (nucleus is not Neuron neuron) - continue; + // public void Backpropagation(Func Observer, float target, float learningRate) { + // foreach (Nucleus nucleus in this.instances[0].nuclei) { + // if (nucleus is not Neuron neuron) + // continue; - foreach (Synapse synapse in neuron.synapses) { - List allSynapseNeurons = GetAllInstances(synapse.neuron); + // foreach (Synapse synapse in neuron.synapses) { + // List allSynapseNeurons = GetAllInstances(synapse.neuron); - Vector3 dSSRdW = Vector3.zero; - for (int clusterIx = 0; clusterIx < this.instances.Length; clusterIx++) { - Cluster clusterInstance = this.instances[clusterIx]; - Neuron neuronInstance = allSynapseNeurons[clusterIx]; + // Vector3 dSSRdW = Vector3.zero; + // for (int clusterIx = 0; clusterIx < this.instances.Length; clusterIx++) { + // Cluster clusterInstance = this.instances[clusterIx]; + // Neuron neuronInstance = allSynapseNeurons[clusterIx]; - // Simple case, without receivers... - dSSRdW += (Vector3)(-2 * (Observer(clusterInstance) - target) * neuronInstance.activation); - } - synapse.weight += learningRate * dSSRdW.magnitude; - } - } + // // Simple case, without receivers... + // dSSRdW += (Vector3)(-2 * (Observer(clusterInstance) - target) * neuronInstance.activation); + // } + // synapse.weight += learningRate * dSSRdW.magnitude; + // } + // } - } + // } #endregion ClusterArray @@ -867,13 +866,13 @@ namespace NanoBrain { ClusterData data = new(this); //this.ToJSON(); string json = JsonUtility.ToJson(data, prettyPrint: true); - Debug.Log($"Exporting json to {path}"); - System.IO.File.WriteAllText(path, json); + // Debug.Log($"Exporting json to {path}"); + File.WriteAllText(path, json); } public static ClusterData Import(string path) { string json = File.ReadAllText(path); - Debug.Log($"Importing json from {path}"); + // Debug.Log($"Importing json from {path}"); return JsonUtility.FromJson(json); }