using System; using UnityEngine; public class NanoBrain : MonoBehaviour { public ClusterPrefab defaultBrain; [NonSerialized] private Cluster brainInstance; public Cluster brain { get { if (brainInstance == null && defaultBrain != null) { brainInstance = new Cluster(defaultBrain) { name = defaultBrain.name + " (Instance)" }; } // SwarmControl sc = FindFirstObjectByType(); // if (sc != null) { // UpdateWeight(brainInstance, "Containment", sc.containmentForce); // UpdateWeight(brainInstance, "Cohesion", sc.cohesionForce); // UpdateWeight(brainInstance, "Separation", sc.separationForce); // UpdateWeight(brainInstance, "Alignment", sc.alignmentForce); // } return brainInstance; } } // public void Awake() { // brainInstance = new Cluster(defaultBrain); // } public static void UpdateWeight(Cluster brain, string name, float weight) { Nucleus root = brain.output; foreach (Synapse synapse in root.synapses) { if (synapse.nucleus.name == name) { if (synapse.weight != weight) { synapse.weight = weight; // Debug.Log($"Updated weight for {name}"); } } } } }