![]() |
Nano Brain for Unity v0.1
|
A Cluster combines a collection of Nuclei to implement reusable behaviour.
A Cluster is an instantiation of a ClusterPrefab. Clusters can be nested inside other clusters.
Public Types | |
| enum | Type { None , Neuron , MemoryCell , Cluster } |
| The types of Nucleus. | |
Public Member Functions | |
| Cluster (ClusterPrefab prefab, Cluster parent) | |
| Instantiate a new copy of a ClusterPrefab in the given parent. | |
| Cluster (ClusterPrefab prefab, ClusterPrefab parent=null) | |
| Add a new cluster to a ClusterPrefab. | |
| override Nucleus | ShallowCloneTo (Cluster parent) |
| Function to make a partial clone of this nucleus. | |
| void | AddInstance () |
| Increase the number of instances in an multi-cluster. | |
| void | AddInstance (ClusterPrefab prefab) |
| Create an new instance in a multi-cluster. | |
| void | RemoveInstance () |
| Decrease the number of instance in a multi-cluster. | |
| void | RefreshComputeOrders () |
| Refresh the order in which neurons should be computed. | |
| void | RefreshOutputs () |
| Reset the list of outputs such that they will be re-determined. | |
| bool | TryGetNucleus (string nucleusName, out Nucleus foundNucleus) |
| Try to find a nucleus in this cluster. | |
| Nucleus | GetNucleus (string nucleusName) |
| Get a nucleus in this cluster. | |
| Neuron | GetNeuron (string neuronName) |
| Get a neuron in this cluster. | |
| Neuron | GetNeuron (int thingId, string neuronName, string thingName=null) |
| Get a neuron in an instance of a multi-cluster. | |
| bool | DeleteNucleus (Nucleus nucleus) |
| Delete a nucleus from this clsuter. | |
| virtual List< Nucleus > | CollectReceivers (bool removeDuplicates=false) |
| Collect all receiving nuclei of signals from this cluster. | |
| List< Synapse > | CollectSynapsesTo (Cluster otherCluster) |
| Collect all synapses of senders in another cluster of signals to this cluster. | |
| void | UpdateFromNucleus (Nucleus startNucleus) |
| Update the state of the nucleus and all nuclei receiving from it. | |
| override void | UpdateStateIsolated () |
| Update the state without updating other Nuclei. | |
| void | Refresh () |
| Recalculate derived properties. | |
Static Public Member Functions | |
| static int | GetNucleusIndex (List< Nucleus > nuclei, Nucleus nucleus) |
| Get the index of a nucleus in a list of nuclei. | |
| static int | GetNucleusIndex (List< Nucleus > nuclei, string nucleusName) |
| Get the index of a nucleus with the given name in a list of nuclei. | |
Public Attributes | |
| ClusterPrefab | prefab |
| The prefab used to create this cluster. | |
| Cluster[] | instances |
| All cluster instance of a multi-cluster. | |
| int | instanceCount = 1 |
| The number of cluster instances in a multi-cluster. | |
| Dictionary< int, Cluster > | thingClusters = new() |
| The mapping from things to cluster instances. | |
| List< Nucleus > | nuclei = new() |
| All nuclei in this cluster. | |
| string | name |
| The name of the Nucleus. | |
| Cluster | parent |
| The cluster instance in which the nucleus is located. | |
Protected Attributes | |
| List< Neuron > | _outputs = null |
| The neurons without outgoing connections. | |
Properties | |
| string | baseName [get] |
| The base name of the cluster. I don't think this is actively used at this moment. | |
| Dictionary< Nucleus, List< Nucleus > > | computeOrders [get] |
| This gives the order in which nuclei should be computed when a nucleus is updated. | |
| virtual Neuron | defaultOutput [get] |
| The first nucleus in a cluster is the default output. | |
| List< Neuron > | outputs [get] |
| The neurons without outgoing connections. | |
| Cluster | ( | ClusterPrefab | prefab, |
| Cluster | parent | ||
| ) |
Instantiate a new copy of a ClusterPrefab in the given parent.
| prefab | The prefab to use |
| parent | The cluster in which this new cluster will be placed |
| Cluster | ( | ClusterPrefab | prefab, |
| ClusterPrefab | parent = null |
||
| ) |
Add a new cluster to a ClusterPrefab.
| prefab | The prefab to copy |
| parent | The prefab in which the new copy is placed |
Function to make a partial clone of this nucleus.
| parent | The cluster in which the cloned nucleus should be placed |
Get the index of a nucleus in a list of nuclei.
| nuclei | The list of nuclei to search |
| nucleus | The nucleus to find |
|
static |
Get the index of a nucleus with the given name in a list of nuclei.
| nuclei | The list of nuclei to search |
| nucleusName | The name of the nucleus to find |
| void AddInstance | ( | ) |
Increase the number of instances in an multi-cluster.
/remark Note this does not create the instances. This is only intended to be used for prefabs.
| void AddInstance | ( | ClusterPrefab | prefab | ) |
Create an new instance in a multi-cluster.
| prefab | The prefab to use to create the new instance |
/remark This does not change the instanceCount. It should only be used at runtime.
| bool TryGetNucleus | ( | string | nucleusName, |
| out Nucleus | foundNucleus | ||
| ) |
Try to find a nucleus in this cluster.
| nucleusName | The name of the nucleus to find |
| foundNucleus | The found nucleus or null if it is not found |
| Nucleus GetNucleus | ( | string | nucleusName | ) |
Get a nucleus in this cluster.
| nucleusName | The name of the nucleus to find |
| Neuron GetNeuron | ( | string | neuronName | ) |
Get a neuron in this cluster.
| neuronName | The name of the neuron to find |
| Neuron GetNeuron | ( | int | thingId, |
| string | neuronName, | ||
| string | thingName = null |
||
| ) |
Get a neuron in an instance of a multi-cluster.
| thingId | The id of the thing mapped to the cluster instance |
| neuronName | The name of the neuron to find |
| thingName | The name of the thing mapped to the cluster instance |
The cluster instance mapped to the thing will be neuron.parent if a neuron is found.
| bool DeleteNucleus | ( | Nucleus | nucleus | ) |
Delete a nucleus from this clsuter.
| nucleus | The nucleus to delete |
|
virtual |
Collect all receiving nuclei of signals from this cluster.
| removeDuplicates | Ensure that a receiver is only listed once in the result |
Collect all synapses of senders in another cluster of signals to this cluster.
| otherCluster | The other cluster with sending neurons |
| void UpdateFromNucleus | ( | Nucleus | startNucleus | ) |
Update the state of the nucleus and all nuclei receiving from it.
| startNucleus | The nucleus to start updating |
| override void UpdateStateIsolated | ( | ) |
Update the state without updating other Nuclei.
| void Refresh | ( | ) |
Recalculate derived properties.
This can be used to recalculate derived properties after the set of nuclei has been changed
| ClusterPrefab prefab |
The prefab used to create this cluster.
Cluster should always be created from prefabs
| Cluster [] instances |
All cluster instance of a multi-cluster.
A cluster is a multi-cluster when there is more than one instance. The actual instances are only created at runtime. The value instanceCount determines how many instances will be present at runtime.
| int instanceCount = 1 |
The number of cluster instances in a multi-cluster.
A cluster is a multi-clsuter when there is more than one instance.
| Dictionary<int, Cluster> thingClusters = new() |
The mapping from things to cluster instances.
In a multi-cluster each instance can be used for a thing. Cluster instance may also not (yet) be mapped to a thing.
|
protected |
The neurons without outgoing connections.
These neurons can potentially be connected to neurons in other clusters
|
get |
The neurons without outgoing connections.
These neurons can potentially be connected to neurons in other clusters