creatur-5.9.30: Framework for artificial life experiments.
Copyright(c) 2013-2021 Amy de Buitléir
LicenseBSD-style
Maintaineramy@nualeargais.ie
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

ALife.Creatur.Genetics.BRGCWord8

Description

Utilities for working with genes that are encoded as a sequence of bytes, using a Binary Reflected Gray Code (BRGC).

A Gray code maps values to codes in a way that guarantees that the codes for two consecutive values will differ by only one bit. This feature can be useful in evolutionary programming because the genes resulting from a crossover operation are likely to be similar to the inputs. This helps to ensure that offspring are similar to their parents, as any radical changes from one generation to the next are the result of mutation alone.

Synopsis

Documentation

class Genetic g where Source #

A class representing anything which is represented in, and determined by, an agent's genome. This might include traits, parameters, "organs" (components of agents), or even entire agents. Instances of this class can be thought of as genes, i.e., instructions for building an agent.

Minimal complete definition

Nothing

Methods

put :: g -> Writer () Source #

Writes a gene to a sequence.

default put :: (Generic g, GGenetic (Rep g)) => g -> Writer () Source #

get :: Reader (Either [String] g) Source #

Reads the next gene in a sequence.

default get :: (Generic g, GGenetic (Rep g)) => Reader (Either [String] g) Source #

getWithDefault :: g -> Reader g Source #

Instances

Instances details
Genetic Bool Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

Genetic Char Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

Genetic Double Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

Genetic Int Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

Genetic Integer Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

Genetic Word8 Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

Genetic Word16 Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

Genetic Word32 Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

Genetic Word64 Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

Genetic a => Genetic [a] Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

Methods

put :: [a] -> Writer () Source #

get :: Reader (Either [String] [a]) Source #

getWithDefault :: [a] -> Reader [a] Source #

Genetic a => Genetic (Maybe a) Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

(Genetic a, Genetic b) => Genetic (Either a b) Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

Methods

put :: Either a b -> Writer () Source #

get :: Reader (Either [String] (Either a b)) Source #

getWithDefault :: Either a b -> Reader (Either a b) Source #

(Genetic a, Genetic b) => Genetic (a, b) Source # 
Instance details

Defined in ALife.Creatur.Genetics.BRGCWord8

Methods

put :: (a, b) -> Writer () Source #

get :: Reader (Either [String] (a, b)) Source #

getWithDefault :: (a, b) -> Reader (a, b) Source #

copy :: Reader Sequence Source #

Return the entire genome.

consumed :: Reader Sequence Source #

Return the portion of the genome that has been read.

getAndExpress :: (Genetic g, Diploid g) => DiploidReader (Either [String] g) Source #

Read the next pair of genes from twin sequences of genetic information, and return the resulting gene (after taking into account any dominance relationship) and the remaining (unread) portion of the two nucleotide strands.

copy2 :: DiploidReader DiploidSequence Source #

Return the entire genome.

consumed2 :: DiploidReader DiploidSequence Source #

Return the portion of the genome that has been read.

putRawWord8 :: Word8 -> Writer () Source #

Write a Word8 value to the genome without encoding it

getRawWord8 :: Reader (Either [String] Word8) Source #

Read a Word8 value from the genome without decoding it

putRawWord8s :: [Word8] -> Writer () Source #

Write a raw sequence of Word8 values to the genome

getRawWord8s :: Int -> Reader (Either [String] [Word8]) Source #

Read a raw sequence of Word8 values from the genome