They are swarming!
This commit is contained in:
parent
28ffae8ce7
commit
8a9700981b
@ -152,11 +152,11 @@ public class ClusterReceptor : Cluster, IReceptor {
|
|||||||
public virtual void ProcessStimulus(Neuron input, Vector3 inputValue, int thingId = 0, string thingName = null) {
|
public virtual void ProcessStimulus(Neuron input, Vector3 inputValue, int thingId = 0, string thingName = null) {
|
||||||
CleanupReceivers();
|
CleanupReceivers();
|
||||||
|
|
||||||
Debug.Log($"{input.name} is {inputValue}, 1/{inputValue} = {1 / inputValue.x}, {1/inputValue.y}, {1/inputValue.z}");
|
// Debug.Log($"{input.name} is {inputValue}, 1/{inputValue} = {1 / inputValue.x}, {1/inputValue.y}, {1/inputValue.z}");
|
||||||
//inputValue = input.Activator(inputValue);
|
//inputValue = input.Activator(inputValue);
|
||||||
|
|
||||||
if (!thingReceivers.TryGetValue(thingId, out ClusterReceptor selectedReceiver))
|
if (!thingReceivers.TryGetValue(thingId, out ClusterReceptor selectedReceiver))
|
||||||
selectedReceiver = FindReceiver2(thingId, inputValue);
|
selectedReceiver = FindReceiver2(thingId, inputValue, input);
|
||||||
if (selectedReceiver == null)
|
if (selectedReceiver == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ public class ClusterReceptor : Cluster, IReceptor {
|
|||||||
|
|
||||||
if (selectedReceiver.clusterNuclei[inputIx] is Neuron selectedNeuron)
|
if (selectedReceiver.clusterNuclei[inputIx] is Neuron selectedNeuron)
|
||||||
selectedNeuron.ProcessStimulusDirect(inputValue);
|
selectedNeuron.ProcessStimulusDirect(inputValue);
|
||||||
Debug.Log($"cluster output = {selectedReceiver.defaultOutput.outputValue}");
|
// Debug.Log($"cluster output = {selectedReceiver.defaultOutput.outputValue}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// private ClusterReceptor FindReceiver(int thingId, float3 inputValue) {
|
// private ClusterReceptor FindReceiver(int thingId, float3 inputValue) {
|
||||||
@ -220,7 +220,7 @@ public class ClusterReceptor : Cluster, IReceptor {
|
|||||||
// return selectedReceiver;
|
// return selectedReceiver;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private ClusterReceptor FindReceiver2(int thingId, float3 inputValue) {
|
private ClusterReceptor FindReceiver2(int thingId, float3 inputValue, Neuron input) {
|
||||||
// No existing nucleus for this thing
|
// No existing nucleus for this thing
|
||||||
ClusterReceptor selectedReceiver = null;
|
ClusterReceptor selectedReceiver = null;
|
||||||
float selectedMagnitude = 0;
|
float selectedMagnitude = 0;
|
||||||
@ -233,6 +233,7 @@ public class ClusterReceptor : Cluster, IReceptor {
|
|||||||
else if (receiver.defaultOutput.isSleeping) {
|
else if (receiver.defaultOutput.isSleeping) {
|
||||||
// A sleeping receiver is not active and can therefore always be used
|
// A sleeping receiver is not active and can therefore always be used
|
||||||
thingReceivers.Add(thingId, receiver);
|
thingReceivers.Add(thingId, receiver);
|
||||||
|
receiver.bias = float3(0, 0, 0);
|
||||||
return receiver;
|
return receiver;
|
||||||
}
|
}
|
||||||
else if (selectedReceiver == null) {
|
else if (selectedReceiver == null) {
|
||||||
@ -251,6 +252,15 @@ public class ClusterReceptor : Cluster, IReceptor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selectedReceiver != null) {
|
if (selectedReceiver != null) {
|
||||||
|
// To re-initialize the cluster (esp. memory cells)
|
||||||
|
// we update the cluster neuron twice.
|
||||||
|
// Bit of a hack.....
|
||||||
|
int inputIx = GetNucleusIndex(this.clusterNuclei, input);
|
||||||
|
if (inputIx >= 0) {
|
||||||
|
if (selectedReceiver.clusterNuclei[inputIx] is Neuron selectedNeuron)
|
||||||
|
selectedNeuron.ProcessStimulusDirect(inputValue);
|
||||||
|
}
|
||||||
|
|
||||||
// Replace the receiver
|
// Replace the receiver
|
||||||
// Find the thingId current associated with the receiver
|
// Find the thingId current associated with the receiver
|
||||||
int keyToRemove = thingReceivers.FirstOrDefault(r => r.Value.Equals(selectedReceiver)).Key;
|
int keyToRemove = thingReceivers.FirstOrDefault(r => r.Value.Equals(selectedReceiver)).Key;
|
||||||
|
|||||||
@ -629,6 +629,7 @@ public class ClusterInspector : Editor {
|
|||||||
this.currentNucleus.name = newName;
|
this.currentNucleus.name = newName;
|
||||||
this.prefab.RefreshOutputs();
|
this.prefab.RefreshOutputs();
|
||||||
outputsField.choices = this.prefab.outputs.Select(output => output.name).ToList();
|
outputsField.choices = this.prefab.outputs.Select(output => output.name).ToList();
|
||||||
|
anythingChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Application.isPlaying) {
|
if (Application.isPlaying) {
|
||||||
@ -767,8 +768,8 @@ public class ClusterInspector : Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
anythingChanged = ConnectNucleus(this.prefab, this.currentNucleus);
|
anythingChanged |= ConnectNucleus(this.prefab, this.currentNucleus);
|
||||||
anythingChanged = AddSynapse(this.prefab, this.currentNucleus);
|
anythingChanged |= AddSynapse(this.prefab, this.currentNucleus);
|
||||||
}
|
}
|
||||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user