I do have to warn though because I am moving at the moment to the neural network so I only created the base codes based on the books and C++ source codes for my Unity project to be used later. So there are some problems at the moment with the code but the code samples can work as an example to you to modify and use how it best fits you.

Niching techniques

“Can be great for retaining population diversity, and are particularly useful where fitness landscape might contain multiple peaks or where it is essential to protect new innovation within a population.” (Rabin, 2003)

Explicit fitness sharing

“Is a mechanism where individuals with similar genetic properties are grouped together. Each individual’s score is then divided by the number of genomes within its group.

Newfitness = oldfitness / numberofneighboors

This punishes the fitness scores of individuals who have many similar neighbors, thereby preventing any one group from growing too large and taking over the population.” (Rabin, 2003)

Speciation

“Goes one step further by separating the genomes into groups in the same way as explicit fitness sharing, but this time individuals are only allowed to breed with members of their own species. Typically, a species is killed when either its size decreases to zero or its fitness has not increased within a user-defined number of generations. This means that the individuals that would normally have died out early in the evolution of a population remain active for much longer, protected among their species members. Because of the protection you can experiment with much larger mutation rates than normal.” (Rabin, 2003)

The compatibility function

“To determine if one genome should belong in the same species as another, you must use a function that compares two genes strings and returns a compatibility distance. If the distance is below a user defined threshold, then the genomes are considered to be in the same species. This compatibility function varies considerably depending on the encoding representation.

Dist= (x-y) / n

N = the number of genes in each chromosome

X and y= represent two different individuals in the population

Each iteration of the genetic algorithm, the compatibility function is used to test every individual against the first member in each species. If the distance is within a user defined threshold, then the individual is added to the appropriate species. Id the individual is incompatible with all the current species, then a new species is created and the individual is added to that.” (Rabin, 2003)

