WIP: all array elements share the same receptor (value)
This commit is contained in:
parent
16f0c3d3bf
commit
b73b28146c
56
Cluster.cs
56
Cluster.cs
@ -76,65 +76,19 @@ public class Cluster : INucleus {
|
|||||||
|
|
||||||
// Find the synapse for the weight
|
// Find the synapse for the weight
|
||||||
float weight = 1;
|
float weight = 1;
|
||||||
//NucleusArray clonedNucleusArray = null;
|
|
||||||
foreach (Synapse synapse in receiver.synapses) {
|
foreach (Synapse synapse in receiver.synapses) {
|
||||||
// Find the weight for this synapse
|
// Find the weight for this synapse
|
||||||
if (synapse.nucleus == receptor)
|
if (synapse.nucleus == receptor) {
|
||||||
weight = synapse.weight;
|
weight = synapse.weight;
|
||||||
|
break;
|
||||||
// if (synapse.nucleus is INucleus synapseNucleus) {
|
}
|
||||||
// if (synapseNucleus.array != null && synapseNucleus.array.nuclei.Length > 0) {
|
|
||||||
// Debug.Log("Clone: Nucleus array");
|
|
||||||
// if (clonedNucleusArray == null) {
|
|
||||||
// // copy the array
|
|
||||||
// clonedNucleusArray = new NucleusArray(synapseNucleus.array.nuclei.Length, "array");
|
|
||||||
// for (int arrayIx = 0; arrayIx < synapseNucleus.array.nuclei.Length; arrayIx++) {
|
|
||||||
// IReceptor arrayNucleus = synapseNucleus.array.nuclei[arrayIx];
|
|
||||||
// int ix2 = GetNucleusIndex(nuclei, arrayNucleus);
|
|
||||||
// clonedNucleusArray.nuclei[arrayIx] = clonedNuclei[ix2];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// synapseNucleus.array = clonedNucleusArray;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clonedReceptor.AddReceiver(clonedReceiver, weight);
|
clonedReceptor.AddReceiver(clonedReceiver, weight);
|
||||||
// Nucleus clonedNucleus = clonedReceptor as Nucleus;
|
|
||||||
// if (clonedNucleus is not null) {
|
|
||||||
// Synapse clonedSynapse = clonedNucleus.GetSynapse(clonedReceiver);
|
|
||||||
// if (clonedSynapse.nucleus is INucleus synapseNucleus) {
|
|
||||||
// if (synapseNucleus.array != null && synapseNucleus.array.nuclei.Length > 0) {
|
|
||||||
// Debug.Log("Clone: Nucleus array");
|
|
||||||
// if (clonedNucleusArray == null) {
|
|
||||||
// // copy the array
|
|
||||||
// clonedNucleusArray = new NucleusArray(synapseNucleus.array.nuclei.Length, "array");
|
|
||||||
// for (int arrayIx = 0; arrayIx < synapseNucleus.array.nuclei.Length; arrayIx++) {
|
|
||||||
// IReceptor arrayNucleus = synapseNucleus.array.nuclei[arrayIx];
|
|
||||||
// int ix2 = GetNucleusIndex(nuclei, arrayNucleus);
|
|
||||||
// clonedNucleusArray.nuclei[arrayIx] = clonedNuclei[ix2];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// synapseNucleus.array = clonedNucleusArray;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (receptor is INucleus nucleus) {
|
|
||||||
// if (clonedSender is not INucleus clonedNucleus) {
|
|
||||||
// Debug.LogError("INucleus clone is not an INucleus!");
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// clonedNucleus.array = new NucleusArray(nucleus.array._nuclei.Length, "array");
|
|
||||||
// for (int arrayIx = 0; arrayIx < nucleus.array._nuclei.Length; arrayIx++) {
|
|
||||||
// //foreach (INucleus arrayNucleus in nucleus.array.nuclei) {
|
|
||||||
// IReceptor arrayNucleus = nucleus.array._nuclei[arrayIx];
|
|
||||||
// int ix = GetNucleusIndex(nuclei, arrayNucleus);
|
|
||||||
// clonedNucleus.array._nuclei[arrayIx] = clonedNuclei[ix];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy nucleus arrays
|
||||||
for (int nucleusIx = 0; nucleusIx < nuclei.Length; nucleusIx++) {
|
for (int nucleusIx = 0; nucleusIx < nuclei.Length; nucleusIx++) {
|
||||||
IReceptor prefabReceptor = nuclei[nucleusIx];
|
IReceptor prefabReceptor = nuclei[nucleusIx];
|
||||||
if (prefabReceptor is not INucleus prefabNucleus)
|
if (prefabReceptor is not INucleus prefabNucleus)
|
||||||
|
|||||||
@ -432,12 +432,12 @@ public class ClusterInspector : Editor {
|
|||||||
tooltip = new(
|
tooltip = new(
|
||||||
$"{nucleus.name}" +
|
$"{nucleus.name}" +
|
||||||
$"\nsynapse count {n.synapses.Count}" +
|
$"\nsynapse count {n.synapses.Count}" +
|
||||||
$"\nValue: {nucleus.outputValue}");
|
$"\nValue: {length(nucleus.outputValue)}");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tooltip = new(
|
tooltip = new(
|
||||||
$"{nucleus.name}" +
|
$"{nucleus.name}" +
|
||||||
$"\nValue: {nucleus.outputValue}");
|
$"\nValue: {length(nucleus.outputValue)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 mousePosition = Event.current.mousePosition;
|
Vector2 mousePosition = Event.current.mousePosition;
|
||||||
|
|||||||
51
Receptor.cs
51
Receptor.cs
@ -25,12 +25,6 @@ public class Receptor : IReceptor {
|
|||||||
cluster.nuclei.Add(this);
|
cluster.nuclei.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public Receptor(ClusterPrefab cluster, INucleus nucleus) {
|
|
||||||
// this.cluster = cluster;
|
|
||||||
// if (cluster != null)
|
|
||||||
// cluster.nuclei.Add(this);
|
|
||||||
// this.AddReceiver(nucleus);
|
|
||||||
// }
|
|
||||||
public Receptor(Cluster parent, string name, string nucleusName) {
|
public Receptor(Cluster parent, string name, string nucleusName) {
|
||||||
this.parent = parent ?? throw new ArgumentNullException(nameof(parent), "Parent cannot be null.");
|
this.parent = parent ?? throw new ArgumentNullException(nameof(parent), "Parent cannot be null.");
|
||||||
|
|
||||||
@ -43,24 +37,6 @@ public class Receptor : IReceptor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("This method is deprecated. Use Receptor() constructor instead.")]
|
|
||||||
public static Receptor CreateReceptor(Cluster cluster, string nucleusName) {
|
|
||||||
return new Receptor(cluster, "Receptor", nucleusName);
|
|
||||||
// if (cluster == null)
|
|
||||||
// return null;
|
|
||||||
|
|
||||||
// Receptor receptor = new(cluster);
|
|
||||||
// foreach (INucleus nucleus in cluster.inputs) {
|
|
||||||
// if (nucleus != null && nucleus.name == nucleusName) {
|
|
||||||
// receptor.AddReceiver(nucleus);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (receptor._receivers.Count == 0)
|
|
||||||
// return null;
|
|
||||||
// else
|
|
||||||
// return receptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ClusterPrefab cluster;
|
private ClusterPrefab cluster;
|
||||||
private Cluster parent;
|
private Cluster parent;
|
||||||
|
|
||||||
@ -68,20 +44,7 @@ public class Receptor : IReceptor {
|
|||||||
Receptor clone = new(parent);
|
Receptor clone = new(parent);
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
// public virtual IReceptor ShallowCloneTo(ClusterPrefab parent) {
|
|
||||||
// Receptor clone = new(parent);
|
|
||||||
// return clone;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public virtual IReceptor CloneTo(ClusterPrefab parent) {
|
|
||||||
// Receptor clone = new(parent);
|
|
||||||
|
|
||||||
// foreach (INucleus receiver in this.receivers) {
|
|
||||||
// clone.AddReceiver(receiver);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return clone;
|
|
||||||
// }
|
|
||||||
public virtual IReceptor Clone() {
|
public virtual IReceptor Clone() {
|
||||||
Receptor clone = new(this.cluster);
|
Receptor clone = new(this.cluster);
|
||||||
|
|
||||||
@ -127,16 +90,8 @@ public class Receptor : IReceptor {
|
|||||||
private bool _isSleeping = false;
|
private bool _isSleeping = false;
|
||||||
public bool isSleeping => _isSleeping;
|
public bool isSleeping => _isSleeping;
|
||||||
|
|
||||||
public Vector3 localPosition {
|
// public float distanceResolution = 0.1f;
|
||||||
set {
|
// public float directionResolution = 5;
|
||||||
this.stale = 0;
|
|
||||||
this._isSleeping = false;
|
|
||||||
this._outputValue = value;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public float distanceResolution = 0.1f;
|
|
||||||
public float directionResolution = 5;
|
|
||||||
|
|
||||||
private float3 _outputValue;
|
private float3 _outputValue;
|
||||||
public float3 outputValue {
|
public float3 outputValue {
|
||||||
@ -149,7 +104,7 @@ public class Receptor : IReceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ProcessStimulus(int thingId, Vector3 newLocalPositionVector, string thingName = null) {
|
public virtual void ProcessStimulus(int thingId, Vector3 newLocalPositionVector, string thingName = null) {
|
||||||
this.localPosition = newLocalPositionVector;
|
this.outputValue = newLocalPositionVector;
|
||||||
if (this._receivers == null)
|
if (this._receivers == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user