Nano Brain for Unity

AUTHOR
Version v0.1

Table of Contents

Table of contents

Nano Brain for Unity

Table of Contents

Installation 

Package Installation
You can import the NanoBrain Ant package in Unity directly with the Package Manager git package importer.
See Unity: Installing from a Git URL
Use the link from 'Clone with HTTP' (for example: https://git.passer.life/CreatureControl/Ant.git) In this way you can always retrieve the latest version by pressing the Update button in the Package Manager.
Optionally, you can use a tag to retrieve a specific version. For example: https://git.passer.life/CreatureControl/Ant.git#0.1.0. This will give you a stable version which does not change. Updating can be done by retrieving the package with a link to a new release.
Samples Installation
In the Unity Package manager, select the NanoBrain Ant package and look for the Samples  tab in the details pane on the right. There you can import the Models . 

NanoBrain
 Documentation is found in the Documentation folder 

Hierarchical Index
Class Hierarchy
This inheritance list is sorted roughly, but not completely, alphabetically:
Brain	pagenum
ClusterPrefab	pagenum
Nucleus	pagenum
Cluster	pagenum
Neuron	pagenum
MemoryCell	pagenum

Neuron.Presets	pagenum
Synapse	pagenum

Class Index
Class List
Here are the classes, structs, unions and interfaces with brief descriptions:
Brain (The NanoBrain Unity Componnent ) 	pagenum
Cluster (A Cluster combines a collection of Nuclei to implement reusable behaviour ) 	pagenum
ClusterPrefab (The Unity ScriptableObject to implement re-usable Cluster Prefabs ) 	pagenum
MemoryCell (A MemoryCell stored its value for one update ) 	pagenum
Neuron (A neuron is a basic Nucleus ) 	pagenum
Nucleus (A Nucleus is a basic element in a brain cluster ) 	pagenum
Neuron.Presets (The curve presets for the activation functions ) 	pagenum
Synapse (A Synapse connects the ouput of a Neuron to another Neuron ) 	pagenum

Namespace Documentation
NanoBrain Namespace Reference

The Nanobrain namespace. 
Classes
class ClusterA Cluster combines a collection of Nuclei to implement reusable behaviour. 
class MemoryCellA MemoryCell stored its value for one update. 
class NeuronA neuron is a basic Nucleus. 
class NucleusA Nucleus is a basic element in a brain cluster. 
class SynapseA Synapse connects the ouput of a Neuron to another Neuron. 

Detailed Description
The Nanobrain namespace. 

NanoBrain.Breitenberg Namespace Reference

NanoBrain.Unity Namespace Reference
Classes
class BrainThe NanoBrain Unity Componnent. 
class ClusterPrefabThe Unity ScriptableObject to implement re-usable Cluster Prefabs. 

Passer Namespace Reference

Class Documentation
Brain Class Reference

Description
The NanoBrain Unity Componnent. 
This implements the top-level NanoBrain Cluster 

Inherits MonoBehaviour.
Static Public Member Functions
static void UpdateWeight (Cluster brain, string name, float weight)
Update the weight for all Synapses coming from the Neuron with the given name. 

Public Attributes
ClusterPrefab brainPrefab
The Cluster prefab from which the cluster is created. 

Properties
Cluster brain [get]
The cluster isntance. 

Member Function Documentation
static void UpdateWeight (Cluster  brain, string  name, float  weight)[static]

Update the weight for all Synapses coming from the Neuron with the given name. 

Parameters
brain 	The cluster in which the synapses are updated	
name 	The name of the Neuron for which the weights are updated	
weight 	The new Synapse weight	

Cluster Class Reference

Description
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. 
Inheritance diagram for Cluster:
IMAGE
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. 

Constructor & Destructor Documentation
Cluster (ClusterPrefab  prefab, Cluster  parent)

Instantiate a new copy of a ClusterPrefab in the given parent. 

Parameters
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. 

Parameters
prefab 	The prefab to copy	
parent 	The prefab in which the new copy is placed	

Member Function Documentation
override Nucleus ShallowCloneTo (Cluster  parent)

Function to make a partial clone of this nucleus.   

Parameters
parent 	The cluster in which the cloned nucleus should be placed	
Returns

static int GetNucleusIndex (List< Nucleus >  nuclei, Nucleus  nucleus)[static]

Get the index of a nucleus in a list of nuclei. 

Parameters
nuclei 	The list of nuclei to search	
nucleus 	The nucleus to find	
Returns
The index of the nucleus in the list or -1 when it has not been found
static int GetNucleusIndex (List< Nucleus >  nuclei, string  nucleusName)[static]

Get the index of a nucleus with the given name in a list of nuclei. 

Parameters
nuclei 	The list of nuclei to search	
nucleusName 	The name of the nucleus to find	
Returns
The index of the nucleus in the list or -1 when it has not been found
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. 

Parameters
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. 

Parameters
nucleusName 	The name of the nucleus to find	
foundNucleus 	The found nucleus or null if it is not found	
Returns
True when the nucleus is found, false otherwise
Nucleus GetNucleus (string  nucleusName)

Get a nucleus in this cluster. 

Parameters
nucleusName 	The name of the nucleus to find	
Returns
The found nucleus or null when it is not found
Neuron GetNeuron (string  neuronName)

Get a neuron in this cluster. 

Parameters
neuronName 	The name of the neuron to find	
Returns
The found neuron or null when it is not found
Neuron GetNeuron (int  thingId, string  neuronName, string  thingName = null)

Get a neuron in an instance of a multi-cluster. 

Parameters
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	
Returns
The found neuron or null when it is not found
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. 

Parameters
nucleus 	The nucleus to delete	
Returns
True if a nucleus was deleted, false if the nucleus could not be found
virtual List< Nucleus > CollectReceivers (bool  removeDuplicates = false)[virtual]

Collect all receiving nuclei of signals from this cluster. 

Parameters
removeDuplicates 	Ensure that a receiver is only listed once in the result	
Returns
The list of receivers
List< Synapse > CollectSynapsesTo (Cluster  otherCluster)

Collect all synapses of senders in another cluster of signals to this cluster. 

Parameters
otherCluster 	The other cluster with sending neurons	
Returns
A list of synapses to the neurons in the other clusters
void UpdateFromNucleus (Nucleus  startNucleus)

Update the state of the nucleus and all nuclei receiving from it. 

Parameters
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 

Member Data Documentation
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. 
List<Neuron> _outputs = null[protected]

The neurons without outgoing connections. 
These neurons can potentially be connected to neurons in other clusters 

Property Documentation
List<Neuron> outputs[get]

The neurons without outgoing connections. 
These neurons can potentially be connected to neurons in other clusters 

ClusterPrefab Class Reference

Description
The Unity ScriptableObject to implement re-usable Cluster Prefabs. 

Inherits ScriptableObject.
Public Member Functions
Nucleus GetNucleus (string nucleusName)
Retrieve a nucleus in this cluster. 

void EnsureInitialization ()
Call this function to ensure that there is at least one nucleus. 

Public Attributes
Cluster cluster
The cluster data. 

Member Function Documentation
Nucleus GetNucleus (string  nucleusName)

Retrieve a nucleus in this cluster. 

Parameters
nucleusName 	The name of the nucleus	
Returns
The Nucleus with the given name or null if no such Nucleus could be found
void EnsureInitialization ()

Call this function to ensure that there is at least one nucleus. 
his is an invariant and should be ensured before the nucleus is used because output requires it. 

MemoryCell Class Reference

Description
A MemoryCell stored its value for one update. 
When the input for a Memory Cell changes, it will output the previous value 
 
Inheritance diagram for MemoryCell:
IMAGE
Public Types
enum CombinatorType { Sum, Product }
The type of combinators. 
enum ActivationType { Linear, Power, Sqrt, Reciprocal, Tanh, Binary, Normalized, Custom }
The type of. 
enum Type { None, Neuron, MemoryCell, Cluster }
The types of Nucleus. 
Public Member Functions
MemoryCell (Cluster parent, string name)
Create a new memory cell. 

override Nucleus ShallowCloneTo (Cluster parent)
Function to make a partial clone of this nucleus.   

override void UpdateStateIsolated ()
Update the state without updating other Nuclei.   

Synapse AddSynapse (Neuron sendingNucleus, float weight=1)
Add a new synapse to this nuclues. 

Synapse GetSynapse (Nucleus sender)
Find a synapse. 

void RemoveSynapse (Nucleus sendingNucleus)
Remove a synapse from a Nucleus. 

virtual void SetBias (Vector3 inputValue)
Set the bias, recalculate the output and update all Nuclei receiving from this Nucleus. 

AnimationCurve GenerateCurve ()
Generate the curve for the current activation function. 

void SleepCheck ()
Check if the neuron is sleeping. 

float3 CombinatorSum ()
Sum the synapse outputs together. 

Vector3 CombinatorSum ()
Sum the synapse outputs together. 

float3 CombinatorProduct ()
Multiply the synapse outputs together. 

Vector3 CombinatorProduct ()
Multiply the synapse outputs together. 

virtual void AddReceiver (Nucleus receiverToAdd, float weight=1)
Add a new receiver to this neuron. 

virtual void RemoveReceiver (Nucleus receiverToRemove)
Remove a receiver to this neuron. 

virtual void ProcessStimulus (Vector3 inputValue)
Process an external stimulus. 

Static Public Member Functions
static void Delete (Nucleus nucleus)
Delete the give neuron. 

Public Attributes
Vector3 bias = Vector3.zero
The bias. 

CombinatorType combinator = CombinatorType.Sum
The type of combinator used for this Neuron. 

ActivationType _activator
The activation function. 

AnimationCurve curve
The curve representing the activation function. 

float curveMax = 1.0f
The maximum value of the curve. 

Action WhenFiring
An action which is called every time the neuron is updated and is firing. 

bool persistOutput = false
When true, the value will not be reset after timeToSleep. 

float lastUpdate = 0
The time at which the last update has been done. 

readonly float timeToSleep = 1f
Time in seconds after the last update the neuron can go to sleep. 

string name
The name of the Nucleus. 

Cluster parent
The cluster instance in which the nucleus is located. 

Protected Member Functions
virtual void CloneFields (Neuron clone)
Copy relevant fields of this neuron to the given neuron. 

float3 ActivatorLinear (float3 input)
Linear activation function. 

Vector3 ActivatorLinear (Vector3 input)
Linear activation function. 

float3 ActivatorSqrt (float3 input)
Square root activation function. 

Vector3 ActivatorSqrt (Vector3 input)
Square root activation function. 

float3 ActivatorPower (float3 input)
Power activation function. 

Vector3 ActivatorPower (Vector3 input)
Power activation function. 

float3 ActivatorReciprocal (float3 input)
Reciprocal activation function. 

Vector3 ActivatorReciprocal (Vector3 input)
Reciprocal activation function. 

float3 ActivatorTanh (float3 input)
Tanh activation function. 

float3 ActivatorBinary (float3 input)
Binary activation function. 

float3 ActivatorNormalized (float3 input)
Normalize activation function. 

Protected Attributes
float3 _outputValue
The output value of the neuron. 

Vector3 _outputValue
The output value of the neuron. 

Properties
List< Synapse > synapses [get]
The synapses of the nucleus. 

ActivationType activator [get, set]
The activation funtion. 

virtual float3 outputValue [get, set]
The output value of the neuron. 

virtual Vector3 outputValue [get, set]
The output value of the neuron. 

float outputMagnitude [get]
The magnitude of the neuron output. 

float outputSqrMagnitude [get]
The squared magnitude of the neuron output. 

bool isFiring [get]
True if the neuron have a positive value with magnitude > 0.5. 

virtual bool isSleeping [get]
True when the neuron is not persisting and has not be updated for timeToSleep seconds. 

Func< float3 > Combinator [get]
The combinator which combines the values from all synapses. 

Func< Vector3 > Combinator [get]
The combinator which combines the values from all synapses. 

virtual List< Nucleus > receivers [get, set]
The nuclei which have a synapse to this neuron. 

Member Enumeration Documentation
enum CombinatorType[inherited]

The type of combinators. 
A combinator combines the weighted values of the synapses to a single value 

Enumerator:
Sum	Add the weighted values together. 
	
Product	Multiply the weighted values. 

Constructor & Destructor Documentation
MemoryCell (Cluster  parent, string  name)

Create a new memory cell. 

Parameters
parent 	The cluster in which the memorycell shoud be created	
name 	The name of the memory cell	

Member Function Documentation
override Nucleus ShallowCloneTo (Cluster  parent)

Function to make a partial clone of this nucleus.   

Parameters
parent 	The cluster in which the cloned nucleus should be placed	
Returns

override void UpdateStateIsolated ()

Update the state without updating other Nuclei.   

Synapse AddSynapse (Neuron  sendingNucleus, float  weight = 1)[inherited]

Add a new synapse to this nuclues. 

Parameters
sendingNucleus 	The nucleus from which the signals may originate	
weight 	The weight applied to the input. Default value = 1	
Returns
The created Synapse
This will add a new input to this nucleus with the given weight. 
Synapse GetSynapse (Nucleus  sender)[inherited]

Find a synapse. 

Parameters
sender 	The sender of the input to the Synapse	
Returns
The found Synapse or null when the sender has no synapse to this nucleus.
void RemoveSynapse (Nucleus  sendingNucleus)[inherited]

Remove a synapse from a Nucleus. 

Parameters
sendingNucleus 	Remote the synapse connecting to this Nucleus	
virtual void SetBias (Vector3  inputValue)[virtual], [inherited]

Set the bias, recalculate the output and update all Nuclei receiving from this Nucleus. 

Parameters
inputValue 		
AnimationCurve GenerateCurve ()[inherited]

Generate the curve for the current activation function. 

Returns
The curve 
void SleepCheck ()[inherited]

Check if the neuron is sleeping. 
This will reset the output value if it is sleeping 
virtual void CloneFields (Neuron  clone)[protected], [virtual], [inherited]

Copy relevant fields of this neuron to the given neuron. 

Parameters
clone 		
static void Delete (Nucleus  nucleus)[static], [inherited]

Delete the give neuron. 

Parameters
nucleus 	The neuron to delete	
float3 CombinatorSum ()[inherited]

Sum the synapse outputs together. 

Returns
The sum of the synapse outputs
Vector3 CombinatorSum ()[inherited]

Sum the synapse outputs together. 

Returns
The sum of the synapse outputs
float3 CombinatorProduct ()[inherited]

Multiply the synapse outputs together. 

Returns
The mutliplcation of the synapse outputs
Vector3 CombinatorProduct ()[inherited]

Multiply the synapse outputs together. 

Returns
The mutliplcation of the synapse outputs
float3 ActivatorLinear (float3  input)[protected], [inherited]

Linear activation function. 

Parameters
input 	Input value	
Returns
The unchanged value
Vector3 ActivatorLinear (Vector3  input)[protected], [inherited]

Linear activation function. 

Parameters
input 	Input value	
Returns
The unchanged value
float3 ActivatorSqrt (float3  input)[protected], [inherited]

Square root activation function. 

Parameters
input 	Input value	
Returns
The square root of the input
Vector3 ActivatorSqrt (Vector3  input)[protected], [inherited]

Square root activation function. 

Parameters
input 	Input value	
Returns
The square root of the input
float3 ActivatorPower (float3  input)[protected], [inherited]

Power activation function. 

Parameters
input 	Input value	
Returns
The input to the power of 2
Vector3 ActivatorPower (Vector3  input)[protected], [inherited]

Power activation function. 

Parameters
input 	Input value	
Returns
The input to the power of 2
float3 ActivatorReciprocal (float3  input)[protected], [inherited]

Reciprocal activation function. 

Parameters
input 	Input value	
Returns
1/input value
Vector3 ActivatorReciprocal (Vector3  input)[protected], [inherited]

Reciprocal activation function. 

Parameters
input 	Input value	
Returns
1/input value
float3 ActivatorTanh (float3  input)[protected], [inherited]

Tanh activation function. 

Parameters
input 	Input value	
Returns
Tanh(input value)
float3 ActivatorBinary (float3  input)[protected], [inherited]

Binary activation function. 

Parameters
input 	Input value	
Returns
An uniform vector with magnitude between 0 and 1
float3 ActivatorNormalized (float3  input)[protected], [inherited]

Normalize activation function. 

Parameters
input 	Input value	
Returns
The normalized vector
virtual void AddReceiver (Nucleus  receiverToAdd, float  weight = 1)[virtual], [inherited]

Add a new receiver to this neuron. 

Parameters
receiverToAdd 	The receiver to add	
weight 	The weight to use for the synapse to his neuron	
virtual void RemoveReceiver (Nucleus  receiverToRemove)[virtual], [inherited]

Remove a receiver to this neuron. 

Parameters
receiverToRemove 	The receiver to remove	
virtual void ProcessStimulus (Vector3  inputValue)[virtual], [inherited]

Process an external stimulus. 

Parameters
inputValue 	The value of the stimulus	

Member Data Documentation
Vector3 bias = Vector3.zero[inherited]

The bias. 
The bias which a value which is always added to the combined value of the neuron It does not have a synapse and therefore no weight of source nucleus 

Neuron Class Reference

Description
A neuron is a basic Nucleus. 
Inheritance diagram for Neuron:
IMAGE
Classes
class PresetsThe curve presets for the activation functions. 
Public Types
enum CombinatorType { Sum, Product }
The type of combinators. 
enum ActivationType { Linear, Power, Sqrt, Reciprocal, Tanh, Binary, Normalized, Custom }
The type of. 
enum Type { None, Neuron, MemoryCell, Cluster }
The types of Nucleus. 
Public Member Functions
Neuron (Cluster parent, string name)
Create a new Neuron in a Cluster instance. 

Synapse AddSynapse (Neuron sendingNucleus, float weight=1)
Add a new synapse to this nuclues. 

Synapse GetSynapse (Nucleus sender)
Find a synapse. 

void RemoveSynapse (Nucleus sendingNucleus)
Remove a synapse from a Nucleus. 

virtual void SetBias (Vector3 inputValue)
Set the bias, recalculate the output and update all Nuclei receiving from this Nucleus. 

AnimationCurve GenerateCurve ()
Generate the curve for the current activation function. 

void SleepCheck ()
Check if the neuron is sleeping. 

override Nucleus ShallowCloneTo (Cluster parent)
Function to make a partial clone of this nucleus.   

override void UpdateStateIsolated ()
Update the state without updating other Nuclei.   

float3 CombinatorSum ()
Sum the synapse outputs together. 

float3 CombinatorProduct ()
Multiply the synapse outputs together. 

Vector3 CombinatorSum ()
Sum the synapse outputs together. 

Vector3 CombinatorProduct ()
Multiply the synapse outputs together. 

virtual void AddReceiver (Nucleus receiverToAdd, float weight=1)
Add a new receiver to this neuron. 

virtual void RemoveReceiver (Nucleus receiverToRemove)
Remove a receiver to this neuron. 

virtual void ProcessStimulus (Vector3 inputValue)
Process an external stimulus. 

Static Public Member Functions
static void Delete (Nucleus nucleus)
Delete the give neuron. 

Public Attributes
Vector3 bias = Vector3.zero
The bias. 

CombinatorType combinator = CombinatorType.Sum
The type of combinator used for this Neuron. 

ActivationType _activator
The activation function. 

AnimationCurve curve
The curve representing the activation function. 

float curveMax = 1.0f
The maximum value of the curve. 

Action WhenFiring
An action which is called every time the neuron is updated and is firing. 

bool persistOutput = false
When true, the value will not be reset after timeToSleep. 

float lastUpdate = 0
The time at which the last update has been done. 

readonly float timeToSleep = 1f
Time in seconds after the last update the neuron can go to sleep. 

string name
The name of the Nucleus. 

Cluster parent
The cluster instance in which the nucleus is located. 

Protected Member Functions
virtual void CloneFields (Neuron clone)
Copy relevant fields of this neuron to the given neuron. 

float3 ActivatorLinear (float3 input)
Linear activation function. 

float3 ActivatorSqrt (float3 input)
Square root activation function. 

float3 ActivatorPower (float3 input)
Power activation function. 

float3 ActivatorReciprocal (float3 input)
Reciprocal activation function. 

float3 ActivatorTanh (float3 input)
Tanh activation function. 

float3 ActivatorBinary (float3 input)
Binary activation function. 

float3 ActivatorNormalized (float3 input)
Normalize activation function. 

Vector3 ActivatorLinear (Vector3 input)
Linear activation function. 

Vector3 ActivatorSqrt (Vector3 input)
Square root activation function. 

Vector3 ActivatorPower (Vector3 input)
Power activation function. 

Vector3 ActivatorReciprocal (Vector3 input)
Reciprocal activation function. 

Protected Attributes
float3 _outputValue
The output value of the neuron. 

Vector3 _outputValue
The output value of the neuron. 

Properties
List< Synapse > synapses [get]
The synapses of the nucleus. 

ActivationType activator [get, set]
The activation funtion. 

virtual float3 outputValue [get, set]
The output value of the neuron. 

float outputMagnitude [get]
The magnitude of the neuron output. 

float outputSqrMagnitude [get]
The squared magnitude of the neuron output. 

virtual Vector3 outputValue [get, set]
The output value of the neuron. 

bool isFiring [get]
True if the neuron have a positive value with magnitude > 0.5. 

virtual bool isSleeping [get]
True when the neuron is not persisting and has not be updated for timeToSleep seconds. 

Func< float3 > Combinator [get]
The combinator which combines the values from all synapses. 

Func< Vector3 > Combinator [get]
The combinator which combines the values from all synapses. 

virtual List< Nucleus > receivers [get, set]
The nuclei which have a synapse to this neuron. 

Member Enumeration Documentation
enum CombinatorType

The type of combinators. 
A combinator combines the weighted values of the synapses to a single value 

Enumerator:
Sum	Add the weighted values together. 
	
Product	Multiply the weighted values. 

Constructor & Destructor Documentation
Neuron (Cluster  parent, string  name)

Create a new Neuron in a Cluster instance. 

Parameters
parent 	The parent cluster in which the new Neuron should be created	
name 	The name of the new Neuron	

Member Function Documentation
Synapse AddSynapse (Neuron  sendingNucleus, float  weight = 1)

Add a new synapse to this nuclues. 

Parameters
sendingNucleus 	The nucleus from which the signals may originate	
weight 	The weight applied to the input. Default value = 1	
Returns
The created Synapse
This will add a new input to this nucleus with the given weight. 
Synapse GetSynapse (Nucleus  sender)

Find a synapse. 

Parameters
sender 	The sender of the input to the Synapse	
Returns
The found Synapse or null when the sender has no synapse to this nucleus.
void RemoveSynapse (Nucleus  sendingNucleus)

Remove a synapse from a Nucleus. 

Parameters
sendingNucleus 	Remote the synapse connecting to this Nucleus	
virtual void SetBias (Vector3  inputValue)[virtual]

Set the bias, recalculate the output and update all Nuclei receiving from this Nucleus. 

Parameters
inputValue 		
AnimationCurve GenerateCurve ()

Generate the curve for the current activation function. 

Returns
The curve 
void SleepCheck ()

Check if the neuron is sleeping. 
This will reset the output value if it is sleeping 
override Nucleus ShallowCloneTo (Cluster  parent)

Function to make a partial clone of this nucleus.   

Parameters
parent 	The cluster in which the cloned nucleus should be placed	
Returns

virtual void CloneFields (Neuron  clone)[protected], [virtual]

Copy relevant fields of this neuron to the given neuron. 

Parameters
clone 		
static void Delete (Nucleus  nucleus)[static]

Delete the give neuron. 

Parameters
nucleus 	The neuron to delete	
override void UpdateStateIsolated ()

Update the state without updating other Nuclei.   

float3 CombinatorSum ()

Sum the synapse outputs together. 

Returns
The sum of the synapse outputs
float3 CombinatorProduct ()

Multiply the synapse outputs together. 

Returns
The mutliplcation of the synapse outputs
Vector3 CombinatorSum ()

Sum the synapse outputs together. 

Returns
The sum of the synapse outputs
Vector3 CombinatorProduct ()

Multiply the synapse outputs together. 

Returns
The mutliplcation of the synapse outputs
float3 ActivatorLinear (float3  input)[protected]

Linear activation function. 

Parameters
input 	Input value	
Returns
The unchanged value
float3 ActivatorSqrt (float3  input)[protected]

Square root activation function. 

Parameters
input 	Input value	
Returns
The square root of the input
float3 ActivatorPower (float3  input)[protected]

Power activation function. 

Parameters
input 	Input value	
Returns
The input to the power of 2
float3 ActivatorReciprocal (float3  input)[protected]

Reciprocal activation function. 

Parameters
input 	Input value	
Returns
1/input value
float3 ActivatorTanh (float3  input)[protected]

Tanh activation function. 

Parameters
input 	Input value	
Returns
Tanh(input value)
float3 ActivatorBinary (float3  input)[protected]

Binary activation function. 

Parameters
input 	Input value	
Returns
An uniform vector with magnitude between 0 and 1
float3 ActivatorNormalized (float3  input)[protected]

Normalize activation function. 

Parameters
input 	Input value	
Returns
The normalized vector
Vector3 ActivatorLinear (Vector3  input)[protected]

Linear activation function. 

Parameters
input 	Input value	
Returns
The unchanged value
Vector3 ActivatorSqrt (Vector3  input)[protected]

Square root activation function. 

Parameters
input 	Input value	
Returns
The square root of the input
Vector3 ActivatorPower (Vector3  input)[protected]

Power activation function. 

Parameters
input 	Input value	
Returns
The input to the power of 2
Vector3 ActivatorReciprocal (Vector3  input)[protected]

Reciprocal activation function. 

Parameters
input 	Input value	
Returns
1/input value
virtual void AddReceiver (Nucleus  receiverToAdd, float  weight = 1)[virtual]

Add a new receiver to this neuron. 

Parameters
receiverToAdd 	The receiver to add	
weight 	The weight to use for the synapse to his neuron	
virtual void RemoveReceiver (Nucleus  receiverToRemove)[virtual]

Remove a receiver to this neuron. 

Parameters
receiverToRemove 	The receiver to remove	
virtual void ProcessStimulus (Vector3  inputValue)[virtual]

Process an external stimulus. 

Parameters
inputValue 	The value of the stimulus	

Member Data Documentation
Vector3 bias = Vector3.zero

The bias. 
The bias which a value which is always added to the combined value of the neuron It does not have a synapse and therefore no weight of source nucleus 

Nucleus Class Reference

Description
A Nucleus is a basic element in a brain cluster. 
Inheritance diagram for Nucleus:
IMAGE
Public Types
enum Type { None, Neuron, MemoryCell, Cluster }
The types of Nucleus. 
Public Member Functions
Nucleus ShallowCloneTo (Cluster parent)
Function to make a partial clone of this nucleus. 

void UpdateStateIsolated ()
Update the state without updating other Nuclei. 

Public Attributes
string name
The name of the Nucleus. 

Cluster parent
The cluster instance in which the nucleus is located. 

Member Function Documentation
Nucleus ShallowCloneTo (Cluster  parent)[abstract]

Function to make a partial clone of this nucleus. 

Parameters
parent 	The cluster in which the cloned nucleus should be placed	
Returns

Neuron.Presets Class Reference

Description
The curve presets for the activation functions. 
Static Public Member Functions
static AnimationCurve Linear (float weight)
Generate a curve for the linear activation function. 

static AnimationCurve Power (float exponent, float weight)
Generate a curve for the power activation function. 

static AnimationCurve Reciprocal (float weight)
Generate a curve for the reciprocal activation function. 

static AnimationCurve Tanh (float weight)
Generate a curve for the tanh activation function. 

static AnimationCurve Binary ()
Generate a curve for the binary activation function. 

Member Function Documentation
static AnimationCurve Linear (float  weight)[static]

Generate a curve for the linear activation function. 

Parameters
weight 	The maximum value for the function	
Returns
The curve preset
static AnimationCurve Power (float  exponent, float  weight)[static]

Generate a curve for the power activation function. 

Parameters
exponent 	The exponent of the power function	
weight 	The maximum value for the function	
Returns
The curve preset
static AnimationCurve Reciprocal (float  weight)[static]

Generate a curve for the reciprocal activation function. 

Parameters
weight 	The maximum value for the function	
Returns
The curve preset
static AnimationCurve Tanh (float  weight)[static]

Generate a curve for the tanh activation function. 

Parameters
weight 	The maximum value for the function	
Returns
The curve preset
static AnimationCurve Binary ()[static]

Generate a curve for the binary activation function. 

Returns
The curve preset

Synapse Class Reference

Description
A Synapse connects the ouput of a Neuron to another Neuron. 
Public Member Functions
Synapse (Neuron nucleus, float weight=1.0f)
Create a new Synapse. 

Public Attributes
Neuron neuron
The neuron from which input is received. 

float weight
The weight value to apply to the Neuron input. 

Constructor & Destructor Documentation
Synapse (Neuron  nucleus, float  weight = 1::0f)

Create a new Synapse. 

Parameters
nucleus 	The neuron from which input is received	
weight 	The weight value to apply to the Neuron input	

Index
INDEX