///
&lt;summary&gt;
/// Separate the population into species. This separates the individuals into species of similar genomes.
/// &lt;/summary&gt;
public void Speciate(ref List&lt;Host&gt; population)
{
//first clear the existing members and kill off any non developing
//species
this.Species.Clear();
//now separate the population into species
for (int gen = 0; gen &lt; population.Count; ++gen)
{
bool bAdded = false;
foreach(Species curSpecies in this.Species)
{
//calculate the compatibility score
double cs = Compatibility(population[gen], curSpecies.Sample());
//if the compatibility score is less than our tolerance then
//this genome is added to the species
if (cs &lt; CompatibilityTolerance) { curSpecies.AddGenome(population[gen]); bAdded = true; break; } }//next species if (!bAdded) { //not compatible with any current species so create a new //species Species.Add(new Species(population[gen], NextSpeciesID++)); } }//next genome //update all the species to make sure their sample member is set //to the best genome found so far. Kill off any empty species //foreach (Species curSpecies in this.Species) for(int x = this.Species.Count -1; x &gt;= 0; --x)
{
var curSpecies = this.Species[x];
curSpecies.UpdateSampleGenome();
if ((curSpecies.Empty() ||
(curSpecies.GenerationsNoImprovement() &gt; GenerationsAllowedWithoutImprovement)) &amp;&amp;
(Species.Count &gt; 1))
{
Species.RemoveAt(x);
}
}
}
///
&lt;summary&gt;
/// this allocates a compatibility score between two genomes. If the
/// score is below a certain threshold then the two genomes are &lt;/summary&gt;
/// considered to be of the same species&lt;param name="g1"&gt;&lt;/param&gt;
/// &lt;param name="g2"&gt;&lt;/param&gt;
/// &lt;returns&gt;&lt;/returns&gt;
public float Compatibility(Host g1, Host g2)
{
if (g1.DNA.Genes.Count != g2.DNA.Genes.Count) return 0;
float RunningTotal = 0.0F;
for (int gene = 0; gene &lt; g1.DNA.Genes.Count; ++gene)
{
//RunningTotal += Mathf.Abs(g1.Genes[gene] - g2.Genes[gene]);
RunningTotal += Vector2.Distance(g1.DNA.Genes[gene], g2.DNA.Genes[gene]);
}
return RunningTotal / g1.DNA.Genes.Count;
}
///
&lt;summary&gt;
/// this method calculates the amount of offspring each species
/// should produce.&lt;/summary&gt;
/// &lt;param name="AmountNeeded"&gt;&lt;/param&gt;
public void CalculateExpectedOffspring(int AmountNeeded)
{
//first calculate the total fitness of all active genomes
float TotalFitness = 0.0F;
foreach (Species curSpecies in this.Species)
{
//apply fitness sharing first
curSpecies.FitnessShare();
TotalFitness += curSpecies.TotalFitness();
}
//now it is necessary to calculate the expected amount of offspring
//from each species
double expec = 0.0;
foreach (Species curSpecies in this.Species)
{
curSpecies.SetExpectedOffspring(TotalFitness, AmountNeeded);
expec += curSpecies.ExpectedOffspring();
}
}
///
&lt;summary&gt;
/// this sorts the species and assigns a color to each one.
/// The color is just cosmetic to be used as a visual aid.&lt;/summary&gt;
public void SortAndAssignVisualAid()
{
if (this.Species.Count &lt; 0) return; this.Species.OrderByDescending(o =&gt; o.BestEverFitness());
}

Co-evolution

“If you have different species competing with each other, they have to work harder at solving the problem. If the fitness of one is somehow inversely proportional to the fitness of the other, you have competition. This can greatly increase the speed and quality of the evolution process.” (Rabin, 2003)

The Michalewicz method

“Contains several mutation and crossover operators that are used in combination to fully exploit the characteristics of real value encoding GAs.

Mutation operators

Boundary mutation: With probability p, this operator changes the value of a gene to either its minimum possible value, Gmin, or its maximum possible value Gmax.

Replace mutation: With probability p, this operator resets a gene to a uniform random between Gmin and Gmax.

Non-Uniform mutation: With probability p, this operator adjusts a gene’s size by a small random amount, the limits of which decrease over time.

Crossover operators

Arithmetical crossover: This simply averages the values of the genes at each locus.

Simple crossover: this operator is the same as a single point crossover.

Heuristics crossover: Given the parents G1 and G2 this operator creates an offspring according to Equation: Child = r(G2 – G1) + G2

Variable G2 is the fitter of the two parents, and r is a random number between 0 and 1.

Alone these operators produce bad results but combined together they have a tendency to produce fitter offspring’s.

Tip: Using adaptive probability distribution for the operators can be speedier and lose little in performance. This means that each operator uses the same equal probability.” (Rabin, 2003)

Genetic programming

“Genetic programming is a powerful extension to evolutionary computing. They allow considerable flexibility, allowing the application programmer to develop solutions of more diverse structure that those provided by genetic algorithms. Grammatical evolution is one way to implement genetic programming while minimizing the computation expense related to the creation and subsequent elimination of nonsense organism.” (Rabin, 2003)

Growth in Genetic Algorithms

Idea: Enhancements through flexibility

Growth

Neutral networks

Variable-length genome

Speciation

Co-evolution.

Growth

Look at nature for examples on how to give more “life” to Gas and not look to static created by a mechanical code. In nature things grow rather than are strictly parametrized. Look at this growth methods from biology, chemistry etc. (Rabin, 2003)

Environment

Such example would be to look at the environment something lives in and how they affect one another. What factors, things and properties of both the environment and the entity play into the role of environment based growth? When do the growth stop for a living organism? Take into consideration how the growth is going to be terminated. Look again into nature. (Rabin, 2003)

Neutral network

A concept that increases evolvability. Have some junk DNA switched on inside an important host. This junk DNA can then be subject to the same rules of evolution. This might not produce great results at first but every now and then might help be of advantage. Increases the probability of finding a better solution.

Implementation ideas:

Scanning through the genome with a logic that determines an interaction values by a single mutation, for example.

Variable-length genomes: Have unequal crossover points. Both parents have their own crossover points so a child can have a genome much bigger or smaller than its two parents, which allows evolution to control the complexity of the solutions.

Another example would be to duplicate a gene once it is identified or to just make a random duplications during crossover.

This would mean that the system cannot be a simple parametrization system.

I needed to use normal maps to my Tiled project with Tiled2Unity and this was not support by default. So I did some script changes to make this happen. Below is the instruction how to use the new code changes.

How to use Ti led with Tiled2Unity to attach Normal Maps to your Tiled project:

Add a new map property named “UseNormalMap” and assign the value 1 to it. This will indicate to the script in unity that a normal map is to searched and applied to the project once exported from Tiled2Unity.

Next add you normal map texture to the Tiled project, make sure that the normal map texture file has the following characters just before the file extension: _n, example: hyptosis_til-art-batch-2_n.png. This will tell the importer code which texture file is the normal map file. So it is the same file name as the original texture file but with the _n characters. Then add a new layer and name it “NormalMapLayer”. IMPORTANT: Add some tiles from the normal map texture to the layer. This is so that the normal map texture is exported to Unity. If this is not done the normal map texture is not exported by the tool Tiled2Unity.

After this simply do what you would normally do to export your tiled project to Unity using Tiled2Unity. This of course implies that you have the code changes which support this new feature for normal maps.

NOTICE: There is a new shader called TextureTintSnapNormal which is used for normal mapping.

DrawNode weirdness:

The position which you set in a init phase is not the same what it will be after the init is performed and added to a parent. This is because of the cross platform issues where you need to take into consideration areas which are part of the screen but not part of your game area which your user will use to interact. This is main in Android devices where you home button, back buttons etc might take screen area(although I ran into this problem also on Windows).

Object Position and Anchor point:

Remember that your objects center is the anchor point. Also your object will be moved from and rotated around the anchor point.