Better swarm control
This commit is contained in:
parent
bb39435892
commit
cb8c9dbb7c
@ -85,7 +85,7 @@ public class Neuroid : Nucleus {
|
|||||||
float weight = synapse.weight;
|
float weight = synapse.weight;
|
||||||
float activatedValue = curve.Evaluate(synapseNucleus.outputValue.magnitude);
|
float activatedValue = curve.Evaluate(synapseNucleus.outputValue.magnitude);
|
||||||
float magnitude = weight * activatedValue;
|
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;
|
result += direction * magnitude;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -122,7 +122,6 @@ public class VelocityNeuroid : Neuroid {
|
|||||||
this.outputValue = Spherical.FromVector3(velocity);
|
this.outputValue = Spherical.FromVector3(velocity);
|
||||||
this.stale = 0;
|
this.stale = 0;
|
||||||
|
|
||||||
//foreach (Neuroid receiver in receivers)
|
|
||||||
foreach (Receiver receiver in receivers) {
|
foreach (Receiver receiver in receivers) {
|
||||||
if (receiver.nucleus is Neuroid neuroid)
|
if (receiver.nucleus is Neuroid neuroid)
|
||||||
neuroid.SetInput(this);
|
neuroid.SetInput(this);
|
||||||
|
|||||||
@ -374,10 +374,10 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::SwarmControl
|
m_EditorClassIdentifier: Assembly-CSharp::SwarmControl
|
||||||
speed: 1
|
speed: 1
|
||||||
inertia: 0.9
|
inertia: 0.8
|
||||||
alignmentForce: 2
|
alignmentForce: 9
|
||||||
cohesionForce: 2
|
cohesionForce: 4
|
||||||
avoidanceForce: 10
|
avoidanceForce: 5
|
||||||
separationDistance: 0.3
|
separationDistance: 0.3
|
||||||
perceptionDistance: 2
|
perceptionDistance: 2
|
||||||
boundaryForce: 5
|
boundaryForce: 5
|
||||||
@ -395,7 +395,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: ec888ca5333d45a438f9f417fa5ce135, type: 3}
|
m_Script: {fileID: 11500000, guid: ec888ca5333d45a438f9f417fa5ce135, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::SwarmSpawn
|
m_EditorClassIdentifier: Assembly-CSharp::SwarmSpawn
|
||||||
count: 1
|
count: 100
|
||||||
boidPrefab: {fileID: 8702527964058765413, guid: f9c706268554ce449a8773675b2864b8, type: 3}
|
boidPrefab: {fileID: 8702527964058765413, guid: f9c706268554ce449a8773675b2864b8, type: 3}
|
||||||
spawnAreaSize: {x: 0.5, y: 0.5, z: 0.5}
|
spawnAreaSize: {x: 0.5, y: 0.5, z: 0.5}
|
||||||
minDelay: 0.05
|
minDelay: 0.05
|
||||||
|
|||||||
@ -177,4 +177,4 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 92f34a5e4027a1dc39efd8ce63cf6aba, type: 3}
|
m_Script: {fileID: 11500000, guid: 92f34a5e4027a1dc39efd8ce63cf6aba, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::NanoBrainComponent
|
m_EditorClassIdentifier: Assembly-CSharp::NanoBrainComponent
|
||||||
defaultBrain: {fileID: 11400000, guid: af8d90b8b4b9dcad7837130c4143d91c, type: 2}
|
defaultBrain: {fileID: 11400000, guid: fc1a4800a8c531eb4855b436bc9084ae, type: 2}
|
||||||
|
|||||||
@ -14,6 +14,9 @@ public class SwarmControl_Editor : Editor {
|
|||||||
|
|
||||||
foreach (NanoBrainObj brain in nanoBrains) {
|
foreach (NanoBrainObj brain in nanoBrains) {
|
||||||
UpdateWeight(brain, "Avoidance", swarmControl.avoidanceForce);
|
UpdateWeight(brain, "Avoidance", swarmControl.avoidanceForce);
|
||||||
|
UpdateWeight(brain, "Cohesion", swarmControl.cohesionForce);
|
||||||
|
//UpdateWeight(brain, "Separation", swarmControl.separationDistance);
|
||||||
|
UpdateWeight(brain, "Alignment", swarmControl.alignmentForce);
|
||||||
}
|
}
|
||||||
Debug.Log("Updated weights");
|
Debug.Log("Updated weights");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ MonoBehaviour:
|
|||||||
_name: Root
|
_name: Root
|
||||||
synapses:
|
synapses:
|
||||||
- nucleusId: -112538112
|
- nucleusId: -112538112
|
||||||
weight: -5
|
weight: 5
|
||||||
curvePreset: 0
|
curvePreset: 0
|
||||||
curve:
|
curve:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@ -1280,10 +1280,10 @@ MonoBehaviour:
|
|||||||
inverse: 0
|
inverse: 0
|
||||||
exponent: 1
|
exponent: 1
|
||||||
- id: -112538112
|
- id: -112538112
|
||||||
_name: Boundary Avoidance
|
_name: Avoidance
|
||||||
synapses:
|
synapses:
|
||||||
- nucleusId: 407735232
|
- nucleusId: 407735232
|
||||||
weight: 1
|
weight: -1
|
||||||
curvePreset: 0
|
curvePreset: 0
|
||||||
curve:
|
curve:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user