S<      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijk l m n o p q r s t u v w x y z { | } ~  (c) Amy de Buitlir 2011-2014 BSD-styleamy@nualeargais.ie experimentalportable Safe-Inferred msg& formats and writes a new log message.(c) Amy de Buitlir 2013-2014 BSD-styleamy@nualeargais.ie experimentalportable Safe-Inferred 01234=JKA diploid agent has two complete sets of genetic instructions. Instances of this class can be thought of as paired genes or paired instructions for building an agent. When two instructions in a pair differ,  dominance2 relationships determine how the genes will be  expressed/ in the agent. Minimal complete definition: .$Given two possible forms of a gene, a takes into account any dominance relationship, and returns a gene representing the result.3Products: encode multiple arguments to constructors(Sums: encode choice between constructors*Meta-information (constructor names, etc.)8Constants, additional parameters and recursion of kind *-Unit: used for constructors without arguments          (c) Amy de Buitlir 2013-2014 BSD-styleamy@nualeargais.ie experimentalportable Safe-Inferred 01234=JKAnalyses a genetic sequence.3Products: encode multiple arguments to constructors(Sums: encode choice between constructors*Meta-information (constructor names, etc.)8Constants, additional parameters and recursion of kind *-Unit: used for constructors without arguments(c) Amy de Buitlir 2011-2014 BSD-styleamy@nualeargais.ie experimentalportableNoneFrom 1http://www.haskell.org/haskellwiki/Random_shuffle   xs n x returns a copy of xs in which the n4th element (if it exists) has been replaced with x.   xs n x returns a copy of xs in which the n%th element has been replaced with x. Causes an exception if xs has fewer than n+1 elements. Compare with  .  Assuming xs> is a sequence containing the elements of a square matrix,   n xs/ returns the elements of the submatrix of size nxn(, centred within the original matrix xs.Example: Suppose we have a 5x5. matrix and we want to extract the central 3x3! submatrix, as illustrated below. da b c d e f g h i j g h i k l m n o ---> l m n p q r s t q r s u v w x y8We can represent the elements of the original matrix as  ['a'..'y']*. The elements of the submatrix are -['g', 'h', 'i', 'l', 'm', 'n', 'q', 'r', 's'], or equivalently,  "ghilmnqrs". And that is what   3 ['a'..'y'] returns.  Assuming xs8 is a sequence containing the elements of a matrix with k columns,   (a,b) (c, d) k xs/ returns the elements of the submatrix from (a,b) in the upper left corner to (c,d)A in the lower right corner). Note: Matrix indices begin at (0,0).Example: Suppose we have a 4x6Z matrix and we want to extract the submatrix from (1,2) to (2,4), as illustrated below. Oa b c d e f g h i j k l ---> i j k m n o p q r o p q s t u v w x8We can represent the elements of the original matrix as  ['a'..'x']*. The elements of the submatrix are ['i', 'j', 'k', 'o', 'p', 'q'], or equivalently, "ijkopq". And that is what   (1,2) (2,4) 6 ['a'..'x'] returns.   nE returns the greatest integer not greater than the square root of n. n mD returns the greatest integer not greater than the log base n of m. n returns True if nQ is a perfect square (i.e., if there exists an _integer_ m such that m*m = n)n  m returns True if nM is a power of m (i.e., if there exists an _integer_ k such that m^k = n)The ' function takes a default value and an  value. If the  is T, it returns the default value; otherwise, it returns the value contained in the .Takes a list of  s and returns a list of all the  values. vLike modify, but the function that maps the old state to the new state operates in the inner monad. For example, s <- get s' = lift $ f s put s'can be replaced with  modifyLift fInvoke a function in the inner monad, and pass the state as a parameter. Similar to modifyLift, but the function being invoked doesn't have a return value, so the state is not modified. For example, s <- get s' = lift $ f scan be replaced with  getLift f&Convert a list of bits to a string of 0s and 1s.Show  non-negative   numbers in binary. !      ! (c) Amy de Buitlir 2013-2014 BSD-styleamy@nualeargais.ie experimentalportableNone 01234=JK (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.Writes a gene to a sequence."Reads the next gene in a sequence.'Return the entire genome.(4Return the portion of the genome that has been read.+Return the entire genome.,4Return the portion of the genome that has been read.-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."3Products: encode multiple arguments to constructors#(Sums: encode choice between constructors$*Meta-information (constructor names, etc.)%8Constants, additional parameters and recursion of kind *&-Unit: used for constructors without arguments*'() !"#$%&'(*+,-)*+,-../0123456"#$%& !"#$%&'()*+,-."!#$ %&'()*-.+,%'() !"#$%&'(*+,-)*+,-../0123456"#$%&(c) Amy de Buitlir 2013-2014 BSD-styleamy@nualeargais.ie experimentalportableNone 01234=JK1(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.2Writes a gene to a sequence.3"Reads the next gene in a sequence.<Return the entire genome.=4Return the portion of the genome that has been read.>5Write a Word8 value to the genome without encoding it?6Read a Word8 value from the genome without decoding it@2Write a raw sequence of Word8 values to the genomeA3Read a raw sequence of Word8 values from the genomeDReturn the entire genome.E4Return the portion of the genome that has been read.FRead 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.73Products: encode multiple arguments to constructors8(Sums: encode choice between constructors9*Meta-information (constructor names, etc.):8Constants, additional parameters and recursion of kind *;-Unit: used for constructors without arguments-/0<=>123456789:;<=?@A>?@ABCDEFGBCDEFGHIJ789:;/0123456789:;<=>?@ABCDEFG123476895:;<=0/BCFGDE>?@A(/0<=>123456789:;<=?@A>?@ABCDEFGBCDEFGHIJ789:;(c) Amy de Buitlir 2014 BSD-styleamy@nualeargais.ie experimentalportableNone 01234=JKJ(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.KWrites a gene to a sequence.L"Reads the next gene in a sequence.UReturn the entire genome.V4Return the portion of the genome that has been read.W6Write a Word16 value to the genome without encoding itX7Read a Word16 value from the genome without decoding itY3Write a raw sequence of Word16 values to the genomeZ4Read a raw sequence of Word16 values from the genome]Return the entire genome.^4Return the portion of the genome that has been read._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.K3Products: encode multiple arguments to constructorsL(Sums: encode choice between constructorsM*Meta-information (constructor names, etc.)N8Constants, additional parameters and recursion of kind *O-Unit: used for constructors without arguments+HIPQRJKLMNOPQRSTUVSWXYZ[\]^_`TUVWXYZ[\KLMNOHIJKLMNOPQRSTUVWXYZ[\]^_`JKLMPOQRNSTUVIH[\_`]^WXYZ&HIPQRJKLMNOPQRSTUVSWXYZ[\]^_`TUVWXYZ[\KLMNO(c) Amy de Buitlir 2011-2014 BSD-styleamy@nualeargais.ie experimentalportableNone aqCuts two lists at the specified locations, swaps the ends, and splices them. The resulting lists will be: 6 a[0..n-1] ++ b[m..] b[0..m-1] ++ a[n..]  Here are some examples.   Expression Result a6 2 5 ("abcdef", "ABCDEF") ("abF","ABCDEcdef") a5 3 1 ("abcd", "ABCDEFG") ("abcBCDEFG","Ad") a4 4 4 ("abcdef", "ABCDEF") ("abcdEF","ABCDef") i If n <= 0 or m <= 0, the corresponding input list will be completely transferred to the other.   Expression Result a6 0 4 ("abcdef", "ABCDEF") ("EF","ABCDabcdef") a6 (-2) 4 ("abcd", "ABCDEFGH") ("EFGH","ABCDabcd") a4 5 0 ("abcdef", "ABCDEF") ("abcdeABCDEF","f") v If n or m are greater than or equal to length of the corresponding list, that list will not be transferred.   Expression Result a6 10 0 ("abcdef", "ABCDEF") ("abcdefABCDEF","") a. 0 0 ("", "ABCDEF") ("ABCDEF","") bSame as a8, except that the two locations are chosen at random.cgCuts two lists at the specified location, swaps the ends, and splices them. This is a variation of a where n == m.dSame as c3, except that the location is chosen at random.e%Mutates a random element in the list.f/Mutates a random element in one list in a pair.g5Performs an operation with the specified probability.h^Performs an operation a random number of times. The probability of repeating the operation n times is p^n.]NRandomly select a boolean, but weighted to return True with probability p.^PChoose an element at random from a list and return the element and its index abcdefgh]ij^ abcdefghij caefjidbhg abcdefgh]ij^ (c) Amy de Buitlir 2011-2014 BSD-styleamy@nualeargais.ie experimentalportableNonekA rotating logger.ll f- creates a logger that will write to file f. k_`albcdeklklk_`albcde (c) Amy de Buitlir 2011-2014 BSD-styleamy@nualeargais.ie experimentalportableNonemA rotating logger.nn d prefix n2 creates a logger that will write to directory d2. The log "rotates" (starts a new log file) every n4 records. Log files follow the naming convention prefix.k, where kj is the number of the last log record contained in the file. If logging has already been set up in  directoryY, then logging will continue where it left off; appending to the most recent log file.mfghijklmnnopqrstuvwmnmn mfghijklmnnopqrstuvw (c) Amy de Buitlir 2012-2014 BSD-styleamy@nualeargais.ie experimentalportableNone3=KoDaemon configuration. If username3 is null, the daemon will run under the login name.tThe agent task.v4Number of microseconds to sleep between agent tasks.ww daemon stateQ creates a daemon running under the current user's real userID, which invokes task.opqrstuvxwyz{|} opqrstuvw opqrstuvwopqrstuvxwyz{|} (c) Amy de Buitlir 2012-2014 BSD-styleamy@nualeargais.ie experimentalportableNoneyBCreates a counter that will store its value in the specified file. x~yz{xyz{xyz{x~yz{ (c) Amy de Buitlir 2014 BSD-styleamy@nualeargais.ie experimentalportableNone24CCreates a resource that will store its value in the specified file.|}~|}~}~||}~(c) Amy de Buitlir 2013-2014 BSD-styleamy@nualeargais.ie experimentalportableNone24BCreates a counter that will store its value in the specified file.   Safe-Inferred  (c) Amy de Buitlir 2012-2014 BSD-styleamy@nualeargais.ie experimentalportableNone3=K6A database offering storage and retrieval for records..Get a list of all active keys in the database.4Return the number of records stored in the database.~Get a list of all archived keys in the database. If the database does not implement archiving, it may return an empty list.(Read an active record from the database.*Read an archived record from the database.jWrite a record to the database. If an agent with the same name already exists, it will be overwritten.hRemove a record from the database. The database may archive records rather than simply deleting them. (c) Amy de Buitlir 2012-2014 BSD-styleamy@nualeargais.ie experimentalportableNone3=KsA simple database where each record is stored in a separate file, and the name of the file is the record's key. d0 (re)creates the FSDatabase in the directory d.Read a record from a file.Write a record to a file. (c) Amy de Buitlir 2014 BSD-styleamy@nualeargais.ie experimentalportableNone3=KMsA simple database where each record is stored in a separate file, and the name of the file is the record's key. mkFSDatabase d0 (re)creates the FSDatabase in the directory d. (c) Amy de Buitlir 2014 BSD-styleamy@nualeargais.ie experimentalportableNone3=K(c) Amy de Buitlir 2012-2014 BSD-styleamy@nualeargais.ie experimentalportableNone234=K]An artificial life species. All species used in Cratr must be an instance of this class.Returns the agent ID.4Returns True if the agent is alive, false otherwise.%A unique ID associated with an agent.7The internal clock used by Cratr is a simple counter.(c) Amy de Buitlir 2012-2014 BSD-styleamy@nualeargais.ie experimentalportableNoneA clock representing the time in a Cratr universe. It is used to schedule events and ensure that each agent gets its fair share of the CPU. This clock is entirely separate from the system clock. It advances only when  is called. This allows Cratr to run without being affected by other processes which might be using the CPU at the same time.%The current time, measured in "ticks"%Advance the clock to the next "tick".(c) Amy de Buitlir 2012-2014 BSD-styleamy@nualeargais.ie experimentalportableNone24BCreates a counter that will store its value in the specified file.(c) Amy de Buitlir 2012-2014 BSD-styleamy@nualeargais.ie experimentalportableNone-Assign a unique ID using the supplied prefix. (c) Amy de Buitlir 2012-2014 BSD-styleamy@nualeargais.ie experimentalportableNone=KyA species that reproduces, transmitting genetic information to its offspring. Minimal complete definition: all except mate.|A sequence of hereditary information for an agent. The type signature for the agent's genome is (Strand a, Strand a). From the twoC strands of the genetic information from this agent, creates a singlex strand that will contribute to the child's genome. (This is analogous to creating either a single sperm or ova.)LBuilds an agent based on the genome provided, if it is possible to do so. (parent1, parent2) name& uses the genetic information from parent1 and parent2) to produce a child with the agent ID name. The default implementation: Calls J to produce a single strand of genetic information from each parent.7Pairs the two strands to create a genome for the child.Calls $ construct a child with this genome.(c) Amy de Buitlir 2012-2014 BSD-styleamy@nualeargais.ie experimentalportableNone=KyA species that reproduces, transmitting genetic information to its offspring. Minimal complete definition: all except mate.2A sequence of hereditary information for an agent.mRecombines the genetic information from two parents, creating genetic information for potential offspring.,Typically this involves the following steps: hRecombine the two strands of genetic information (one from each parent) to obtain two new strands.1Discard one strand, and return the remaining one.LBuilds an agent based on the genome provided, if it is possible to do so. (parent1, parent2) name& uses the genetic information from parent1 and parent2) to produce a child with the agent ID name. The default implementation: Calls " to create a genome for the child.Calls ' to construct a child with this genome.(c) Amy de Buitlir 2012-2014 BSD-styleamy@nualeargais.ie experimentalportableNone 234=KMA program involving multiple agents. The input parameter is a list of agents. The program must return a list of agents that have been *modified*. The order of the output list is not important.A program involving one agent. The input parameter is the agent. The program must return the agent (which may have been modified).%A habitat containing artificial life.-The current "time" (counter) in this universe8Increment the current "time" (counter) in this universe.2Write a message to the log file for this universe.'Generate a unique name for a new agent.-Returns the list of agents in the population.1Returns the list of (dead) agents in the archive.+Returns the current size of the population.zFetches the agent with the specified ID from the population. Note: Changes made to this agent will not "take" until  is called.9Fetches the agent with the specified ID from the archive.>Fetches the agents with the specified IDs from the population.If the agent is alive, adds it to the population (replacing the the previous copy of that agent, if any). If the agent is dead, places it in the archive.!Run a program involving one agentRReturns the current lineup of (living) agents in the universe. Note: Check for  and call , if needed before invoking this function.KReturns true if no agents have yet their turn at the CPU for this round.{Returns true if the lineup is empty or if all of the agents in the lineup have had their turn at the CPU for this round.ZCreates a fresh lineup containing all of the agents in the population, in random order.\Mark the current agent done. If it is still alive, it will move to the end of the lineup.Replenish the energy poolWithdraw energy from the poolF//%(c) Amy de Buitlir 2012-2014 BSD-styleamy@nualeargais.ie experimentalportableNone3=K   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJ6789:;<=>?@ABCDKLMNEFGHIJ6789:;<=>?@ABCDOPQREFGHIJSTUVWXYZ[\ ] ^ _ ` a a b c d e f g h i j k l m n o p q rstuvwxyz{|}~ztnv            ]   ! " # $ _  %  & ' ( ) ! " * + , # - . / 0 1 2 3 4 5 6 i 7 8 9 : ! " ; <=>?@ABCDEFGHIJKLMNOPQ!"RSTUVWXYZ[\]^_`abcdefghijklmnopqrs creatur-5.6.4ALife.Creatur.LoggerALife.Creatur.Genetics.DiploidALife.Creatur.Genetics.AnalysisALife.Creatur.UtilALife.Creatur.Genetics.BRGCBool ALife.Creatur.Genetics.BRGCWord8!ALife.Creatur.Genetics.BRGCWord16$ALife.Creatur.Genetics.Recombination!ALife.Creatur.Logger.SimpleLogger)ALife.Creatur.Logger.SimpleRotatingLoggerALife.Creatur.DaemonALife.Creatur.PersistentALife.Creatur.EnergyPoolALife.Creatur.ChecklistALife.Creatur.Database!ALife.Creatur.Database.FileSystem/ALife.Creatur.Database.CachedFileSystemInternal ALife.CreaturALife.Creatur.ClockALife.Creatur.CounterALife.Creatur.Namer*ALife.Creatur.Genetics.Reproduction.Sexual4ALife.Creatur.Genetics.Reproduction.SimplifiedSexualALife.Creatur.UniverseALife.Creatur.Task Paths_creatur'ALife.Creatur.Database.CachedFileSystemLogger writeToLog timestampDiploidexpress expressMaybe AnalysableanalyseshufflesafeReplaceElementreplaceElement cropSquarecropRectisqrtilogBase perfectSquare isPowerOf reverseLookupstateMap fromEither catEithers modifyLiftgetLiftrotate boolsToBitsshowBin DiploidReaderDiploidSequenceGeneticputgetgetWithDefaultReaderWriterSequencewrite runWriterread runReadercopyconsumedreadAndExpressrunDiploidReadercopy2 consumed2 getAndExpressgetAndExpressWithDefault putRawWord8 getRawWord8 putRawWord8s getRawWord8s putRawWord16 getRawWord16 putRawWord16s getRawWord16s cutAndSplicerandomCutAndSplice crossoverrandomCrossover mutateListmutatePairedListswithProbabilityrepeatWithProbabilityrandomOneOfPairrandomOneOfList SimpleLoggermkSimpleLoggerSimpleRotatingLoggermkSimpleRotatingLoggerDaemon onStartup onShutdown onExceptiontaskusername sleepTimelaunch Persistent mkPersistentgetPSputPSPersistentEnergyPool EnergyPool replenishwithdraw availablemkPersistentEnergyPoolPersistentChecklist CheckliststatusmarkDone notStarteddonesetItemsdeletemkPersistentChecklistDatabaseDBRecordkeys numRecords archivedKeyslookuplookupInArchivestore SizedRecordsizeRecordkey FSDatabase mkFSDatabaseCachedFSDatabasedatabasecache maxCacheSizewithFSDB fromCache addToCachedeleteByKeyFromCachedeleteFromCache trimCachetrimlistSizemkCachedFSDatabase$fDatabaseCachedFSDatabaseAgentagentIdisAliveAgentIdTimeprogramVersionClock currentTimeincTimePersistentCounterCountercurrent incrementmkPersistentCounter SimpleNamerNamergenName mkSimpleNamer ReproductiveStrand produceGametebuild makeOffspring recombineCachedUniverseSimpleUniverse AgentsProgram AgentProgramUniverseAgentDBclocksetClocklogger setLoggeragentDB setAgentDB agentNamersetNamer checklist setChecklist energyPool setEnergyPoolagentIdsarchivedAgentIdspopSizegetAgentgetAgentFromArchive getAgentsisNew withAgent withAgentslineup startOfRound endOfRound refreshLineupreplenishEnergyPoolwithdrawEnergymkSimpleUniversemkCachedUniverse simpleDaemonstartupHandlershutdownHandlerexceptionHandlerrunNoninteractingAgentsrunInteractingAgentsnothing $fGDiploidK1 $fGDiploidM1 $fGDiploid:+: $fGDiploid:*: $fGDiploidU1GDiploidgexpress $fDiploid(,)$fDiploidMaybe $fDiploid[]$fDiploidDouble$fDiploidWord64$fDiploidWord32$fDiploidWord16$fDiploidWord8 $fDiploidWord $fDiploidInt $fDiploidChar $fDiploidBool$fGAnalysableK1$fGAnalysableM1$fGAnalysable:+:$fGAnalysable:*:$fGAnalysableU1 GAnalysableganalyse$fAnalysableEither$fAnalysable(,)$fAnalysableMaybe$fAnalysable[]$fAnalysableWord16$fAnalysableWord8$fAnalysableChar$fAnalysableBoolbase Data.EitherEitherLeftRightGHC.RealIntegral safeSlice $fGGeneticK1 $fGGeneticM1 $fGGenetic:+: $fGGenetic:*: $fGGeneticU1GGeneticgputggetputRawBoolArraygetRawBoolArray intToBools boolsToInt expressEither$fGeneticEither $fGenetic(,)$fGeneticMaybe $fGenetic[]$fGeneticWord16$fGeneticWord8 $fGeneticChar $fGeneticBool word8ToBoolfinalisegetList word16ToBoolweightedRandomBooleanrandomListSelection initialised logFilename initIfNeeded initialisewrite'$fLoggerSimpleLogger directory expFilenamemaxRecordsPerFile recordCountlogCountdebug readState saveStatebumpRecordCountrotateLogIfNeeded rotateLog$fLoggerSimpleRotatingLogger termReceiveddaemonUsername daemonMaindaemonMainLoopwrap handleTERM psInitialisedpsValuepsDefaultValue psFilename readValue$fEnergyPoolPersistentStatus$fChecklistPersistentcatchIOversionbindirlibdirdatadir libexecdir sysconfdir getBinDir getLibDir getDataDir getLibexecDir getSysconfDirgetDataFileName readRecord3 writeRecord3mainDir archiveDirkeysInlookupIn writeRecord2isRecordFileName$fDatabaseFSDatabase$fClockPersistent$fCounterPersistentprefixcounter withCounter$fNamerSimpleNamercuClockcuLoggercuDBcuNamer cuChecklist cuEnergyPoolsuClocksuLoggersuDBsuNamer suChecklist suEnergyPool withClock withLogger withAgentDB withNamer withChecklistwithEnergyPoolshuffledAgentIds$fUniverseCachedUniverse$fUniverseSimpleUniversepopSizeInBoundsatStartOfRound atEndOfRound