Traitor 1.0.1

dotnet add package Traitor --version 1.0.1                
NuGet\Install-Package Traitor -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Traitor" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Traitor --version 1.0.1                
#r "nuget: Traitor, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Traitor as a Cake Addin
#addin nuget:?package=Traitor&version=1.0.1

// Install Traitor as a Cake Tool
#tool nuget:?package=Traitor&version=1.0.1                

Traitor trait library

This project aims to provide a simple algorithm neatly packaged and usable for genetic algorithms though primarily aimed at game development.

The algorithm it implements is one that picks random traits from one or more parents into a new set of genes with a chance of random mutation and novel traits.

Usage

This project is based primarily on two classes: Genes<TKey, TValue> and GeneCombiner<TKey, TValue>. The generic arguments indicate the type on the trait key and trait value. A trait key, TKey, is usually either a string or an int. The trait value, TValue, is usually either int or double.

A new set of genes is created using Gene<TKey, TValue>'s constructor which takes an IEnumerable<Trait<string, int>>.

var genes = new Genes<string, int>(new[] { new Trait<string, int>("funk", 10) });

If you, for whatever reason, need an empty gene set use Gene<TKey, TValue> use the static property Gene<TKey, TValue>.Empty. This value is a singleton, but Gene<TKey, TValue> is an immutable type so it shouldn't matter.

The GeneCombiner<TKey, TValue> is used to combine genes or at the very least create a somewhat random offspring of one or more sets of genes. It is initialized through its constructor and you likely just need one instance. By default it uses a thread static Random instance and should be thread safe.

The most demanind constructor requires a random function, a novel trait function, a trait mutation function, trait mutation chance and finally a novel trait chance.

The random function simply a function that returns a random number. When this is omitted it will use System.Random.

After the random functio you can provide a trait factory. This is the factory to produce a novel trait. It takes in an IEnumerable of the current traits and returns a novel trait. The input argument can be used to make sure that a novel trait is always returned if possible.

Following is a mutation function, or "mutationValue" function. This takes the current trait and returns the new trait value. This parameter must always be provided. Some examples are provided in the Mutators class. The Hello World example uses Mutators.Gaussian.

Then you have trait mutation chance which is a rational. The rational type has an implicit cast from tuple so for a 1/100 chance simply write (1, 100).

Following that is the novel trait chance. This follows trait mutation chance.

When an instance is available you can use the Combine function to produce "offspring". It takes at least one set of genes (for asexual reproduction I guess) but you can provide as many sets as you like. It will always produce a single instance.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 656 12/17/2018

# Traitor release notes

## v1.0.1 Update license in nuget package

* Minor non-functional changes in project structure.

## v1.0.0 Initial Release

* Implemented Genes which is a set of genes

* Implemented GeneCombiner which produce a new set of genes from one or more other genes.

* Unit test coverage