Better swarm control

This commit is contained in:
Pascal Serrarens 2026-01-05 15:35:39 +01:00
parent bb39435892
commit cb8c9dbb7c
6 changed files with 13 additions and 11 deletions

View File

@ -85,7 +85,7 @@ public class Neuroid : Nucleus {
float weight = synapse.weight;
float activatedValue = curve.Evaluate(synapseNucleus.outputValue.magnitude);
float magnitude = weight * activatedValue;
Debug.Log($"{this.name} {synapseNucleus.outputValue.direction} {synapseNucleus.outputValue.direction.horizontal}{synapseNucleus.outputValue.direction.vertical} {direction}");
//Debug.Log($"{this.name} {synapseNucleus.outputValue.direction} {synapseNucleus.outputValue.direction.horizontal}{synapseNucleus.outputValue.direction.vertical} {direction}");
result += direction * magnitude;
}

View File

@ -122,7 +122,6 @@ public class VelocityNeuroid : Neuroid {
this.outputValue = Spherical.FromVector3(velocity);
this.stale = 0;
//foreach (Neuroid receiver in receivers)
foreach (Receiver receiver in receivers) {
if (receiver.nucleus is Neuroid neuroid)
neuroid.SetInput(this);

View File

@ -374,10 +374,10 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::SwarmControl
speed: 1
inertia: 0.9
alignmentForce: 2
cohesionForce: 2
avoidanceForce: 10
inertia: 0.8
alignmentForce: 9
cohesionForce: 4
avoidanceForce: 5
separationDistance: 0.3
perceptionDistance: 2
boundaryForce: 5
@ -395,7 +395,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ec888ca5333d45a438f9f417fa5ce135, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::SwarmSpawn
count: 1
count: 100
boidPrefab: {fileID: 8702527964058765413, guid: f9c706268554ce449a8773675b2864b8, type: 3}
spawnAreaSize: {x: 0.5, y: 0.5, z: 0.5}
minDelay: 0.05

View File

@ -177,4 +177,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 92f34a5e4027a1dc39efd8ce63cf6aba, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::NanoBrainComponent
defaultBrain: {fileID: 11400000, guid: af8d90b8b4b9dcad7837130c4143d91c, type: 2}
defaultBrain: {fileID: 11400000, guid: fc1a4800a8c531eb4855b436bc9084ae, type: 2}

View File

@ -14,6 +14,9 @@ public class SwarmControl_Editor : Editor {
foreach (NanoBrainObj brain in nanoBrains) {
UpdateWeight(brain, "Avoidance", swarmControl.avoidanceForce);
UpdateWeight(brain, "Cohesion", swarmControl.cohesionForce);
//UpdateWeight(brain, "Separation", swarmControl.separationDistance);
UpdateWeight(brain, "Alignment", swarmControl.alignmentForce);
}
Debug.Log("Updated weights");
}

View File

@ -21,7 +21,7 @@ MonoBehaviour:
_name: Root
synapses:
- nucleusId: -112538112
weight: -5
weight: 5
curvePreset: 0
curve:
serializedVersion: 2
@ -1280,10 +1280,10 @@ MonoBehaviour:
inverse: 0
exponent: 1
- id: -112538112
_name: Boundary Avoidance
_name: Avoidance
synapses:
- nucleusId: 407735232
weight: 1
weight: -1
curvePreset: 0
curve:
serializedVersion: 2