diff --git a/docs/Avida-ED-Error-Database.txt b/docs/Avida-ED-Error-Database.txt
new file mode 100755
index 0000000..ca47068
--- /dev/null
+++ b/docs/Avida-ED-Error-Database.txt
@@ -0,0 +1,67 @@
+Flask
+SQLAlchemy - MySQL backend
+
+http://github.com/ruppmatt/AEDeveloper
+
+Two modes -
+ Local for debug (flask)
+ WSGI Apache Module for deployment
+
+MySQL for AEDeveloper
+u/n: aedeveloper
+p/w:
+
+
+leviathan.cme.msu.edu
+
+database is in
+cd ..
+cd ..
+cd /var/www/
+cd wsgi-scripts
+cd AEDeveloper
+ls -l #to see files
+ls -lah #to see . files
+
+files need to be owned by Apache
+so use script
+cat update.sh #to see script to update from github and have apache own
+
+cat aedeveloper.wsgi #to see this protocol that apache uses.
+
+---------------------------------------------------------------------------
+To add a user
+---------------------------------------------------------------------------
+To create a user from the command line use
+sudo ./create_user.sh
+
+create_user.py [-h] username password fullname email
+where username and password cannot spaces
+fullname can be wrapped in quotes and have spaces
+
+need root access to add a user.
+---------------------------------------------------------------------------
+
+Matt uses flask on his machine using start_local.py
+need to have mysSQL running.
+
+Cannot have any print statements when deploy
+
+
+
+To restart Apache
+sudo apachectl restart #apache control
+
+
+cat update.sh does a restart tat is slightly different
+
+sudo service apache2 restart
+
+
+I found an abstract for some of the work discussed in the article.
+
+Immunizing Against Prejudice: Effects of Disease Protection on Attitudes Toward Out-Groups
+By:Huang, JY (Huang, Julie Y.); Sedlovskaya, A (Sedlovskaya, Alexandra); Ackerman, JM (Ackerman, Joshua M.; Bargh, JA (Bargh, John A.)
+PSYCHOLOGICAL SCIENCE Volume: 22 Issue: 12 Pages: 1550-1556 Dec 2011
+Contemporary interpersonal biases are partially derived from psychological mechanisms that evolved to protect people against the threat of contagious disease. This behavioral immune system effectively promotes disease avoidance but also results in an overgeneralized prejudice toward people who are not legitimate carriers of disease. In three studies, we tested whether experiences with two modern forms of disease protection (vaccination and hand washing) attenuate the relationship between concerns about disease and prejudice against out-groups. Study 1 demonstrated that when threatened with disease, vaccinated participants exhibited less prejudice toward immigrants than unvaccinated participants did. In Study 2, we found that framing vaccination messages in terms of immunity eliminated the relationship between chronic germ aversion and prejudice. In Study 3, we directly manipulated participants' protection from disease by having some participants wash their hands and found that this intervention significantly influenced participants' perceptions of out-group members. Our research suggests that public-health interventions can benefit society in areas beyond immediate health-related domains by informing novel, modern remedies for prejudice.
+
diff --git a/docs/Avida-ED_workFlowTesting.txt b/docs/Avida-ED_workFlowTesting.txt
new file mode 100755
index 0000000..b7d7373
--- /dev/null
+++ b/docs/Avida-ED_workFlowTesting.txt
@@ -0,0 +1 @@
+Goals for 2017 0829
Avida
- Changes
- ./run_tests
- commit & push
then
(automated tests)
Don_ͺt have
- No method aside from commit msgs describing changes
- no unit tests
Add in code commit lists
or in the readme file?
tagging commits with Av_ED 3.0.2 or what ever
- on both Avida and AV_UI so we know what version of Av_ui goes with which version of Avida Core
AV_UI
- changes
- haphazard tests by Diane by hand
- commit push
- get Jake to test
- fixes
- commit push with tag.
_____________________________________________________________
following JakeΥs readme file on https://github.com/cousi2344/avida-ed-testing/blob/master/README.rst
toward the end ran
+The file analyze.cfg is used to setup Avida when it is run in
+analyze mode, which can be done by running avida -a. Analyze
+mode is useful for performing additional tests on genotypes after a run
+has completed.
+
+This analysis language is basically a simple programming language. The
+structure of a program involves loading in genotypes in one or more
+batches, and then either manipulating single batches, or doing comparisons
+between batches. Currently there can be up to 2000 batches of genotypes, but
+we will eventually remove this limit.
+
+The rest of this file describes how individual commands work, as well
+as some notes on other languages features, like how to use variables. As
+a formatting guide, command arguments will be presented between brackets,
+such as [filename]. If that argument is
+mandatory, it will be in blue. If it is optional, it will be in green, and
+(if relevant) a default value will be listed, such as
+[filename='output.dat'].
+
+Analyze mode provides a number of commands for loading, manipulating,
+and saving analysis data. In addition to the analyze mode specific
+commands detailed in the following sections, all of the
+Avida actions can be called as well.
+
+There are currently four ways to load in genotypes:
+
+A future addition to this list is a command that will use the "dominant.dat"
+file to identify all of the dominant genotypes from a run, and then lookup and
+load their individual genomes from the archive directory.
+
+All of the load commands place the new genotypes into the current batch,
+which can be set with the
+There are several other commands that will allow you to interact with the
+analysis mode in some very important ways, but don't actually trigger any
+analysis tests or output. Below are a list of some of the more important
+control commands.
+
+Now that we know how to interact with analysis mode, and load in genotypes,
+its important to be able to manipulate them. The next batch of commands
+will do basic analysis on genotypes, and allow the user to prune batches
+to only include those genotypes that are needed.
+
+Next, we are going to look at the standard output commands that will used to
+save information generated in analyze mode.
+
+And at last, we have the actual analysis commands that perform tests on
+the data and output the results.
+
+These commands build input files for Avida, using the capabilities of analyze mode to
+automate some tedium.
+
+This summary is given to help explain the use and constraints for using resources.
+
+When a command specifies the use of resources for the test cpu, it should not
+affect the state of the test cpu after the command has finished. However, this
+means that the test cpu is no longer guaranteed to be reentrant. Each command
+will set up the environment and the resource count in the test cpu with it's own
+environment and resource count. When the command has finished it will set the the
+test cpu's environment and resource count back to what they were before the command
+was executed.
+
+Resource usage for the test cpu occurs by setting the environment and then
+setting up the resource count using the environment. Once the resource
+count has been set up, it will not change during the use of the test cpu.
+When an organism performs and IO, completing a task, the concentrations are
+not changed. This was a design decision, but is easily changed.
+
+In analyze, a new data structure was included which contains a time ordered
+list of resource concentrations. This list can be used to set up resources
+from different time points. By using the update parameter in the RECALCULATE (or RECALC) function,
+you can use the resource concentrations from a specified time
+point. If the LOAD_RESOURCES command is not called, the list defaults to
+a single entry which is the the initial concentrations of the resources
+specified in the environment configuration file.
+
+ Avida analyze mode recognizes several keywords that correspond to information about genotypes.
+ Several commands (such as DETAIL and MAP) require the use of these as format parameters
+ to specify what genotypic features should be output. Others (such as FILTER) use them to identify
+ specific genotypes that possess certain qualities. Before these commands are used, other
+ processing functions may need to be run.
+
+Allowable formats after a normal load (assuming these values were available
+from the input file to be loaded in) are:
+
+After a RECALCULATE (or RECALC), these additional formats become available:
+
+It gives a count of 0 if there is no such instruction.
+
+A note on r_spec.n: This counts nop specifications done by any and all "collect-type" instructions -- that is, any instruction that uses the helper function DoCollect. If more than one such instruction is included in the instruction set, r_spec.n will include specification counts for both instructions without any differentiation.
+For details on what the specification numbers mean, see cCodeLabel::AsIntUnique.
+
+If a FIND_LINEAGE was done before the RECALCULATE (or RECALC), the parent
+genotype for each regular genotype will be available, enabling the
+additional formats:
+
+If an ALIGN is run, one additional format is available:
+
+If a RECALCULATE (or RECALC) was done before the ALIGN, the following format is available:
+
+If tags have been applied to genotypes in analyze mode, an additional format
+is available:
+
+There are a handful of commands that will automatically perform
+landscapping. The landscape will only be run once per organism even when
+multiple output variables are used. For enhanced performance on
+multi-processor/multi-core systems, see the
+PrecalcLandscape action.
+
+Phenotypic plasticity information is available through a number
+of different commands. This information will be gathered in one
+of two manners. If RECALC num_trials X is called, where X is greater
+than 1, phenotypic plasticity information for each genotype in the
+batch will be collected. If RECALC is not called or is called with
+with just one trial (the default for RECALC), then using these commands will request 1000
+trials for each genotype to gather plasticity information. Requesting an analysis
+of phenotypic plasticity in this manner will not re-evaluate other genotype statistics.
+
+
+For the moment, all variables can only be a single character (letter or
+number) and begin with a $ whenever they need to be translated to their
+value. Lowercase letters are global variables, capital letters are
+local to a function (described later), and numbers are arguments to a
+function. A $$ will act as a single dollar sign, if needed.
+
+These functions are currently very primitive with fixed inputs of
+$0 through $9. $0 is always the function name, and then there can be up
+to 9 other arguments passed through. Once a function is created, it can
+be run just like any other command.
+
+Currently there are no conditionals or mathematical commands in this
+scripting language. These are both planned for the future.
+ (Material adapted from Heather Goldsby's dissertation... so, it's a bit formal.) To study group behavior with Avida, we divide the population of digital organisms into distinct subpopulations and link their long-term fates. Groups (also referred to as demes or colonies) can comprise a set of genetically-clonal or genetically-heterogeneous organisms. Β As with individual organisms, entire groups replicate and compete for space, but at a much greater time-scale. Group Competition There are two different forms of group competition. Both types of group competition result in group replication. First, for some experiments, we use tournament selection in which groups compete every 100 updates based on a fitness function, where a group's success is determined by the behavior of its constituent organisms. Each tournament contains a set of groups selected at random, and the group with greatest fitness is replicated (ties are broken randomly).Β Second, some of our experiments use task-based group competition (or deme replication event), where a group replication event is triggered by the collective behavior of individuals within a group. For example, a group could be set to replicate once its constituent organisms have consumed a certain amount of resources. (See create a deme replication event for a tutorial on how to make this work.) FAQ: Subpopulation migration in Avida is supported by the assignment of "migration weights" for connections between subpopulations. The migration "topology" between subpopulations is defined through reading in a connection-weight matrix in the following format:Β # BEGIN To turn on and use subpopulation migration, the following configuration parameters in *avida.cfg* will need to be set appropriately:Β (1)Β MIGRATION_FILE -- This config setting should be set to the migration file name that you want Avida to initialize with. Note: This file must be contained in the same working directory as your avida.cfg, events.cfg, and other Avida-related files. This setting is only used by Avida when the DEMES_MIGRATION_METHOD is set to use the migration matrix, otherwise a dummy value can be left here.Β (2)Β NUM_DEMES - This value specifies the total number of subpopulations in the run and it is *critical* that your MIGRATION_FILE's connectivity matrix have NUM_DEMES rows and that each row has NUM_DEMES columns.Β (3)Β DEMES_MIGRATION_RATEΒ - This value can be between 0.0 and 1.0 and essentially specifies the "success rate" that a triggered migration event will actually take place. When set to 0.0, migration will *never* occur and when set to 1.0, a triggered migration rate will *always* succeed and use the DEMES_MIGRATION_METHOD. If this value was set to 0.50, for example, it would mean that a migration event would trigger but that 50% of the time the actual migration action would not occur.Β (4)Β DEMES_MIGRATION_METHODΒ - This config setting should be set to 4Β to use the new connection matrix setup. Rather than the pre-built migration methods (Any other deme,Β Eight neighboring demes,Β Two adjacent demes in list, etc.), the "4" setting specifies to use the weights within the migration matrix to determine where an organism should migrate to.Β Deme Migration Events (can be added in your events.cfg)
+This document discusses how to implement your own instructions.
+
+For this first step, you will be editing the virtual CPU definition in
+cHardwareCPU.h and cHardwareCPU.cc, both of which are
+found in the directory source/cpu/. Start by going to the
+final section of the class definition in the header file and writing
+the declaration for the new method that will be called whenever the
+instruction is executed. For example, if you were going to add the
+instruction
+If possible, place it near other instructions of the same type. There are
+about a hundred methods cHardwareCPU. This instruction would likely fit best
+with the group of instruction described as "Single-Argument Math".
+That is, all those instructions that perform mathematical operation that only
+affect a single register.
+
+All methods associated with instructions return a
+bool value that determines if it was
+successfully executed. Most instructions will always return true since they
+have no way to fail. The convention that we use to designate a method
+explicitly associated with an instruction is placing a prefix of
+
+Next, you have to write the function body in the code file
+(cHardwareCPU.cc). The method bodies will be listed at the end of
+this file in the same order that they were declared in the header. You would
+find the proper position, and write something to the effect of:
+
+The first line of this method uses a helper function called
+FindModifiedRegister() to identify the register
+that should be affected (it scans the next instruction to test if it is a
+
+Note that this would be a good time to recompile if you want to test how
+well your implementation is going so far.
+
+in the same order that it was defined in the class definition.
+
+Since we want to use a pointer to the appropriate method, that is what we
+must pass into the dictionary. To obtain said pointer, we must list the class
+the function is part of (cHardwareCPU) follow it
+by a double colon (::) and then give the method name
+(Inst_Minus17) without the normal
+parentheses following it. The parentheses indicate that we should execute
+the method. Without them, it is just the data that represents the method,
+and by preceding this whole mess with an ampersand ('&') we get the pointer
+to the location in memory that the method resides.
+
+IMPORTANT: If your instruction interacts with the population, resources,
+or IO, make sure to flag the instruction for speculative stall by adding a third
+ argument, nInstFlags::STALL. For an example, look at the 'h-divide'
+ instruction.
+
+Compile again, and you should have your instruction ready for use.
+
+This last part should be the easiest. If you want the new instruction you
+just created to be loaded on startup, you must add a line in the instruction
+set you are using (specified in the configuration file) to indicate its
+inclusion:
+
+And there you have it! Now the real trick is to test if its working
+properly. I'd recommend using as a framework the creature
+default-classic.org and modifying some of the long series of
+
+Where you have to replace inst_test.org with the name of the
+organism you want to trace. The new file will appear in the
+data/archive/ directory, with the same name as the one you loaded
+in, but a .trace appended to the end.
+
+Various CPU components are often manipulated by instructions, and we
+need a standard way of doing this. We have settled on each component being
+associated with a method to access it, to provide a single location that can
+control that access. This has already been useful -- in a multi-threaded
+CPU (i.e., a CPU that has multiple positions in its genome being executed at
+the same time) each thread has its own registers and heads, so we need to
+always be sure we are manipulating the component of the active thread. If
+you simply use the following methods, they will always find the correct
+component for you.
+
+These are only a sampling of the available methods of interacting with the
+components of the CPU, but they give you a good cross-section without
+overwhelming you with all of the possibilities. You should look through the
+source files if you want to see the other options that are available to you.
+
+There are several very common tasks that are performed during the execution
+of many of the instructions. For each of these tasks we have created a
+helper function to ease the creation of new instructions.
+
+To test your understanding of adding instruction into Avida, try writing two
+new instructions. The first one is the mathematical instruction
+
+Next, you will implement the instruction
+For both of these instruction make sure to craft an organism to test that
+they are working properly!
+
+This document describes the coding standards that should be followed
+when developing within Avida.
+
+ Open and close braces should each be on their own line. Do not
+ place the open brace on the same line as the function signature. The only
+ exception to this rule is single line class methods, in which both braces
+ are allowed to be on the same line as the code (but only in pairs). Examples:
+
+ The open brace should go on the same line as the control structure,
+ the close brace on its own line. Examples:
+
+ The same formatting rules as for/while/etc., but if there is an else clause
+ the close brace should go on the same line as the else statement. Single
+ line if else statements should not get braces, unless they accompany a
+ multi-line statement. Examples:
+
+ Do not use any space between the name and the open parenthesis, inside the
+ parentheses, or before commas that separate arguments. A single space
+ should follow commas that separate arguments. Examples:
+
+ Control structures such as if, for, while, do, and switch statements use a
+ single space before the open parenthesis, but spaces inside them.
+
+ Some groupings of classes should maintain important limitations with respect
+ to class dependency.
+
+ All classes developed as general utility classes should be placed within the
+ source/tools directory. These classes
+ should have no dependencies that extend outside of this directory.
+
+ Usage of the Standard Template Library should be very limited. A number of
+ these templates have unspecified orderings that can vary across platforms,
+ affecting consistency. Where possible, it is greatly preferred to use the
+ local tools classes.
+
+This document describes the interaction between organisms and the population.
+
+When an organism is killed off, its location in the population (that is, its
+population cell) needs to be emptied, the scheduler needs to be notified, and
+various statistics need to be updated to reflect the recently deceased. All of
+this is handled with the method below. In a default Avida setup, this method
+will only be called when a cell needs to be cleared out for a new occupant,
+but you've already seen this method used when you implemented the kill-related
+events in a previous homework. We'll see it also called from code displayed in
+the next section of this document.
+
+This method takes as an argument the cell that needs to be emptied. It starts
+off by making sure that the cell in question actually has an organism in it to
+be killed. If not, it stops right there. If so, it records some statistics
+about that organism's life, and updates its counter of living organisms to
+reflect that there is one fewer.
+
+Once the statistics are finished, the cell itself is cleared with the
+cPopulationCell::RemoveOrganism()
+method (in which the pointer to the organism it once contained is set to NULL).
+At this point if the organism is not the currently running CPU it will be
+deleted. Otherwise, a flag is set that marks the organism for deletion after
+the current instruction has finished executing. Finally, the scheduler (which
+is the object that doles out CPU cycles to the individual organisms) is updated
+to reflect that this cell is now empty.
+
+If an organism is going to be placed into a specific cell of the population,
+the method ActivateOrganism can be called on the population, telling it the
+location in memory of the organism to be placed and the cell to place it in.
+This method will call the KillOrganism() method
+to make sure the cell is unoccupied. This method is called from the
+Inject() method as well as
+ActivateOffspring(), described below.
+Here is the ActivateOrganism method:
+
+
+The first thing we do build a new interface object and attach it to the
+organism object. Next we check to see if the organism has already been
+assigned its genotype. If an organism was born from a parent in the population,
+it will have been assigned a genotype by the time this method is called. If it
+does not have a genotype, however, the classification manager object will be
+called to look up any genotypes that match this genome. The classification
+manager will either return an exact match, or else create a new genotype, add it
+to the archive, and return its pointer. In either case, we now have a genotype
+for this organism.
+
+Before we erase the organism currently in this cell, we want to keep track of
+what genotype it was part of for use in updating the archive later. We then
+kill the organism in the cell (as described above) and insert the new one.
+The cPopulationCell::InsertOrganism()
+method will setup the organism based on the environmental conditions of this
+cell (mutation rate, tasks rewarded, etc), and store the organism for future
+use.
+
+We then adjust the genotype to let it know a new organism of its type has
+been created, and tell the classification manager that it should also adjust
+the genotypes to reflect their new abundances (one genotype has grown by one,
+the other has shrunk, so the genotype ordering may change). Other maintenance
+we need to do at this point includes adjusting the scheduler to let it know the
+merit of this new organism, and the
+Finally, we adjust some more statistics by incrementing the number of
+organisms in the population and let the statistics object know that a new
+organism was born, with all of its information. Remember, if this cell was
+already occupied, KillOrganism() would have decremented it, so this will
+properly reflect the number of organisms alive in the population at any moment.
+
+When an organism gives birth, we must collect some relevant statistics,
+which can best be accomplished in the population object. Then we must
+place the offspring into its own cell in the population. This is all done
+with the cPopulation::ActivateOffspring
+method. This method takes as arguments the parent organism and child genome
+that we're working with. It is called by the divide command via the
+population interface. As this method is quite long, refer to it in the source
+code in cPopulation.cc while reading the remainder of this section.
+
+The first step in activating an offspring involves performing some book keeping
+on the parent's phenotype via the DivideReset()
+method. After this, the child genome is submitted to the birth chamber. The
+birth chamber is responsible for handling the details of reproduction, such as
+genome recombination in sexual populations. The
+SubmitOffspring() method will add organism objects
+to the child_array for each offspring produced.
+
+The next section of code is in charge of finding where in the population each
+child organism should be placed. The cell of the parent is looked up, and then
+the PositionChild() method is called to determine
+the child's cell.
+
+If the parent is not about to be killed off (due to being replaced by one of
+the children), we actually want to do a bit more work -- we need to adjust
+it in the schedule in case its merit has changed over this gestation cycle,
+and (if we are on a grid) we want to turn the child so that it is facing
+its parent.
+
+Finally, we collect a bunch of statistics for the parent's genotype object,
+and we run ActivateOffspring for each offspring produced using the cell we have
+chosen in order to place the child into the population.
+
+Injecting a genome into the population that does not have a parent (such as
+with the
+This file will cover in more detail some of the concepts needed to understand
+C++. The goal here is not to make you be able to sit down and write
+your own program from scratch.
+
+An object in C++ is a single, conceptual unit that contains
+data (information about the state of that object) and
+methods (functions associated with that class of objects) by
+which the object is modified or can interact with other objects. The data in
+an object can be either normal variables (e.g. characters, floating
+point numbers, or integers) or previously-defined objects. A category of
+objects is a class; an object is a single instance of a class.
+
+For example, in Avida one of the most important classes is called
+Don't worry too much about how the syntax works. The code presented above
+is a definition of a class in C++. It is broken into two parts; one labeled
+
+A variable is defined by a description of the type of variable (such
+a
+Methods are slightly more complex. The declaration of a method starts with the
+type of data the method returns (such as
+The C++ language will accept variable names, class names, and method names of
+any alpha-numeric sequence as long as all names begin with a letter. The only
+other character allowed in a name is the underscore ('_'). To make reading code
+easier, we have adopted certain conventions.
+
+Different software projects will each use their own style conventions; these
+are the ones you'll end up working with in Avida. Some exceptions do exist.
+For example, the C++ language itself does not follow many style rules;
+built-in C++ names are all lowercase letters, regardless of what they
+represent. For more details, including spacing and other code formatting
+standards you must follow in Avida, see the
+Coding Standards.
+
+
+
+The section labeled
+The internal m_phenotype object is used to
+record the behaviors and abilities that the organism demonstrates during its
+life. This class has variables to track everything from the tasks performed to
+the gestation time of the organism and the number of offspring it has ever
+produced. The m_interface allows an
+organism to communicate with the environment (either the
+cPopulation or the
+cTestCPU) that it is part of. This is used,
+for example, when an organism is ready to finish replicating and needs its
+offspring to be placed into the population. If an organism is being run on a
+test CPU rather than in a proper population object, then this interface will
+cause the statistics about offspring to be recorded for later use instead of
+activating it.
+
+Next, we have two pointers. A pointer is a value that
+represents ("points to") a location in the physical memory of the computer. A
+pointer can be identified by the asterisk ('*') that follows the type name. The
+code "
+The final data element is m_hardware, a
+pointer to an object of type cHardwareBase.
+This variable is a pointer for a different reason than the genotype. Where a
+single genotype is shared by many different organisms, each organism does
+possess its own hardware. However, Avida supports more than one type of
+hardware, where any of them can be at the other end of that hardware pointer.
+The cHardwareBase class is used as an interface to the actual hardware that is
+used. This is explained in more detail later in the section on inherited
+classes. For the moment, the key idea is that a pointer can sometimes point to
+a general type of object, not just those of a very specific class.
+
+Class descriptions (with limited exceptions) must contain two specific
+methods called the constructor and the
+destructor. The constructor always has the same name as the
+class (it's called cOrganism(...) in this
+case), and is executed in order to create a new object of that class. The
+arguments for the constructor must include all of the information required to
+build on object of the desired class. For an organism, we need the world
+object within which the organism resides, the current execution context, and
+perhaps most importantly the genome of the organism. The method is not defined
+here, only declared. A declared method must be defined
+elsewhere in the program. All methods must be, at least, declared in the class
+definition. Note that if there are many ways to create an object, multiple
+constructors are allowed as long as they take different inputs.
+
+Whereas the constructor is called when an object is created, the destructor
+is called when the object is destroyed, whereupon it must do any cleanup,
+such as freeing allocated memory (see the section on memory management
+below). The name of a destructor is always the same as the class name,
+but with a tilde ('~') in front of it. Thus, the cOrganism's destructor
+is called ~cOrganism(). A destructor can
+never take any arguments, and there must be only one of them in a class
+definition.
+
+The next group of five methods are all called when an organism needs
+to perform some behavior, which in all of these cases involves it interacting
+with the population. For example, if you need to know at whom an organism
+is facing, you can call the method
+GetNeighbor()
+on it, and a pointer to the neighbor currently faced will be returned.
+Likewise, if you need to kill an organism, you can call the method
+Die() on it, and it will be terminated.
+Since each of these require interaction on the population level, the population
+itself takes care of the bulk of the functionality.
+
+The 'Accessors' are methods that provide access to otherwise private
+data. For example, the method GetGenome()
+will literally pass the genome of the organism to the object that calls it. In
+particular, the hardware object associated with an organism will often call
+GetPhenotype() in order to get the current
+state of the organism's phenotype and update it with something new the organism
+has done. Several things to take note of here. In the first three accessors,
+the name of the class being returned is followed by an ampersand ('&').
+This means that the actual object is being passed back, and not just a copy of
+all the values contained in it. See the next section on pointers, references,
+and values for more information about this. Also, in the very first accessor,
+the keyword
+This section has contained information about a particular C++ class found
+in Avida. The next sections will more generally explain some of the
+principles of the language. If you haven't already, now might be a good
+time to take a deep breath before you dive back in.
+
+The three ways of passing information around in a
+C++ program is through sending a pointer to the location of that information,
+sending a reference to it, or actually just sending the value of the information.
+For the moment, lets consider the return value of a method. Consider
+the three methods below:
+
+These three cases are all very different. In the first case
+(Pass-by-Value), the value of the genome in question is
+returned. That means that the genome being returned is analyzed, and the exact
+sequence of instruction in it are sent to the object calling this method. Once
+the requesting object gets this information, however, any changes made to it do
+not affect the original genome that was copied. The second case
+(Pass-by-Pointer),only a few bytes of information are returned
+that give the location in memory of this genome. The requesting object can then
+go and modify that memory if it chooses to, but it must first 'resolve' the
+pointer to do so. Finally, the last case (Pass-by-Reference)
+actually passes the whole object out. It is used in a very similar way to
+pass-by-value, but any changes made to the genome after it is passed out will
+affect the genome in the actual organism itself! Pass-by-reference does not
+add any new functionality over pass-by-pointer, but in practice it is often
+easier to use.
+
+Memory management in C++ can be as simple or complicated as the programmer
+wants it to be. If you never explicitly allocate a chunk of memory, than
+you never need to worry about freeing it up when you're done using it.
+However, there are many occasions where a program can be made faster or
+more flexible by dynamically allocating objects. The command
+
+The variable created_genome is defined as a pointer to a memory location
+containing a genome. This is assigned the location of the newly allocated
+genome in memory, which is the return value of the
+Unfortunately, C++ won't know when we're done using this genome. If we
+need to create many different genomes and we only use each of them once,
+our memory can rapidly fill up. So, we need tell the memory management
+that we are finished with the current object. Thus, when we're done using
+it, we type:
+
+And the memory pointed to by the created_genome
+variable will be freed up.
+
+An excellent example of when allocation and freeing of memory is employed
+in Avida is with the genotype. Every time a new genotype is created during
+evolution, Avida needs to allocate a new object of class cGenotype. During
+the course of a run, millions of genotypes may be created, so we need to be
+sure to free genotypes whenever they will no longer be needed in the run.
+
+One of the beauties of C++ is that well written code
+is inherently very reusable. As part of that, there is the concept
+of the class inheritance. When a new class is built in C++,
+it is possible to build it off of an existing class, then referred to as
+a base class. The new derived
+class will have access to all of the methods in the base class, and can
+overload them; that is, it can change how any of those
+methods operate.
+
+For example, in the Avida scheduler, we use a class called
+cSchedule to determine which organism's
+virtual CPU executes the next instruction. Well, this cSchedule object is not
+all that clever. In fact, all that it does is run through the list of
+organisms that need to go, lets them each execute a single instruction, and
+then does it all over again. But sometimes we need to make some organisms
+execute instructions at a faster rate than others. For that reason, there are
+several derived classes, including
+cIntegratedSchedule, which takes in a merit
+value for each organism, and assigns CPU cycles proportional to that merit.
+Since this new class uses cSchedule as its base class, it can be dynamically
+plugged in during run time, after looking at what the user chooses in the
+configuration file.
+
+If a method is not implemented in a base class (left to be implemented in the
+derived classes) it is called an abstract method. If a base
+class does not implement any of its methods and is only used in order
+to specify what methods need to be included in the derived classes, it is
+referred to as an abstract base class (or sometimes an
+interface class or protocol) and is used
+simply as a method contract for derived classes. An example in Avida where this
+is used is the organism interface with the environemnt. The class
+cOrgInterface is an abstract base class,
+with cPopulationInterface and
+cTestCPUInterface as derived classes. This
+organization allows for organism objects to interact with both the population
+and the test environment, without having to write separate code for each.
+
+The environment source code consists of several main components: resources,
+reactions, and task triggers, plus the libraries that maintain each of these.
+
+A task library is composed of a collection of entries, each of which fully
+describes a single task that can be used to trigger reactions.
+
+Task entries are very straight-forward. They consist of a name, a description,
+a unique ID number, and a method from the task library (cTaskLib) that they
+are associated with. This method looks at the inputs the organism has taken
+in, the values it has output, and returns a number between 0.0 and 1.0
+representing how well the task was performed. Currently, all task tests will
+return an exact zero or one, but fractions are possible if there
+is a quality component associated with the task.
+
+Here is an abridged version of the task library class that manages all of the
+individual entries:
+
+The task library contains an array of task entries that define all of the
+rewarded (or otherwise acted upon) tasks in an environment.
+
+The TestOutput() method can only be run with
+as cTaskContext object that has been initialized
+with the SetupTests method. It will test the
+specific task passed in and return the 0.0 - 1.0 quality measure of how well
+that task was done with the most recent output.
+
+Below is a sample task-tester implementation:
+
+
+This case tests to see if the organism has performed an addition operation.
+It compares all pairs of inputs summed together against the most recent
+output of the organism. If there is a match a full reward (1.0) is given.
+If no match is found, no reward is given (0.0).
+
+The SetupTests method performs some
+precomptution for all of the logic tasks, creating the value
+logic_id within the task context. The
+logic_id has 256 possible values, each of which
+can only be associated with a single logic task. These tests look more like:
+
+If the logic ID is on the list, the task has been done, otherwise it hasn't.
+In each case, the outside world needs to request a test of which tasks have
+been performed, and the library just replied with a numerical answer.
+
+The reaction class keeps track of all of the information associated with
+a single possible environmental reaction. Each reaction must have a unique
+name and a unique numerical ID associated with them. In addition to those
+data, a reaction object also has a task that acts as its trigger, a list of
+other requisites that must be met for the trigger to work, and a list of
+processes that will occur if the reaction goes off. The cReaction object
+acts a a single place to store all of this information.
+
+Resources are a little more complicated than task entries to manage
+and understand. An object of type cResource
+contains 19 pieces of data, and the associated accessors. Like all of the
+other individual units we have discussed, resources have a unique
+name and numerical
+id. For all resource we store the quantities
+associated with their inflow,
+outflow, and
+initial count (each stored as a
+double) as well as the geometry of that resource.
+
+
+For spatial resources we need to be able to describe how a resource
+exists in space so we store data for:
+
+This class describes the dynamics of a resource, not its current count
+(since, for example, we might want local resources where each cell
+would have its own count). However, every time a
+resource is needed, any changes in its quantity from the last time it was
+used can be calculated using these numbers.
+
+The cEnvironment class is used to maintain the details of how the environments
+work using the classes described above and a few others. Below is an
+abbreviated version of this class:
+
+The private data members include all of the libraries needed to specify
+the environment, plus its mutation rates. The
+Load() method takes a filename
+(environment.cfg by default) and will fill out all of the libraries
+in this environment. The most important feature of this class is the
+TestOutput() method, which takes in all sorts
+of information about the current state of the organism that has just done
+an output and fills out an object of type
+cReactionResult with information about what
+happened. It also directly returns a bool that will indicate if there have
+been any changes at all. The specific information it uses to determine
+the results are the inputs the organism has taken in and the outputs it has
+produced -- both needed to determine what tasks have been done, and therefore
+what reactions may have been triggered. This information is encapsulated in
+the task context taskctx. The organism's
+previous task_count and
+resource_count are also needed to determine
+if the reactions requisites have been met. And finally the
+resource_count available to the organisms is
+needed to determine how much of each resource can be used in the reactions.
+
+This document discusses the implementation of the cInstruction and Genome classes.
+
+This class is used to represent a single instruction within a genome. The
+private portion of this class consists of a single number that uniquely
+identifies the type of instruction, and the public section
+has a number of helper methods that allow us to work with that number.
+
+As stated above, the only private datum is a numerical value that identifies
+this instruction. The name m_operand is the term
+that is used for a command name in an assembly language. Most normal assembly
+languages have both an operand and arguments associated with each full command.
+In Avida, the commands have no arguments, and hence they just consist of a
+single operand. The data type used for this is
+The public methods begin with the GetOp() and
+SetOp() methods, which are standard accessors.
+Next, we have a collection of methods that begin with the word 'operator'.
+These are used to define how the corresponding symbols should be treated
+when applied to objects of this class. For example, the method
+operator==() is called when we try to compare
+an object of type cInstruction to another. We have full control over the
+definition of this method, just like any other.
+
+Finally, we have a pair of methods that convert instructions to and from
+alphanumeric characters (symbols). These methods are used to print instructions
+out in a maximally compressed format, and to load them back in. The order of
+symbols used are the letters 'a' through 'z' in lowercase, followed by an
+uppercase 'A' through 'Z' and finally the numbers '0' through '9'. If there
+are more than 62 possible instructions, all the rest are assigned a '?' when
+printed out, and cannot be read back in properly from this format.
+
+A genome is a sequence of instructions. The following class maintains this
+sequence as an array, and provides a collection of methods to manipulate the
+total construct.
+
+The protected variable genome is an array
+containing an object of type cInstruction at each position. The second
+variable active_size denotes the number of
+instructions in this array that are currently being used. The fact that
+these variables are "protected" instead of "private" means that any
+class derived from Genome will also have direct
+access to the variables. In particular, the class
+cCPUMemory extends Genome, adding methods to
+alter the array length and new variables to keep track of information about
+each instruction.
+
+Three constructors allow for a new Genome object to be specified by either a
+genome length, a previously created genome, or else a string -- a sequence
+of symbols representing each instruction in order.
+
+The operators created for manipulating genomes include both assignment
+(setting one genome equal to another) and comparison (testing to see if
+two genomes are identical.) Additionally, there are two
+operator[] methods. This means that if you
+have an object of type Genome, you can index into it to retrieve a single
+instruction. Thus, if the object was called
+The Copy() method is a shortcut to copy memory
+from one position in the genome to another. This method will later be
+overloaded (that is, replaced with a newer version) by
+cCPUMemory such that the proper flags will be copied, with the instruction
+and others will be set to indicate the copied instruction for future tests.
+GetSize() returns the length of the genome, and
+AsString() returns a string who has symbols in
+each position that correspond to the the instruction in the same position in
+the genome.
+
+This document examines the details of commands directly involved in
+replication.
+
+The very first instruction in most heads-based organisms is
+This Inst_MaxAlloc() method will determine the maximum amount of extra space
+that an organism is allowed to allocate, and then run the Allocate_Main()
+function passing in that amount. Allocate_Main is a very long method which is
+mostly just check to make sure that everything going on is legal, and then
+initializes the new memory that was allocated as per the configuration file:
+random, default instruction, or leave as it was in the previous organism that
+used it (for "necrophelia").
+
+Most of the initial self-analysis done on Avida organisms is with the
+
+The search type instructions read in the template (series of nops) that
+follows it, determine the complement template, and find that complement
+elsewhere in the genome. It then sets the registers BX and CX to be the
+distance to the found template and the size of that template respectively.
+Finally, we place the flow control head at the end of the template found in
+order to reference it later on. Obviously this last step only occurs
+in the heads-based search.
+
+The first search instruction executed by a heads organism is typically used
+to locate the end of its genome. The search will place the flow-head at
+the end of the genome, which the organism will use to move the write head to
+this point as well. This is done with the
+If the
+The copy loop is the heart of any organism. It consists of a setup,
+a copy segment to copy one or more instructions, a test segment to determine
+if the loop has finished, and a 'jump' type instruction to move back to
+copy the next line.
+
+In a hand written organism, the setup is an
+The copy segment is typically just a single
+The first thing that happens in this method is the variables
+read_head,
+write_head, and
+cpu_stats are setup as references to the
+appropriate objects in the hardware and organism (that is, any modifications
+to these references change the actual objects, not just a local copy of them).
+This is so that we have easy to use variables locally for those objects that
+we are working with. The read_head and write_head are then adjusted to make
+sure they are in a legal position on the genome (if, for example, the last
+instruction changed the organism's size, the heads might no longer be
+pointing to memory that still exists).
+
+Next, the instruction at the read head is recorded in the variable
+read_inst, and we test to see if this should
+be mutated to some other value. If a mutation does occur, we change the
+read_inst variable to a random value, increment the mutation count, and mark
+flags at the instruction position of the write head to denote the mutation.
+After we determine what instruction was read (be it a correct reading or not),
+we call the ReadInst() method, which is simply
+used to keep track of the most recent template copied. This template is used
+to help detect the end of the organism, which we shall discuss in a moment.
+
+Finally, we collect the statistics that another copy command was executed
+in this organism, finish the write by placing this instruction at the position
+of the write head (and setting its flag as being a copied instruction) and
+then advancing both heads to their next positions.
+
+After an organism executes one of these copies it has to test to see if it
+is done copying itself. The heads based organisms will typically do this
+with the aid of the
+A common adaptation is "unrolling the loop".
+In the hand-written version discussed above, each instruction must have
+three instructions executed to copy it:
+When an organism finishes copying itself, it needs to divide off its
+child using a divide command. In the heads based instruction set, this is
+the
+This method will use the read head to determine the starting location of the
+offspring, and the write head to determine its end. This is logical because
+these are the locations that the heads should be in right after the copy loop
+has finished. Everything after the write head is cut off and discarded as
+"extra lines". This information is passed into the Divide_Main method
+which does the bulk of the work for divide (and is called by all of the various
+divide instructions in all of the sets).
+
+The cHardwareCPU::Divide_Main()
+method is therefore what we are most interested in. It begins by calculating
+the size of that child that would result from the divide point and the
+extra_line count that were passed into it, and runs
+Divide_CheckViable() to make sure that all of
+these values are legal (that is that both parent and child are reasonable
+sizes for organisms, and reasonable sizes in relationship to each other -- for
+definitions of reasonable as found in the configuration file). If any of
+them are not legal, the method returns false.
+
+From this point on, we know the divide is legal, so we just need to process
+it. We create a variable called child_genome,
+which we use to construct the child genome. We use a reference to a Genome
+object inside of the organism so that this child genome is attached to its
+parent organism and will be easily accessible from other places where it will
+be needed later. We're not going to be doing all of the work on it right in
+this method. We initialize the child genome to the section of the parents
+genome that was created for it. We then run
+Resize() on the parent genome to get
+rid of all of this extra space (both child and extra lines).
+
+The Divide_DoMutations() method will test and
+(if needed) process any divide mutations that may occur. There are many of
+them, so this method is quite long. It is followed by
+Divide_TestFitnessMeasures(), which will run the
+offspring through a test CPU for special options that may be set in the
+genesis file (such as mutation reversions). Obviously this is very processor
+intensive since it would occur with every birth, so tests are only performed
+if required. Both of these methods are left to the reader to step through
+themselves.
+
+If we are using extra costs associated with the first time instructions are
+used, those costs a reset now that a divide has occurred, and must be paid for
+again on the next divide cycle.
+
+After a divide, we mark that we no longer have a mal (Memory ALlocation)
+active. If the parent is reset (i.e., we have two offspring, not a parent
+and child) we need to make sure not to advance the IP of the parent. The
+reset parent has its IP placed at the beginning of its genome, and we want
+to leave it there to execute the very first instruction.
+
+Finally, we tell the organism to activate the divide and do something with
+the child. Give the child to the population (or the test CPU as the case
+may be) to be dealt with, and reset the parent if we're splitting into two
+offspring.
+
+In the description of this life-cycle, one issue that has not been discussed is
+where these organisms would perform their computations. In truth, there isn't
+a fixed time other than it must be before the divide occurs, since merit is
+recalculated on a divide. In practice it will typically be placed right before
+the copy loop, but there are plenty of exceptions.
+
+Ideally, in the longer term, an organism's life will be composed of much
+more than just replication and computations -- they will have to interact with
+each other and have more interactions with the environment. In a
+multi-threaded model, organisms will be doing many activities at the same
+time.
+
+This document discusses how to implement your own tasks to use as triggers
+for reactions in the environment.
+
+For this step, you will be editing the task library found in the files
+cTaskLib.cc and cTaskLib.h in the directory
+source/main/. Start by adding the prototype of your new test
+function to the cTaskLib class in the header file. The data that will be
+tested is all stored within task context that is passed into this function.
+This function will output a double that represents the quality with
+which the task is performed. This is a number between 0 and 1 that
+determines the fraction of the bonus that should be received. For tasks that
+are either successful or not, this will only return 0.0 or 1.0.
+
+For example, if we were going to create a task that tests if the organisms
+could double one of their inputs, we might call that task 'times2'. We would
+then add the line to this file:
+
+If possible, place it near other tasks of the same type. In this case,
+I choose to place it directly after Task_Echo(), since this is also an
+easy task for the organisms to perform.
+
+We next go into the code (cTaskLib.cc) file, and add the body of our
+new method. We search for cTaskLib::Task_Echo(), since our new prototype
+followed this method in the header file, and place the body of our function
+immediately after it.
+
+The most recent output is always placed at the beginning of the output
+buffer, so we store it in the variable
+test_output to compare it against all of the
+different inputs. We then have a for-loop that goes from 0 to the number
+of inputs stored in the input buffer. Inside the body of the loop, we
+test for each input if twice that input is equal to the output. If so,
+then the task was successful and we return a 1.0. If all of the tests
+fail and we exit the loop, then we return a 0.0.
+
+These test methods should be carefully written so that they run as fast
+as possible. In particular, if a task requires that an output be
+compared to multiple inputs at a time (i.e., the tasks Add or Subtract),
+then this can become combinartoically explosive. For the moment, we
+keep control on this problem by only allowing three different inputs
+in the input buffer, but in the future this number may need to become
+higher.
+
+This next step is also done in the code file, inside the
+cTaskLib::AddTask()
+method. Again, we want this to be in the same place, so we locate the
+task 'echo' that its supposed to follow, and add in the new line.
+
+This line will attach the name to the description "Times2" (which
+could have been a little more detailed, but should be 40 characters or less)
+as well as the function that should be called when that name is listed as a
+trigger to a reaction.
+
+You are now ready to use your task!
+ These place limits on when an organism can successfully issue a divide command to produce an offspring. Many other requirements can be imposed. See avida.cfg for
+The energy model provides an organism with a metabolic rate, which is proportional to its stored energy (shown below).
+
+An organism with a higher metabolic rate will pay more energy to execute instructions than one with a lower rate.
+
+An organism must pay both virtual CPU cycle and energy costs to execute instructions.
+
+As instructions are executed the organism's stored energy level is reduced.
+
+Energy can be taken up by the organism when it completes a task, among others.
+
+The settings below are defults from
+
diff --git a/docs/documentation/Analysis-settings.md b/docs/documentation/Analysis-settings.md
new file mode 100644
index 0000000..3498f2b
--- /dev/null
+++ b/docs/documentation/Analysis-settings.md
@@ -0,0 +1,3 @@
+These settings allow you to control the number of analyze threads and to define values that analyze mode can access.
+
+See avida.cfg for MAX_CONCURRENCY, ANALYZE_OPTION_1, and ANALYZE_OPTION_2.
diff --git a/docs/documentation/Analyze-File.md b/docs/documentation/Analyze-File.md
new file mode 100644
index 0000000..3a70869
--- /dev/null
+++ b/docs/documentation/Analyze-File.md
@@ -0,0 +1,1010 @@
+The Analyze File
+Analyze Mode Commands
+
+Load Commands
+
+
+
+
Example: LOAD_MULTI_DETAIL 100 100 100000 ../my_run/run100/
+
+ This would load in the files detail_pop.100 through detail_pop.100000
+ in steps of 100, from the directory of my choosing. Since 1000 files will
+ be loaded and we didn't specify starting batch, they will be put in
+ batches 0 through 999.
+Batch Control Commands
+SET_BATCH command. Below is the list of control
+functions that allow you to manipulate the batches.
+
+
+
+
+Analysis Control Commands
+
+
+
+
+
+Genotype Manipulation Commands
+
+
+
+
+
+
+ RECALC update 10 use_resources use_manual_inputs 256948023 870730840 1441302276
+
+ will set the update to 10, request the use of resources, and test the genotypes using the inputs 256948023, 870730840, and 1441302276. Manually specified environment inputs must conform to the pseudo-random numbers as
+ described in cEnvironment::SetupInputs.
+ Typically, use_manual_inputs will override use_random_inputs, however if num_trials is set to greater than one, manual input specficiation will be overriden
+ and random inputs will be used to gather phenotypic plasticity information that will be available
+ for genotype statistics at the bottom of this document. Please note that phenotypic plasticity
+ analysis perfoemd by using RECALC will reset genotype statistics to the values for the most likely
+ phenotype. Implicit phenotypic plasticity analysis (e.g. by not calling RECALC or calling RECALC with num_trials 1)
+ will not re-evaluate the genotype statistics in this manner and instead rely on the initial values or
+ those values from a single recalculation.
+
+ FILTER fitness >= 1.5
+ will save only those genotypes with a fitness greater than or equal to 1.5. Set the section on
+ Genotype Statistics for more information on what keywords can be used here.
+Basic Output Commands
+
+
+
+
+
+Analysis Commands
+
+
+
+
+AVERAGE_MODULATITY legend.dat At the moment doesn't support html
+ output format and works with only 1 and 2 input tasks.
+
Output: Batch1Name Batch2Name AveDistance Count FailCount
+Building Input Files for Avida
+
+
+
+
+
+
+ Warning: Unlike SaveClone, WRITE_CLONE does not preserve location.
+ Any spatial structure the population had is lost.
+
+ Warning: injection is in order that the genotypes appear in the batch.
+ This will break any spatial structure your population may have had.
+
+ Warning: injection is in order that the genotypes appear in the batch and doesn't take into account the original location.
+ This will break any spatial structure your population may have had.
+
+ Each population should be square, of grid_side x grid_side dimensions. (You will have
+ to set up the world in avida.cfg to have WORLD_X of grid_side and WORLD_Y of 2*grid_side.)
+ Each population may not be larger than 10,000 organisms. Organisms from batch_A will
+ be assigned the given lineage label; organisms from batch_B will be assigned the given
+ lineage label + 1.
+
+ Warning: Like WRITE_INJECT_EVENTS, WRITE_COMPEITITIONS will destroy any
+ spatial structure the populations may have had. Also, since it severs/joins only the grid_side
+ row, it is not suitable for use with WORLD_GEOMETRY values other than 1 (bounded grid).
+Using Test CPU Resources Summary
+
+
+
+
+
+
+Genotype Statistics
+
+
+
+
+
+id (Genome ID)
+ parent_id (Parent ID)
+ parent2_id (Second Parent ID in sexual genotypes)
+
+
+num_cpus (Number of CPUs)
+ total_cpus (Total CPUs Ever)
+ length (Genome Length)
+
+
+update_born (Update Born)
+ update_dead (Update Dead)
+ depth (Tree Depth)
+
+
+lineage (Unique Lineage Label)
+ sequence (Genome Sequence)
+ task_list (List of all tasks performed)
+
+
+
+
+viable (Is Viable [0/1])
+ copy_length (Copied Length)
+ exe_length (Executed Length)
+
+
+merit (Merit)
+ comp_merit (Computational Merit)
+ gest_time (Gestation Time)
+
+
+efficiency (Replication Efficiency)
+ fitness (Fitness)
+ div_type (Divide type used; 1 is default)
+
+
+mate_id (Mate Selection ID Number
+ (sexual genotypes))
+ executed_flags (Executed Flags)
+ task_order (Task Performance Order)
+
+
+task.n (# of times task number n is done)
+ task.n:binary (is task n done, 0/1)
+ total_task_count (# of unique tasks done)
+
+
+total_task_performance_count (total # of tasks done)
+ inst.n (# of times instruction #n is done)
+ r_tot.n (amount of resource n added to the organism's store in its lifetime)
+
+
+r_avail.n (amount of resource n in organism's store)
+ r_spec.n (# of times specification #n is used)
+
+
+
+
+parent_dist (Parent Distance)
+ ancestor_dist (Ancestor Distance)
+
+
+comp_merit_ratio, (Computational Merit Ratio with parent)
+ efficiency_ratio (Replication Efficiency Ratio with parent)
+
+
+fitness_ratio (Fitness Ratio with parent)
+ parent_muts (Mutations from Parent)
+
+
+html.sequence (Genome Sequence in Color; html format)
+
+
+
+
+alignment (Aligned Sequence)
+
+
+
+
+alignment_executed_flags (Alignment Executed Flags)
+
+
+
+
+tag (Genotype Tag)
+
+
+
+
+frac_dead (Fraction of Lethal Mutations)
+ frac_neg (Fraction of Harmful Mutations)
+
+
+frac_neut (Fraction of Neutral Mutations)
+ frac_pos (Fraction of Beneficial Mutations)
+
+
+complexity (Physical Complexity of Organism)
+ land_fitness (Average Mutation Fitness)
+
+
+
+
+num_phen (Number of Phenotypes Identified)
+ phen_avg_fitness (Weighted Average Fitness)
+
+
+num_trials (Number of Phenotype Tests)
+ phen_entropy (Phenotypic Entropy [bits])
+
+
+phen_max_fit_freq (Maximum Fitness Phenotype Frequency)
+ phen_max_fitness (Maximum Phenotype Fitness)
+
+
+phen_min_fit_freq (Minimum Fitness Phenotype Frequency)
+ phen_min_fitness (Minimum Phenotype Fitness)
+
+
+phen_likely_freq (Most Likely Phenotype Frequency)
+ phen_likely_fitness (Fitness of the Most Likely Phenotype)
+
+
+prob_task.n (Probability of task n being performed)
+ prob_viable (Probability of genotype viability)
+Variables
+
+
+
+
+
+Functions
+
+
+
+
+
+ FUNCTION MY_HTML_LINEAGE # arg1=run_directory
+ PURGE_BATCH
+ LOAD $1/detail-100000.spop
+ FIND_LINEAGE num_cpus
+ RECALCULATE
+ DETAIL $1/lineage.html depth parent_dist length fitness html.sequence
+ END
+
+
+This works identically to how we found lineages and printed their data in the section above. Only this time, it has created the new command called MY_HTML_LINEAGE that you can use anytime thereafter. Arguments to functions work similar to variables, but they are numbers instead of letters. Thus $1 translates to the first arguments, $2 becomes the second, and so on. You are limited to 9 arguments at this point, but that should be enough for most tasks. $0 is the name of the function you are running, in case you ever need to use that.
+
+You may be interested in also using functions in conjunction with the SYSTEM command. Anything you type as arguments to this command gets run on the command line, so you can make functions to do anything that could otherwise be done were you at the shell prompt. For example, imagine that you were going to use a lot of compressed files in your analysis that you would first need to uncompress. You might right a function like:
+
+
+ FUNCTION UNZIP # Arg1=filename
+ SYSTEM gunzip $1
+ END
+
+
+This is a shorter example than you might typically want to write a function for, but it does get the point across. This would allow you to just type UNZIP whenever you needed to uncompress something.
+
+Functions are particularly useful in conjunction with the INCLUDE command. You can create a file called something like my_functions.cfg in your Avida work directory, define a bunch of functions there, and then start all of your analyze.cfg files with the line:
+
+ INCLUDE my_functions.cfg
+
+and you will have access to all of your functions thereafter. Ideally, as this language becomes more flexible, so will your ability to create functions within the language, so you will be able to develop flexible and useful libraries for yourself.
diff --git a/docs/documentation/Analyze-mode-:-finding-lineages.md b/docs/documentation/Analyze-mode-:-finding-lineages.md
new file mode 100644
index 0000000..1792c3d
--- /dev/null
+++ b/docs/documentation/Analyze-mode-:-finding-lineages.md
@@ -0,0 +1,18 @@
+Quite often, the portion of an Avida run that we will be most interested in is the lineage from the final dominant genotype back to the original ancestor. As such, there are tools in Avida to get at this information.
+
+
+ FORRANGE i 100 199
+ SET d /home/charles/dev/avida/runs/evo-neut/evo_neut_$i
+ PURGE_BATCH
+ LOAD $d/detail-100000.spop
+ FIND_LINEAGE num_cpus
+ RECALCULATE
+ DETAIL lineage.$i.html depth parent_dist length fitness html.sequence
+ END
+
+
+This program looks very similar to one in the Using Variables example. The first four lines are actually identical. A .spop detail file contains all of the genotypes that were currently alive in the population at the time it was printed, and by default all of the genotypes that are direct ancestors of those that were still alive. (If you used the save_historic=1 option when you saved this population, the .spop contains only the currently-alive genomes, and you will not find much of a lineage!)
+
+The .spop file therefore gives us the lineages of the entire population back to the original ancestor. Since we are only interested in a single lineage, the next thing we do is run the FIND_LINEAGE command to pick out a single genotype, and discard everything else except for its lineage. In this case, we pick the genotype with the highest abundance (the most virtual CPUs associated with it) at the time of printing.
+
+As before, the RECALCULATE command gets us any additional information we may need about the genotypes, and then we print that information to a file using the DETAIL command. The filenames that we are using this time have the format lineage.$i.html, so they are all being written to the current directory with filenames that incorporate the run number right in them. Also, because the filename ends in the suffix '.html', Avida knows to print the file in a proper html format. Note that the specific values that we choose to print take advantage of the fact that we have a lineage (and hence measured things like the genetic distance to the parent) and are in html mode (and thus can print the sequence using colors to specify where exactly mutations occurred).
diff --git a/docs/documentation/Analyze-mode-:-testing-a-genome-sequence.md b/docs/documentation/Analyze-mode-:-testing-a-genome-sequence.md
new file mode 100644
index 0000000..4e22e07
--- /dev/null
+++ b/docs/documentation/Analyze-mode-:-testing-a-genome-sequence.md
@@ -0,0 +1,14 @@
+The following program will load in a genome sequence, run it through a test CPU, and output the information about it in a couple of formats.
+
+
+ VERBOSE
+ LOAD_SEQUENCE rmzavcgmciqqptqpqcpctletncogcbeamqdtqcptipqfpgqxutycuastttva
+ RECALCULATE
+ DETAIL detail_test.dat fitness merit gest_time length viable sequence
+ TRACE
+ PRINT
+
+
+This program starts off with the VERBOSE command so that Avida will print to the screen all of the details about what is going on as it runs the analyze script; I recommend you begin all of your programs this way for debugging purposes. The program then uses the LOAD_SEQUENCE command to allow the user to enter a specific genome sequence in its compressed format. This will translate the genome into the proper genotype as long as you are using the correct instruction set file, since that file determines the mappings of letters to instructions).
+
+The RECALCULATE command places the genome sequence into a test CPU, and determines its fitness, merit, gestation time, etc. so that the DETAIL command that follows it can have access to all of this information as it prints it to the file "detail_test.dat" (its first argument). The TRACE and PRINT commands will then print individual files about this genome, the first tracing its execution line-by-line, and the second summarizing all sorts of statistics about it and displaying the genome. Since no directory was specified for these commands, archive/ is assumed, and the filenames are org-S1.trace and org-S1.gen. If a genotype has a name when it is loaded, that name will be kept, but if it doesn't, it will be assigned a name starting at org-S1, then org-S2, and so on counting higher. The TRACE and PRINT commands add their own suffixes to the genome's name to determine the filename they will be printed as.
diff --git a/docs/documentation/Analyze-mode-:-try-it-yourself-exercises.md b/docs/documentation/Analyze-mode-:-try-it-yourself-exercises.md
new file mode 100644
index 0000000..d59099f
--- /dev/null
+++ b/docs/documentation/Analyze-mode-:-try-it-yourself-exercises.md
@@ -0,0 +1,12 @@
+Here are a couple of example problems you can try to see how well you can use analyze mode. These should get you used to working with it for future projects.
+
+Problem 1. A detail file in Avida contains one line associated with each genotype, in order from the most abundant to the least. Currently, the LOAD command will load the entire file's worth of genotypes into the current batch, but what if you only wanted the top few? You should write a function called LOAD_DETAIL_TOP that takes two arguments. The first ($1) is the name file that needs to be loaded in (just as in the original command), and the second is the number of lines you want to load.
+
+The easiest way to go about doing this is by using the SYSTEM command along with the Unix command head which will output the very top of a file. If you typed the line:
+
+ head -42 detail-1000.spop > my_temp_file
+
+
+The file my_temp_file would be created, and its contents would be the first 42 lines of detail-1000.spop. So, what you need this function to do is create a temporary file with proper number of lines from the detail file in it, load that temp file into the current batch, and then delete the file (using the rm command). Warning: be very careful with the automated deletions -- you don't want to accidentally remove something that you really need! I recommend that you use the command rm -i until you finish debugging. This problem may end up being a little tricky for you, but you should be able to work your way through it.
+
+Problem 2. Now that you have a working LOAD_DETAIL_TOP command, you can run LOAD_DETAIL_TOP 1 in order to only load the most dominant genotype from the detail file. Rewrite the example program from the section "Working with Batches" above such that you now only need to work within a single batch.
diff --git a/docs/documentation/Analyze-mode-:-using-variables.md b/docs/documentation/Analyze-mode-:-using-variables.md
new file mode 100644
index 0000000..734647e
--- /dev/null
+++ b/docs/documentation/Analyze-mode-:-using-variables.md
@@ -0,0 +1,25 @@
+Often, you will want to run the same section of analyze code with multiple different inputs each time through, or else you might simply want a single value to be easy to change throughout the code. To facilitate such programming practices, variables are available in analyze mode that can be altered for each repitition through the code.
+
+There are actually several types of variables, all of which are a single letter of number. For a command that requires a variable name as an input, you simply put that variable where it is requested. For example, if you were going to set the variable i to be equal to the number 12, you would type:
+
+ SET i 12
+
+But later on in the code, how does Avida know when you type an i if you really want the letter 'i' there, or if you prefer the number 12 to be there? To distinguish these cases, you must put a dollar sign '$' before a variable wherever you want it to be translated to its value instead of just using the variable name itself.
+
+There are a few different commands that allow you to manipulate a variable's value, and sometimes execute a section of code multiple times based off of each of the possible values. Here is one example:
+
+
+ FORRANGE i 100 199
+ SET d /home/charles/dev/avida/runs/evo-neut/evo_neut_$i
+ PURGE_BATCH
+ LOAD $d/detail-100000.spop
+ RECALCULATE
+ DETAIL $d/detail.dat update length fitness sequence
+ END
+
+
+The FORRANGE command runs the contents of the loop once for each possible value in the range, setting the variable i to each of these values in turn. Thus the first time through the loop, 'i' will be equal to the value '100', then '101', '102', all the way up to '199'. In this particular case, we have 100 runs (numbered 100 through 199) that we want to work with.
+
+The first thing we do once we're inside the loop is set the value of the variable 'd' to be the name of the directory we're going to be working with. Since this is a long directory name, we don't want to have to type it over every time we need it. If we set it to the variable d, then all we need to do is type '$d' in the future, and it will be translated to the full name. Note that in this case we are setting a variable to a string instead of a number; that's just fine and Avida will figure out how to handle it properly. This directory we are working with will change each time through the loop, and that it is no problem to use one variable as part of setting another.
+
+After we know what directory we are using, we run a PURGE_BATCH to get rid of all of the genotypes from the last time through the loop (lest we just keep building up more and more genotypes in the current batch) and then we refill the batch by using LOAD to load in all of the genotypes saved in the file detail-100000.spop within our chosen directory. The RECALCULATE command runs all of the genotypes through a test CPU so we have all the statistics we need, and finally DETAIL will print out the stats we want to the file detail.dat, again placing it in the proper directory. The END command signifies the end of the FORRANGE loop.
diff --git a/docs/documentation/Analyze-mode-:-working-with-batches.md b/docs/documentation/Analyze-mode-:-working-with-batches.md
new file mode 100644
index 0000000..b89ee21
--- /dev/null
+++ b/docs/documentation/Analyze-mode-:-working-with-batches.md
@@ -0,0 +1,17 @@
+In analyze mode, we can load genotypes into multiple batches and we then operate on a single batch at a time. So, for example, if we wanted to only consider the dominant genotypes at time points 100 updates apart, but all we had to work with were the detail files (containing all genotypes at each time point) we might write a program like:
+
+
+ SET d /home/charles/avida/runs/mydir/here-it-is
+ SET_BATCH 0
+ FORRANGE u 100 100000 100 # Cycle through updates
+ PURGE_BATCH # Purge current batch (0)
+ LOAD $d/detail-$u.spop # Load in the population at this update
+ FIND_GENOTYPE num_cpus # Remove all but most abundant genotype
+ DUPLICATE 0 1 # Duplicate batch 0 into batch 1
+ END
+ SET_BATCH 1 # Switch to batch 1
+ RECALCULATE # Recalculate statistics...
+ DETAIL dom.dat fitness sequence # Print info for all dominants!
+
+
+This program is slightly more complicated than the other examples, so I added in comments directly inside it. Basically, what we do here is use batch 0 as our staging area where we load the full detail dumps, strip them down to only the single most abundant genotype, and then copy that genotype over into batch 1. By the time we're done, we have all of the dominant genotypes inside of batch 1, so we can print anything we need right from there.
diff --git a/docs/documentation/Avida-3-API.md b/docs/documentation/Avida-3-API.md
new file mode 100644
index 0000000..47bb9c2
--- /dev/null
+++ b/docs/documentation/Avida-3-API.md
@@ -0,0 +1,273 @@
+Avida 3 will include and be built around a flexible, extensible application programming interface (API). The intention of the API is to provide a powerful, stable interface to core Avida functionality.
+
+The API will be broken up into multiple modules that will be connected together to create rich experiments and powerful analyses. The development of this API is very active right now. The following provides an overview of existing components and an estimation of their completeness and stability.
+
+### API Modules
+* core
+* data
+* environment
+* systematics
+* util
+* viewer
+
+### Notes
+The following are miscellaneous notes, which may or may not be relevant to the current Avida 3.0 plans. Preserved for consideration.
+
+* Get rid of merit. Organisms have energy (which they absorb by performing reactions) and metabolic rate, which determines how quickly they use that energy to execute instructions.
+* Each thread in an organism is placed into the scheduler. When a thread is created, the scheduler assigns it a process ID, and that ID is then freed up with the thread is removed. A thread must keep track of its own ID. When a thread is removed, its ID is placed in a container of free IDs. Only when that container is empty are new IDs created. This will happen rarely enough that its okay if its a slow process.
+* New analyze mode! This should be interesting... Require lex & yacc?
+* Implement new method of performing mutations. The old stuff should be entirely removed.
+* This version will be optimized for stack-based CPUs, but the old register based CPUs should still function fine.
+* Make sure all output files have headers. There should be a central object that all files are output through that will make sure this is the case.
+* Make events just call analyze scripts. Re-design entire event structure.
+
+### Mutations.cfg ideas
+
+# @CAO : THIS IS A PROTOTYPE FILE FOR HOW I'D LIKE TO SEE MUTATIONS WORK
+
+# This file is used to configure the mutations that occur during an avida
+# run. The format is simple:
+#
+# MUTATION
+
+
+### Stack-based Instruction Set
+
+# This new CPU has 8 heads, 2 of each main type, and otherwise has four
+# stacks (A, B, C, and D) and no registers.
+
+# Base Instruction Set
+# Nops (1-4)
+Nop-A 1 # Associated with the Instruction Pointers
+Nop-B 1 # Associated with the Read Heads
+Nop-C 1 # Associated with the Write Heads
+Nop-D 1 # Associated with the Flow Heads
+
+# Other control functions (5)
+Toggle 1 # Causes all instructions to swap to a complementary behavior
+ # affects only the instruction that immediately follows it.
+ # A nop indicates that the associate head should be toggled
+ # to its alternate. Two toggles will reset all toggled states
+
+# Single input Math -- *modifies* top of ?Stack-B? (6-7)
+Val-Shift 1 # shirt-r before toggle, shift-l after.
+Val-Inc 1 # inc before toggle, dec after
+
+# Double input math -- uses top of Stack-A and Stack-B; pushes result onto
+# the top of Stack-B (8-9)
+Val-Nand 1 # unaffected by toggle
+Val-Add 1 # add before toggle, sub after
+
+# Biological (10-13)
+SetMemory 1 # Set the write head at the beginning of a memory space. Up
+ # to four memory spaces can be used at once. Nop-A is the
+ # main genome, and the other nops are possible offspring.
+ # A nop argument will indicate a space; no nops will find
+ # an "unclaimed" memory space (if possible)
+ # Perhaps Toggle can be used for recombination somehow??
+Divide 1 # Divide off offspring memory. After toggle becomes Inject.
+ # If threads are active a successful inject will also cause
+ # a fork. In either case, it uses the memory that contains
+ # the active write head.
+Inst-Read 1 # Push the instruction at ?read-head? into Stack-A (advance
+ # head) Toggle to move head back by one rather than advance.
+Inst-Write 1 # Pop Stack-A into position at ?write-head? (advance head)
+ # Toggle to move head back by one rather than advance.
+
+# Flow Control (14-15)
+If-Equal 1 # Compares top of ?Stack-A? with successor (Default: Stack-B)
+ # Becomes If-NEqual after toggle
+If-Less 1 # Compares top of ?Stack-A? with successor (Default: Stack-B)
+ # Becomes If-Greater after toggle
+
+# Head Control (16-19)
+Head-Push 1 # Push position of ?IP? head onto Stack-B.
+ # Toggle to use Stack-D
+Head-Pop 1 # Move ?flow-head? to address in Stack-B (pop Stack-B)
+ # Toggle to use Stack-D
+
+Head-Move 1 # Move ?IP? head to flow-head
+ # - if flow-head is given as nop, advance flow-head
+ # Toggle to decrement flow-head when given as nop.
+Search 1 # Search for matching template, set flow head to last line,
+ # template size to Stack-A and template distance to Stack-B
+ # If no template, move flow-head to next line, set A&B=0.
+ # Toggle to NOT leave size&distance
+
+# Stack Control (20-24)
+Push-Next 1 # Pop off ?Stack-A? and push on successor (Default: Stack-B)
+Push-Prev 1 # Pop off ?Stack-B? and push on predecessor (Default: Stack-A)
+Push-Comp 1 # Pop off ?Stack-B? and push on complement (Default: Stack-D)
+Val-Delete 1 # Pop off (and lose) top value of ?Stack-B?
+Val-Copy 1 # Duplicate the contents at the top of ?Stack-B?
+
+# CPU:
+# Stack-A (Used in copying & math)
+# Stack-B (Used for positioning and math)
+# Stack-C (Input) -- Filled on birth
+# Stack-D (Output) -- Scanned (and emptied) on divide
+#
+# Four nops. Each nop has a predecessor, successor and complement (opposite)
+#
+# nop-A -> IP
+# nop-B -> Read Head
+# nop-C -> Write Head
+# nop-D -> Flow Head
+#
+# Note lack of allocate instruction!
+# The organism has additional memory space that the write heads starts out
+# at the beginning of. It is treated as an extension of the main memory,
+# BUT is local to each thread if there is more than one.
+
+# SAMPLE ORGANISM:
+#
+# Search # 1: Find organism end.
+# Nop-C # 2: - Match A:A
+# Nop-C # 3:
+# Head-Push # 4: Save end position to Stack-B
+# Nop-D # 5: - Flow head is at end...
+# Push-Prev # 6: Move end position to Stack-A
+# SetMemory # 7: Place write-head in memory space for offspring
+# Search # 8: Drop flow head at start of copy loop
+# Inst-Read # 9:
+# Inst-Write # 10:
+# Head-Push # 11: Get current position of...
+# Nop-C # 12: - Read-Head
+# If-Equal # 13: Test if we are done copying...
+# Divide # 14: ...If so, divide.
+# Head-Move # 15: ...If not, continue with loop.
+# Nop-A # 16:
+# Nop-A # 17:
+
+# Other possible, special instructions...
+# ScanWorld 1 # Environment-specific scanning instruction...
+# Val-Swap 1 # Swap top contents of ?Stack-A? with successor (Default: B)
+ # Toggle will swap with complement.
+# Inst-Copy 1 # Combine read and write
+# Inst-Move 1 # Like Inst-Copy, but actually deletes original and can
+ # move multiple lines at once (as indicated by ?Stack-B?)
+# SearchOut 1 # Like search, but in faced creature. Needs exact match!
+# Rotate 1 # Rotate to neighbor with template (toggle reverses dir)
+ # in mass action, find randomly in population.
+# If-Bit-1 1 # Is last bit of ?Stack-B? a one? (toggle to If-Bit-0)
+# If-Zero 1 # Toggle to If-N-Zero
+# If-InstEqu 1 # Does contents of ?read-head? match successor (write-head)
+ # (toggle to If-InstNEqu)
+# Order 1 # Put top two numbers in ?Stack-B? into numerical order
+# Push-Zero 1 # Push a zero onto the top of ?Stack-B?
+# Replicate 1 # Make a full offspring
+
+
+# ------- THREADING --------
+# There can only be up to four threads in an organism, specified as
+# Thead-A through Thread-D
+
+# Hardware:
+# For threads, Stacks A and B are local, while C and D are global.
+# All heads are local to each thread.
+# - Read and Flow heads will initialize to fork.
+# - Write head will initialize on new offspring memory.
+# Each thread has its own offspring memory.
+# Each thread keeps its own list of toggled instructions.
+
+# Instructions:
+# ThreadFork 1 # Create a new thread. By default this will be the next
+ # available thread ID, but if a nop follows it will
+ # indicate the thread instead. If a thread is specified
+ # that already exists, its priority will increase to a
+ # maximum. On the original thread executes the next
+ # instruction. Toggle to ThreadKill ?cur-Thread?, which
+ # will decrement a thread one step, to a min of 0.
+# If-Thread 1 # Only execute next instruction if this is ?Thread-A?
+ # Toggle to IfNThread
+# ThreadCopy 1 # Make this thread an exact copy of ?Thread A? including
+ # working on the same memory space. Toggle to ThreadClr
+ # which will reset the specifed thread (default current)
+
+# SAMPLE PARASITE
+#
+# Nop-A # 1: Some nop to extend the template above
+# Toggle # 2: Toggle the Divide command...
+# Divide # 3: ... to become "Inject"
+# Toggle # 4: Toggle the If-Equal command...
+# If-Equal # 5: ... to become "If-NEqual"
+# Search # 6: Locate the end, so we know when to stop.
+# Nop-C # 7:
+# Nop-D # 8:
+# Head-Push # 9: Save the location of the flow head to mark the end.
+# Nop-D # 10:
+# Push-Prev # 11: Move end position to Stack-A
+# SetMemory # 12: Claim and empty memory space
+# Search # 13: Drop flow head at start of copy loop
+# Inst-Read # 14:
+# Inst-Write # 15:
+# Head-Push # 16: Get current position of...
+# Nop-C # 17: - Read-Head
+# If-Equal # 18: Test if we are done copying... (If-NEqual)
+# Head-Move # 19: ...If not, continue with loop.
+# Divide # 20: ...If so, Inject!
+# Nop-C # 21: ... Into the very end of the host.
+# Nop-C # 22
+# Head-Move # 23: Go to the beginning of the copy loop and start over!
+# Nop-A # 24: End Template
+# Nop-B # 25:
+
\ No newline at end of file
diff --git a/docs/documentation/Avida.cfg.mediawiki b/docs/documentation/Avida.cfg.mediawiki
new file mode 100644
index 0000000..cc566b2
--- /dev/null
+++ b/docs/documentation/Avida.cfg.mediawiki
@@ -0,0 +1,19 @@
+The Avida configuration file (avida.cfg) is the main configuration file for Avida. With this file, the user can setup all of the basic conditions for a run.
+
+avida.cfg is actually an excellent guide to itself; every option has a description of what it does and what its options are, and many of these pages will simply refer you to the file itself instead of replicating that description. We endeavor here to give extended explanations of particularly common or confusing options, and of settings that interact with other settings.
+
+
+== Configuration Sections ==
+* [[General Settings]]
+* [[Mutation Settings]]
+* [[Topology Settings]] : the shape and connectedness of the world
+* [[File Settings]] : other configuration files and where to save your data
+* [[Instruction Set]]
+* [[Reproduction Settings]] : birth and death
+* [[Time Slicing Settings]] : how CPU time is distributed among organisms
+* [[HTML Output Color Settings]]
+* [[Resource Hoarding Settings]] : internal resource storage for organisms
+* [[Divide Settings]] : limitations on organism division
+* [[Settings for Genealogy Info in the Test CPU]]
+* [[Mutations Reversion Settings]]
+* [[Analysis Settings]]: threads and variables in analyze mode
diff --git a/docs/documentation/Beginner-Documentation.md b/docs/documentation/Beginner-Documentation.md
new file mode 100644
index 0000000..03ff7ed
--- /dev/null
+++ b/docs/documentation/Beginner-Documentation.md
@@ -0,0 +1,211 @@
+# Avida: Beginner User Documentation
+
+As youβre beginning to use Avida to answer research questions, it can be easy to get lost in the extensive amount of variables and settings you can use in Avida. The purpose of this documentation is to identify the features that are most important for you to consider before running an experiment in Avida. For each feature, this documentation will explain what it controls, what options you have, and how and where you set those options.
+
+## **1. Set up the environment.**
+_Why you need to do this_
+
+Setting up the environment tells Avida how big your universe is and what shape you want your universe to take. This will be important in determining a) the population cap for your experiment, b) how much (if any) empty space exists in your world, and c) how proportionally (or not) the organisms in your experiment have access to other organisms and resources. What you choose in this portion of the experiment will affect how organisms in your Avida universe interact with each other and, indirectly, the carrying capacity of your Avida universe.
+
+_What you can do_
+
+Avida allows you to customize both the world size and the world geometry. The world size determines the carrying capacity of your Avida world. In Avida (which is based on a grid system), each grid block can be occupied by only one Avida organism. So if you set the Avida grid height to 120 and the Avida grid width to 120, your Avida universe would have a carrying capacity of 14,400.
+
+World geometry determines what shape your Avida grid will take. By default, the Avida universe is set to taking a toroidal (doughnut) shape. The creators of Avida chose this so that there are no edges in the universe and so that each organism has equal access to resources and neighbors. If, however, having boundaries and edges in your universe is important, you can change the shape of the Avida world to a bounded grid, hexagonal, random connected, and more. Details for what options exist for this setting and what they mean can be found in the avida.cfg file.
+
+_Where to do it_
+
+Both world size and world geometry are set in the avida.cfg file. World size is controlled by the WORLD_X and WORLD_Y controls; world geometry is controlled by the WORLD_GEOMETRY control. Similar to most grid systems, the width is controlled by the WORLD_X control and the height is controlled by the WORLD_Y control.
+
+_How to do it_
+
+To make changes to the default settings for world size and world geometry, 1) find the variables mentioned above in the avida.cfg file, 2) highlight and replace the current values with the ones you selected, and 3) save the file with your new changes.
+
+## 2. Stock the environment with organisms.
+
+_Why you need to do this_
+
+An experiment canβt run without any organisms to evolve. If you donβt load an organism into the Avida config file, it would be like conducting a culture experimentβ without any organisms in the petri dish.
+
+_What you can do_
+
+Avida comes with a number of different organisms you can use to populate your Avida world. Most experiments will use the basic Avida organism (defaultΒheads.org). This organism is haploid and asexual. For your first Avida experiments, it is highly recommended that you use the basic Avida organism. Only if your experiment explicitly calls for a different organism should you consider using a different Avida organism.
+
+_Where to do it_
+
+Organisms are stocked (or βinjectedβ) into Avida in the events.cfg file. The command that controls what organisms are injected is the βInjectβ function located here.
+
+
+
+_How to Do it_
+
+By default, Avida will inject the basic Avida organism (defaultΒheads.org). Unless you are changing this to a different organism, feel free to leave the file asΒis.
+
+## 3. Decide how organisms will be born and how organisms will die.
+
+_Why you need to do it_
+
+The functions described in this setting give you control over how organisms enter and leave your Avida universe. Birth method determines where on the Avida grid new organisms are placed. Having control over this function allows you to mimic biological communities (if thatβs important to your experiment) or to decide how organisms are dispersed across the Avida universe.
+
+Death method allows you to determine whether organisms in your world can die from old age or not. This distinction may be crucial for experiments that investigate longevity issues. Population cap controls determine how many organisms are allowed to exist in your Avida universe and, if the population cap is reached, the population cap eldest control will determine if a) the oldest organism in the universe dies or b) a random organism from the universe dies.
+
+_What you can do_
+
+When it comes to placing new organisms in your Avida world, the birth method feature in Avida gives you a few options for where those organisms are placed. By default, new organisms are placed randomly onto the Avida grid. You can change this option, however, via the eleven birth method options found in the avida.cfg file next to the BIRTH_METHOD control. Some options include having new organisms facing the parent organism, replacing the oldest age in the neighborhood, or replacing the oldest within the entire population.
+
+The death method setting allows you to decide if an organism in your Avida world can die of old age or not. Avida has one setting for turning off this functionβ meaning that an organism will never die of old age. Avida has another setting for turning this function on, meaning that organisms who complete a certain number of instructions (i.e., AGE_LIMIT) will die.
+
+The population cap controls allow you to set a limit on how many organisms can exist in your Avida universe. While this is also partially controlled by the world size (see explanation in Step 1), the population cap can allow you to set an even smaller population maximum in your Avida world if having space and empty squares on the Avida grid is important to you. For example, letβs say I set my Avida world size to be 60 units high and 60 units wide. This would mean that I have set a de facto population cap of 3,600 (60 X 60) because Avida will only allow one organism to occupy a grid cell.
+
+But this also means that, unless other factors (such as competition or a population cap) come into play, the population will continue growing until it fills each of the 3,600 cells. IF, however, I wanted there to be some extra space protected in the Avida worldβ if my experiment called for there to be extra room between organisms β I could set a population cap of 3,000 organisms. This means that, no matter how large my world is, there will only ever be a maximum 3,000 organisms in the Avida universe. Setting a population cap allows you to protect empty space and/or to keep a more precise control over your maximum potential population size.
+
+Similarly, Avida allows you some flexibility over what happens to your Avida organisms when the population cap is reached. You can choose to a) kill off the oldest organism in the population or b) kill off a random member of the population. This choice is more or less critical depending on your research question(s), but should be thought over carefully when setting up your Avida experiment.
+
+_Where you do it_
+
+The birth method and death method settings are found in the reproduction section of the avida.cfg file. Birth method is controlled by the BIRTH_METHOD variable and the death method is controlled by the DEATH_METHOD variable. Controls for the population cap settings, including POPULATION_CAP and POP_CAP_ELDEST, are located in the βgeneral groupβ section of the avida.cfg file.
+
+_How you do it_
+
+To change Avidaβs birth method (i.e., where new organisms are placed in the Avida grid), choose the option you would prefer from the avida.cfg documentation (located next to the BIRTH_METHOD control). Highlight and replace the preΒselected option (in this case, number 7) with the option you would prefer for your experiment. Be sure to save the file with your changes.
+
+To change the death method, locate the DEATH_METHOD variable in the avida.cfg file. By default, Avida is set to death method setting 2, which has a deathΒbyΒoldΒage feature. If you wish to turn this off, highlight and replace the 2 with a 0 (0 is the setting for no death by old age). If you wish to have organisms die from old age, keep the file the same.
+
+To set a population cap, find the POPULATION_CAP control in the avida.cfg file, highlight the 0 (Avida defaults to 0/no population cap), and replace it with your population cap number (from our example above, this would be 3000). Do not use commas when writing in your population cap number in Avida. Once youβve made your changes, save the avida.cfg file.
+
+The POP_CAP_ELDEST control works by entering in either a 0 (default) or 1 after the control name in the avida.cfg file. Select 0 for a random organism or 1 for the oldest organism to die if the population reaches the carrying capacity (i.e., population cap) you set for the population in the previous step.
+
+## 4. Stock the environment with resources.
+
+_Why you need to do this_
+
+Just like in biological systems, Avida works by using competition for resources as a motivation for organisms to evolve characteristics that help them secure more resources and, thus, make them more likely to reproduce. In Avida, you have some control over how many resources are available to organisms in your experiment as well as how evenly (or not) those resources are distributed across the Avida grid.
+
+_What you can do_
+
+By default, resources in Avida are infinite and undepletable. This means that there is never a shortage of a resource and that organisms are competing to acquire the most resources out of the infinite resource pool. They are not competing against each other for a limited number of resources. Furthermore, resources are, by default, dispersed evenly within the Avida environment. This means that there is no clustering of resources in a particular area. Organisms placed anywhere on the Avida grid will have equal access to resources.
+
+While most experiments work well with the default settings, you can change both the amount of resources available (i.e., create a depletable resource) or the dispersal pattern of the resources (i.e., create high and low resource concentration areas) to better answer your research questions.
+
+_Where you do this_
+
+Any changes to the default settings of infinite and evenly dispersed resources are made in the environment.cfg file.
+How you do this
+Since most experiments donβt require changes to the default settings, changing the dispersal pattern and/or limiting the availability of resources requires more complex instructions. Those instructions, along with more description about what options are available to you, are located on the Avida documentation wiki [here](https://github.com/devosoft/avida/wiki/Environment-file).
+
+## 5. Decide what task(s) organisms will use to compete for resources and how they will/will not be rewarded for those tasks.
+
+_Why you need to do this_
+
+In Avida, organisms complete logic functions to increase their merit. The more merit an organism in Avida has, the more CPU cycles it will receive. This means that the organism can reproduce faster and, eventually, become a more fit organism. As a researcher, you get to make choices about what logic tasks organisms in your Avida world will be asked to complete and how they will/will not be rewarded for completing these tasks. This will impact what types of behavior(s) you see evolving during your experiment.
+
+_What you can do_
+
+It is important that you decide 1) what kinds of logic tasks organisms in your experiment(s) will be asked to complete, 2) how organisms in your experiment will be rewarded for completing those various tasks, and 3) how an organismβs merit gets added to its pre-Βexisting merit when it successfully completes a logic task.
+
+### Kinds of logic tasks
+
+By default, Avida will ask the organisms in your experiment to complete a series of nine logic tasks. This is often referred to in the Avida literature as the βdefault logicΒ9 environment.β These nine logic tasks are listed in the environment.cfg file and move from relatively simple functions to more complex functions. For most experiments, the default logicΒ9 environment provides a sufficiently complex environment. You can make the environment more complex, however, by adding additional logic tasks. There is a logicΒ77 environment that adds such complexity but, again, most experiments work successfully with the default logicΒ9 environment.
+
+Conversely, if youβre not really interested in looking at tasks or looking at evolved behavior, you can remove some logic tasks or remove the logic tasks all together. This can make your data easier to analyze and will prevent you from having to factor in evolvability later on in your experiment.
+
+### How organisms are rewarded
+Avida allows you to control how organisms are rewarded for completing logic tasks. For every different logic task you ask your organisms to complete, you get to decide a point value reward for completing that task. By default, simple logic tasks receive less reward points than the more complex logic tasks. This is to ensure that organisms have sufficient motivation to attempt to complete the more complicated logic tasks. You can choose, however, to undo this default setting and reward all tasks the same. If you were interested in how a particular behavior evolves you could arbitrarily set the reward value for a certain function significantly higher and see how that impacts evolution. Because the options here are endless, itβs important to keep your research question(s) in mind when deciding how rewards are distributed in Avida.
+
+### How an organismβs merit is accumulated
+
+Every time an organism in Avida completes a logic task, it receives increased merit. You have to decide how that newly earned merit will be combined with the organismβs previously accumulated merit. By default, an organismβs merit increases exponentially. This encourages organisms to spend time solving more complicated logic tasks (even though they take more time) because the reward for completing those tasks is exponentially higher than the reward they would receive from completing simpler logic tasks. This also prevents an organism that completes many simple logic tasks from acquiring more merit than an organism who completes a few difficult logic tasks.
+
+While most experiments find the default settings to be a conducive way of encouraging the evolution of more complicated behavior, there are other settings that may be more appropriate for your particular research goals. More information about what other options are available and how they can be used in your experiment is located on the Avida documentation wiki [here](https://github.com/devosoft/avida/wiki/Environment-file).
+
+_Where you can do it_
+
+All of the settings for logic tasks and task reward are located in the environment.cfg file. When you open the file, you will see the nine default logic tests laid out as in the following example:
+
+`REACTION NOT not process:value=1.0:type=pow requisite:max_count=1`
+
+Each line that starts with REACTION marks a different logic task. The variables listed after REACTION in each line determine the reward value, type, and restrictions for that logic task. Hereβs an example of how to read these variables.
+
+In the examples above βNOTβ would be the name of the logic task and βnotβ would be the type of logic task (often, these are the same). So this tells you that this logic function is named βNOTβ and will ask the organisms in your experiment to solve a logic problem that requires them to complete a βnotβ logic task. (In Avida, this would be an organism correctly knowing to convert the sequence 001101 to 110010).
+
+The βprocess:value=1.0:type=powβ is the part of the REACTION line that determines how much merit an organism receives for completing that task and how that merit gets added to the organismβs preΒexisting merit. The βvalue=1.0β part of the code assigns how much reward value (i.e., increased merit) an organism would receive from successfully completing that task. In this case, an organism gets 1.0 merit points for completing the task. The βtype=powβ part of the code determines how newly earned merit from completing this task will be combined with the organismβs preΒexisting merit. In this example, an organisms merit is increased exponentially (the βpowβ stands for power). This would mean that an organism would receive a 2^bonus or 2^1 for completing this task.
+
+The final part of this REACTION lineβ βrequisite:max_count=1β β sets a limit for how many times an organism can receive increased merit from completing this task. By default, this is set to 1, meaning that an organism would only receive increased merit the first time it completed that logic task. After that, the organism would not receive increased merit from repeating the same function. While this default setting encourages organisms to attempt increasingly complex behaviors, it may not work for all experiments and can be replaced with any value you choose. If your experiment requires that there is no merit cap on a particular logic function, you can delete the max_count=1 function completely so that the new code would read:
+
+`REACTION NOT not process:value=1.0:type=pow`
+
+_How you do it_
+
+As weβve seen in other portions of the Avida program, you make changes to these settings by highlighting the default value you wish to change and replacing it with your new value. For example, if I wanted to change how much merit an organism received from completing the NOT function in my experiment, I would highlight the source code where it says β1.0β and replace it with a higher value, such as β2.0β so that the final code would read like this (*'s to show changes):
+
+`REACTION NOT not process:value=**2.0**:type=pow requisite:max_count=1`
+
+If I also wanted to have the merit an organism receives from completing the NOT function to be
+added to their previous merit (as opposed to being increased exponentially), I would highlight 7
+where it says βpowβ in the documentation and replace it with βadd.β Again, the new REACTION line would read like this:
+
+`REACTION NOT not process:value=2.0:type=**add** requisite:max_count=1`
+
+If your experiment calls for less logic functions, you can delete a logic task by highlighting and
+deleting the undesired logic task. Be sure to delete the _entire_ line, not just part of the command.
+
+It is also important that you not change either the task name (i.e., NOT) or task type (i.e., not) in the environment.cfg file. This will cause an error with your experiment. When you are done editing this file remember to save your changes.
+
+## 6. Decide how long your experiment will last.
+
+_Why you need to do this_
+
+By default, Avida will run an experiment for 100,000 updates, where 10 updates are roughly equal to 1 generation. Depending on what type of experiment youβre doing, you may want to lengthen or shorten the default experiment runΒtime. Setting the experiment update time is like deciding how long you want a certain bacteria to culture and/or how many generations of fruit flies youβre going to analyze. Shorter experiment times in Avida will take less time and will be much less data to analyze and store; however, longer experiments will allow you to see more longΒterm
+evolutionary patterns and population dynamics.
+
+_Where to do this_
+
+The variable that controls the experiment length is located in the event.cfg file and is labeled βEXITβ (will be located near the bottom of the file).
+
+
+
+_How to do this_
+
+You can change the experiment update length by selecting the number 100000 and replacing it by typing in any positive whole number you select. Be sure to save the file before closing to update your changes.
+
+## 7. Decide what types of data you will collect from your experiment.
+
+_Why you need to do this_
+
+Avida can collect and print a number of different types of data reports on any experiment. Depending on what your experiment is investigating, different types of data reports may or may not be as useful to you in answering your research question(s). Some of these data files are complex, take a long time to print, and use up a lot of computing/memory power on your device. Therefore, you can save yourself a lot of time and technological resources by intentionally selecting only the files you need Avida to print from your experiment.
+
+In addition to selecting what files to print, it is also important to select the frequency at which Avida prints your data files. By default, Avida prints a complete set of data files after every 100 updates for the entire duration of your experiment. Depending on how long your experiment lasts and/or if youβre looking at shortΒterm or longΒterm evolutionary patterns, this default print frequency might not make sense for your research.
+
+_What you can do_
+
+The types of data files Avida can print are split into two groups: standard data files and nonΒstandard data files. The standard data files are printed by default in Avida and will save basic data about what is happening in your experiment (more information about what is collected in each of the standard data files is located in the events.cfg file).
+
+The nonΒstandard data files keep track of more nuanced and specific data. These files are not printed by default in Avida. Because these files often require that Avida make more calculations, these files take up more computational/memory space on your device. Therefore, it is recommended that you only print the nonΒstandard data files that are essential to your experiment. Most experiments, especially at the beginner level, do not require any additional data files from the nonΒstandard data files group.
+
+Avida also gives you a lot of control over when and how often the program prints data files. In particular, you can control three factors: 1) when Avida starts printing data files, 2) how many update cycles between data file printing, and 3) when Avida stops printing data files.
+
+You can choose any update cycle to begin and end data collection, and can print data files as frequently (i.e., every 10 updates) or infrequently (i.e., every 10,000 updates) as needed.
+
+_Where you can do this_
+
+All settings to control data file printing are found in the events.cfg file. The standard data files are grouped together towards the beginning of the document and the nonΒstandard data files are group together towards the end of the document. The print timing and frequency controls are located next to each data file in this document.
+
+_How you can do this_
+
+Each data file is listed in the events.cfg file like this:
+
+ `u 0:100:end PrintAverageData`
+
+To turn a data file on (i.e., print the file) remove the # from before the file name. Notice that the files in the standard file group donβt have a # at the beginning of the file name; thatβs because they are printed (turned on) by default. If you choose to not print a certain data file, add a # to the beginning of the file name that you wish to turn off. For example, if you didnβt want to print the PrintAverageData file, you would insert an # before the u (i.e., `# u 0:100:end PrintAverageData`). The nonΒstandard data files do have a # before their file name (i.e., `# u 100:100:end PrintTotalsData`). This means that, unless you remove the #, that file will not print.
+
+When Avida starts printing data, how often Avida prints a data file, and when Avida ends printing data are controlled by the three variables within colons. Taking our example from above,
+
+`u 0:100:end PrintAverageData`
+
+the β0β would be when Avida starts printing this data file (i.e., at the 0th update), the β100β would be the frequency at which Avida prints this data file (i.e., every 100 updates), and the βendβ would be when Avida stops printing this data file (i.e., when the experiment ends). ReΒwriting this example to the following,
+
+`u: 100:1000:10000 PrintAverageData`
+
+would tell Avida to a) start printing this file at the 100th update, b) print this data file every 1,000 updates, and c) stop printing this file at 10,000 updates (even if the experiment is still running).
+
+This documentation was produced by Rebecca Zantjer with consultation from members of the Devolab.
\ No newline at end of file
diff --git a/docs/documentation/Configuration-and-command-reference.md b/docs/documentation/Configuration-and-command-reference.md
new file mode 100644
index 0000000..36c7a5a
--- /dev/null
+++ b/docs/documentation/Configuration-and-command-reference.md
@@ -0,0 +1,25 @@
+## Main Configuration Files
+* [[Avida.cfg|Avida.cfg]]
+* [Events File](https://github.com/devosoft/avida/wiki/Events-file)
+* [Environment File](https://github.com/devosoft/avida/wiki/Environment-file)
+* [Instruction Set](https://github.com/devosoft/avida/wiki/Instruction-Set)
+* [[instset-heads.cfg]]
+* [[default-heads.org]]
+* [Analyze File](https://github.com/devosoft/avida/wiki/Analyze-File)
+
+## Analyze Mode
+* [[Analyze File]]
+* [[Sample Analyze Programs]]
+
+## Subpopulations (Demes)
+* [[Deme introduction]]
+* [[Deme migration]]
+
+## Misc. Configuration
+* [[Quirks]]
+* [[Setting up Fixed-Length Organisms]]
+* [[Introduction to Parasites]]
+* [[Gradient Resources]]
+* [[Internal resources]]
+* [[Using mating types (separate sexes)]]
+* [[Energy model configuration]]
diff --git a/docs/documentation/Creating-a-flame-graph.mediawiki b/docs/documentation/Creating-a-flame-graph.mediawiki
new file mode 100644
index 0000000..d2f03ed
--- /dev/null
+++ b/docs/documentation/Creating-a-flame-graph.mediawiki
@@ -0,0 +1,59 @@
+A flame graph is a visual representation of genetic diversity and "speciation" through an Avida run, graphing genetic distance over time. It is related to a phylogeny, but it is not a phylogeny and should not be mistaken for (or used as!) one.
+
+1. Generating the Data
+
+First you must obtain the necessary data -- you need population detail files (historic files are not necessary) files. The default events.cfg generates these only every 50,000 updates, so you must change this to get finer timeslices. More timeslices yield a smoother graph, but also increase the storage space necessary for your run. I generally use time slices of 100 or 50 updates, because storage is cheap and I like smooth graphs.
+
+Once you have your population files, there are two ways to create a flamegraph. Choose according to your preferred tools:
+
+== Producing a Flame Graph with flamegraph.py ==
+
+flamegraph.py is a Python script found in avida-core/source/utils/hist_map/ which uses matplotlib to produce the flamegraph. (It requires both Python and [http://matplotlib.sourceforge.net/ matplotlib] to work). It will handle both unzipped (.spop) and gzipped(.spop.gz) files.
+
+To run it:
+
+python flamegraph.py
+
+matplotlib can produce graphs in png, pdf, ps, eps, or svg format; choose the extension of your output file appropriately.
+
+In the current default Avida, the population detail files (.spop) use column 14 for phylogenetic depth and column 5 for number of organisms. (Older Avida population detail files with the .pop extension use columns 12 and 4, respectively.) Additionally, you will want to ensure that flamegraph.py reads the detail files the correct order, and that you include any files still gzipped. Altogether, your command should look something like this:
+
+python flamegraph.py flame.pdf 14 5 detail-?00.spop* detail-??00.spop* detail-???00.spop* detail-????00.spop*
+
+
+When it has run, you may wish to check the reported number of rows -- it should be the number of detail files provided.
+
+(If you wish to immediately see the graph produced, you can add the -g flag. The -q flag will stop all those "Processing..." messages from appearing.)
+
+== Producing a Flame Graph with hist_map and Matlab ==
+
+This is the "classic" method.
+
+1. hist_map
+
+If you have not already compiled hist_map, do so. It is located in source/utils/hist_map/, and you can simply use the Makefile. (Type "make" on the command line while in this directory.)
+
+Now run it:
+
+hist_map
+
+In the current default Avida, the population detail files (.spop) use column 14 for phylogenetic depth and column 5 for number of organisms. (Older Avida population detail files with the .pop extension use columns 12 and 4, respectively.) Additionally, you will want to ensure that hist_map reads the detail files the correct order. Altogether, your command should look something like this:
+
+hist_map 12 4 detail-?00.spop detail-??00.spop detail-???00.spop detail-????00.spop
+When it has run, you may wish to check the reported number of rows -- it should be the number of detail files provided.
+
+2. Matlab
+
+Load the file created by hist_map into matlab, using zl or your favorite matrix-loading tool. E.g.:
+
+flame_matrix = zl('
+What you will actually graph is the transpose of the log of this matrix + 1:
+
+flame_graphable = (log(flame_matrix + 1))';
+Finally, pcolor it -- for flame-colored flame graphs, use the hot colormap:
+
+colormap('hot')
+flame_graph = pcolor(flame_graphable)
+If at this point your flame graph is pure black, try the command
+
+shading flat
diff --git a/docs/documentation/Default-Ancestor-Guided-Tour.md b/docs/documentation/Default-Ancestor-Guided-Tour.md
new file mode 100644
index 0000000..55d2ac9
--- /dev/null
+++ b/docs/documentation/Default-Ancestor-Guided-Tour.md
@@ -0,0 +1,228 @@
+This document describes the structure of the classic virtual CPU and an example organism running on it.
+
+## The Virtual CPU Structure
+
+The virtual CPU, which is the default "body" or "hardware" of the organisms, contains the following set of components, (as further illustrated in the figure below).
+
+* A memory that consists of a sequence of instructions, each associated with a set of flags to denote if the instruction has been executed, copied, mutated, etc. Memory is treated as circular, such that execution will loop back to the first instruction after the last instruction has been executed
+* An instruction pointer (IP) that indicates the next site in the memory to be executed.
+* Three registers that can be used by the organism to hold data currently being manipulated. These are often operated upon by the various instructions, and can contain arbitrary 32-bit integers.
+* Two stacks that are used for storage. The organism can theoretically store an arbitrary amount of data in the stacks, but for practical purposes we currently limit the maximum stack depth to ten.
+* An input buffer and an output buffer that the organism uses to receive information, and return the processed results.
+* A Read-Head, a Write-Head, and a Flow-Head which are used to specify positions in the CPU's memory. A copy command reads from the Read-Head and writes to the Write-Head. Jump-type statements move the IP to the Flow-Head.
+
+
+
+
+## Instruction Set Configuration
+
+The instruction set in Avida is loaded on startup from a configuration file specified in the avida.cfg file. This allows selection of different instruction sets without recompiling the source code, as well as allowing different sized instruction sets to be specified. It is not possible to alter the behavior of individual instructions or add new instructions without recompiling Avida; such activities have to be done directly in the source code.
+
+The available instructions are listed in the inst_set.* files with a 1 or a 0 next to an instruction to indicate if it should or should not be included. Changing the instruction set to be used simply involves adjusting these flags.
+
+The instructions were created with three things in mind:
+
+* To be as complete as possible (both in a "Turing complete" sense -- that is, it can compute any computable function -- and, more practically, to ensure that simple operations only require a few instructions).
+* For each instruction to be as robust and versatile as possible; all instructions should take an "appropriate" action in any situation where they can be executed.
+* To have as little redundancy as possible between instructions. (Several instructions have been implemented that are redundant, but such combinations will typically not be turned on simultaneously for a run.)
+
+One major concept that differentiates this virtual assembly language from its real-world counterparts is in the additional uses of nop instructions (no-operation commands). These have no direct effect on the virtual CPU when executed, but often modify the effect of any instruction that precedes them. In a sense, you can think of them as purely regulatory genes. The default instruction set has three such nop instructions: nop-A, nop-B, and nop-C.
+
+The remaining instructions can be seperated into three classes. The first class is those few instructions that are unaffected by nops. Most of these are the "biological" instructions involved directly in the replication process. The second class of instructions is those for which a nop changes the head or register affected by the previous command. For example, an inc command followed by the instruction nop-A would cause the contents of the AX register to be incremented, while an inc command followed by a nop-B would increment BX.
+
+The notation we use in instruction definitions to describe that a default component (that is, a register or head) can be replaced due to a nop command is by surrounding the component name with ?'s. The component listed is the default one to be used, but if a nop follows the command, the component it represents in this context will replace this default. If the component between the question marks is a register than a subsequent nop-A represents the AX register, nop-B is BX, and nop-C is CX. If the component listed is a head (including the instruction pointer) then a
+nop-A represents the Instruction Pointer, nop-B represents the Read-Head, and nop-C is the Write-Head. Currently the Flow-Head has no nop associated with it.
+
+The third class of instructions are those that use a series of nop instructions as a template (label) for a command that needs to reference another position in the code, such as h-search. If nop-A follows a search command, it scans for the first complementary template (nop-B) and moves the Flow-Head
+there. Templates may be composed of more than a single nop instruction. A series of nops is typically abbreviated to the associated letter and separated by colons. This the sequence "nop-A nop-A nop-C" would be displayed as "A:A:C".
+
+The label system used in Avida allows for an arbitrary number of nops. By default, we have three: nop-A's complement is nop-B, nop-B's is nop-C, and nop-C's is nop-A. Likewise, some instructions talk about the complement of a register or head -- the same pattern is used in those cases. So if an instruction tests if ?BX? is equal to its complement, it will test if
+BX == CX by default, but if it is followed by a nop-C it will test if CX == AX.
+
+
+## Instruction Set Reference
+
+An abbreviated description of the 26 default instructions is below.
+
+
+
+
+
+### An Example Ancestor
+
+The following organism is stored in the file organism.heads.15, which you should find in the support/config/misc/ directory. This is a simplified version of organism.default and
+organism.heads.100, of lengths 50 and 100 respectively (each has additional instructions placed before the copy loop)
+
+
+
+(a-c) nop-A, nop-B,
and nop-C
+ No-operation instructions; these modify other instructions.
+
+(d) if-n-equ
+ Execute next instruction only-if ?BX? does not equal its complement
+
+(e) if-less
+ Execute next instruction only if ?BX? is less than its complement
+
+(f) if-label
+ Execute the next instruction only if the given template complement was just copied
+
+(g) mov-head
+ Move the ?IP? to the same position as the Flow-Head
+
+(h) jmp-head
+ Move the ?IP? by a fixed amount found in CX
+
+(i) get-head
+ Write the position of the ?IP? into CX
+
+(j) set-flow
+ Move the Flow-Head to the memory position specified by ?CX?
+
+(k) shift-r
+ Shift all the bits in ?BX? one to the right
+
+(l) shift-l
+ Shift all the bits in ?BX? one to the left
+
+(m) inc
+ Increment ?BX?
+
+(n) dec
+ Decrement ?BX?
+
+(o) push
+ Copy the value of ?BX? onto the top of the current stack
+
+(p) pop
+ Remove a number from the current stack and place it in ?BX?
+
+(q) swap-stk
+ Toggle the active stack
+
+(r) swap
+ Swap the contents of ?BX? with its complement.
+
+(s) add
+ Calculate the sum of BX and CX; put the result in ?BX?
+
+(t) sub
+ Calculate the BX minus CX; put the result in ?BX?
+
+(u) nand
+ Perform a bitwise NAND on BX and CX; put the result in ?BX?
+
+(v) h-copy
+ Copy an instruction from the Read-Head to the Write-Head and advance both.
+
+(w) h-alloc
+ Allocate memory for an offspring
+
+(x) h-divide
+ Divide off an offspring located between the Read-Head and Write-Head.
+
+(y) IO
+ Output the value ?BX? and replace it with a new input
+
+
+(z) h-search
+ Find a complement template and place the Flow-Head after it.
+
+
+This program begins by allocating extra space for its offspring. The exact amount of space does not need to be specified -- it will allocate as much as it is allowed to. The organism will then do a search for the end
+of its genome (where this new space was just placed) so that it will know where to start copying. First the Flow-Head is placed there, and then the Write-Head is moved to the same point.
+
+It is after this initial setup and before the actual copying process commences that extra # --- Setup ---
+h-alloc # Allocate extra space at the end of the genome to copy the offspring into.
+h-search # Locate an
+ A:B template (at the end of the organism) and
+ place the Flow-Head after it
+nop-C #
+nop-A #
+mov-head # Place the
+ Write-Head at the Flow-Head (which is at beginning of
+ offspring-to-be).
+nop-C # [ Extra
+ nop-C commands can be placed here w/o harming the
+ organism! ]
+
+ # --- Copy Loop ---
+h-search # No template,
+ so place the Flow-Head on the next line code
+h-copy # Copy a single
+ instruction from the read head to the write head (and advance both
+ heads!)
+if-label # Execute the
+ line following this template only if we have just copied an
+ A:B template.
+nop-C #
+nop-A #
+h-divide # ...Divide off offspring! (note if-statement above!)
+mov-head # Otherwise,
+ move the IP back to the Flow-Head at the beginning of the copy
+ loop.
+nop-A # End label.
+nop-B # End label.
+nop instructions can be included. The only caveat is that you need to make sure that you don't duplicate any templates
+that the program will be searching for, or else it will no longer function properly. The easiest thing to do is insert a long sequence of nop-C instructions.
+
+Next we have the beginning of the "copy loop". This segment of code starts off with an h-search command with no template following it. In such as case, the Flow-Head is placed on the line immediately following the search. This head will be used to designate the place that the IP keeps returning to with each cycle of the loop.
+
+The h-copy command will copy a single instruction from the Read-Head (still at the very start of the genome, where it begins) to the Write-Head (which we placed at the beginning of the offspring). With any copy command there is a user-specified chance of a copy mutation. If one occurs, the Write-Head will place a random instruction rather than the one that it gathered from the Read-Head. After the copy occurs (for better or worse),
+both the Read-Head and the Write-Head are advanced to the next instruction in the genome. It is for this reason that a common mutation we see happening will place a long string of h-copy instruction one after another.
+
+The next command, if-label (followed by a nop-C and a nop-A) tests to see if the complement of C:A is the most thing copied. That is, if the two most recent instructions copied were a nop-A followed by a nop-B as is found at the end of the organism. If so, we are done! Execute the next instruction which is h-divide (when this occurs, the read and write heads will surround the portion of memory to be split off as the offspring's genome). If not, then we need to keep going. Skip the next instruction and move on to the mov-head which will move the head specified by the nop that follows (in this case nop-A which is the Instruction Pointer) to the Flow-Head at the beginning of the copy loop.
+
+This process will continue until all of the lines of code have been copied, and an offspring is born.
+
+
+### An Example Logic Gene
+
+Here is a short example program to demonstrate one way for an organism to perform the "OR" logic operation. This time I'm only going to show the contents of the registers after each command because the functionality of the individual instructions should be clear, and the logic itself won't be helped much by a line-by-line explanation in English.
+
+
+
diff --git a/docs/documentation/Default-heads.org.md b/docs/documentation/Default-heads.org.md
new file mode 100644
index 0000000..7e6169b
--- /dev/null
+++ b/docs/documentation/Default-heads.org.md
@@ -0,0 +1 @@
+The default ancestor organism when using the Heads virtual CPU.
\ No newline at end of file
diff --git a/docs/documentation/Deme-introduction.mediawiki b/docs/documentation/Deme-introduction.mediawiki
new file mode 100644
index 0000000..ca10abc
--- /dev/null
+++ b/docs/documentation/Deme-introduction.mediawiki
@@ -0,0 +1,15 @@
+Line #
+ Instruction
+ AX
+ BX
+ CX
+ Stack
+ Output
+ 1 IO
+ ? X ?
+ ? ?
+ 2 push
+ ? X ?
+ X, ?
+ 3 pop
+ ? X X
+ ?
+ 4 nop-C
+ 5 nand
+ ~X X X
+ ?
+ 6 nop-A
+ 7 IO
+ ~X Y X
+ ? X
+ 8 push
+ ~X Y X
+ Y, ?
+ 9 pop
+ ~X Y Y
+ ?
+ 10 nop-C
+ 11 nand
+ ~X ~Y Y
+ ?
+ 12 swap
+ Y ~Y ~X
+ ?
+ 13 nop-C
+ 14 nand
+ Y X or Y ~X
+ ?
+ 15 IO
+ Y Z ~X
+ ? X or Y
+
+
+
+[[How to create a deme replication event]]
diff --git a/docs/documentation/Deme-migration.mediawiki b/docs/documentation/Deme-migration.mediawiki
new file mode 100644
index 0000000..632b386
--- /dev/null
+++ b/docs/documentation/Deme-migration.mediawiki
@@ -0,0 +1,25 @@
+
Β
# All text beyond the '#' character in a file is a comment and will not be read in by Avida
# Subpop: Β Β Β Β [0] Β Β Β [1]Β Β Β Β [2] Β Β [3]
Β Β Β Β Β Β Β Β Β Β Β Β 5.0, Β 0.10, Β 0.0, Β 4.0 Β Β # [0] Β Β Β Row[0].Sum = 9.10
Β Β Β Β Β Β Β Β Β Β Β Β 3.0, Β 0.20, Β 0.8, Β 2.0 Β Β # [1] Β Β Β Row[1].Sum = 6.00
Β Β Β Β Β Β Β Β Β Β Β Β 7.0, Β 0.30, Β 0.0, Β 1.0 Β Β # [2] Β Β Β Row[2].Sum = 8.30
Β Β Β Β Β Β Β Β Β Β Β Β 2.0, Β 1.30, Β 9.0, Β 0.0 Β Β # [3]Β Β Β Β Rom[3].Sum = 12.30
# END
What this file means: The above un-commented text shows a simple 4-line file with each line containing 4 comma-separated values. Each row in the connection matrix contains all the connection weights *from* subpopulation[row] to other subpopulations that are indexed by column. For example, the connection weight between Subpopulation[1] and Subpopulation[2] is 0.8 where the from-subpopulation is row index 1 and to-subpopulation is column index 2. By setting each of these weights, you can specify what the appropriate migration probability will be from a given subpopulation to another subpopulation. Internally, when a migration event is going to occur from a given subpopulation (let's assume Subpopulation[1]), Avida will sum up the values in row 1 of the connectivity matrix (3.0 + 0.20 + 0.8 + 2.0 = 6.00) and generate a random number between: 0 and Row[1].Sum. This random number will be used to determine which subpopulation the organism will migrate into using a "roulette selection" protocol where each connection is represented by its weight's proportion of the sum. Β As you may have noticed, the sum of a row does not have to equal 1.0 as a typical probability matrix does. The probability matrix would be an exclusive subset of the type of connectivity matrices you can use under this setup.Β
Restrictions for this file (and why):
+
+
+
+1. Build the method to be attached to the new instruction
+
+minus-17 (which performs the oh-so-useful behavior
+of subtracting 17 from the ?BX? register), you would add the line:
+
+bool Inst_Minus17(cAvidaContext& ctx);
+
+
+Inst_ in front of it.
+
+bool cHardwareCPU::Inst_Minus17(cAvidaContext& ctx)
+{
+ const int reg_used = FindModifiedRegister(REG_BX);
+ GetRegister(reg_used) -= 17;
+ return true;
+}
+
+
+nop), with a default value of REG_BX passed in.
+The second line then subtracts 17 from the value in that register. The
+constant values and available helper functions will be described in more
+detail below, as will a guide to accessing the components in the virtual
+CPU. For the moment, you have finished implementing the method!
+2. Link the instruction name to its method
+
+For this step, you will need to edit the code file. You would go into the method
+cHardwareCPU::initInstLib(void)
+and add in the line
+
+
+cInstEntryCPU("minus-17", &cHardwareCPU::Inst_Minus17);
+
+
+3. Add the entry to your instruction set and test it!
+
+
+minus-17 1
+
+
+nop-C instructions inside of it to perform some math using the
+new instruction (only the very first nop-C cannot be changed). You
+can then either go into zoom mode in the viewer and step through the creature,
+or else use analyze mode trace its execution. If you are going to use zoom
+mode, setup your modified creature as the START_CREATURE in configuration file.
+If you want to use analyze mode, put the following lines into the
+analyze.cfg file in your work/ directory:
+
+
+ LOAD_ORGANISM inst_test.org
+ TRACE
+
+
+CPU Components
+
+
+
+
+
+void StackPush(int value);
+int StackPop();
+void SwitchStack();
+
+
+cCPUHead& GetHead(int head_id);
+cCPUHead& IP();
+HEAD_IP, HEAD_READ,
+HEAD_WRITE, and HEAD_FLOW. These heads each point
+to a position in memory, and all have their own purpose. A head can be
+accessed by passing the appropriate constant into the GetHead() method. The
+extra method IP() was added to more easily obtain just the instruction pointer.
+The IP is a very special head since it designates what instruction is going to
+be executed next, and often it will make code clearer if you obtain it by
+calling IP(). (It will show that you need to make sure of the special
+qualities of the instruction pointer.)
+
+int& Register(int reg_id);
+
+REG_AX, REG_BX, and REG_CX. If the
+Register() method is called, an integer reference will be returned associated
+with that register. Any change to this integer will make a corresponding
+change to the register in question.
+
+cCPUMemory& GetMemory();
+
+Helper Methods
+
+
+
+
+
+
+void ReadLabel();
+cCodeLabel& GetLabel();
+cCPUHead FindLabel(int direction);
+
+
+int FindModifiedRegister(int default_register);
+int FindModifiedHead(int default_head);
+
+
+int FindComplementRegister(int base_reg);
+
+Problem
+
+cube that will take the ?BX? register, and put
+its value to the third power. If you look in the actual source files, you
+will see that there is already a square instruction that you can
+model this on.
+if-twice
+that will execute the next instruction if-and-only-if the value in the ?BX?
+register is twice that of the value in its complement. In other words by
+default, if would test of BX was twice CX, but if it is followed by a
+nop-C it will test if CX is twice AX.
+
+
+
+
+## Code Formatting
+
+Indentation
+
+
+
+
+
+Braces
+
+Function Definitions
+ Right:
+
+void cFoo::Method()
+{
+ // code goes here
+}
+
+// ... in a class
+inline void Method() { ; }
+
+inline void Method()
+{ // longer code in here }
+
+ Wrong:
+
+void cFoo::Method() {
+ // code goes here
+}
+
+// ... in a class
+inline void Method() {
+ ; }
+
+
+ For, While, Do Loops and Switch Statements
+ Right:
+
+while (foo) {
+ // code goes here
+}
+
+ Wrong:
+
+while (foo)
+{
+}
+
+
+ If/Else Statements
+ Right:
+
+if (foo) {
+ DoSomething();
+ DoAnotherSomething();
+} else {
+ DoADifferentSomthing();
+}
+
+if (!foo) CallAFunction();
+else CallBFunction();
+
+ Wrong:
+
+if (foo)
+{
+ DoSomething();
+ DoAnotherSomething();
+} else
+ DoADifferentSomthing();
+
+if (!foo) {
+ CallAFunction();
+}
+else CallBFunction();
+
+ Parentheses
+Function Declarations and Calls
+ Right:
+
+void cFoo::Method(int arg1, double arg2);
+int aFunction();
+
+ Wrong:
+
+void cFoo::Method( int arg1 , double arg2 );
+void cFoo::Method (int arg1, double arg2);
+int Function ( );
+
+
+ Control Structures
+ Other Punctation
+
+
+
+
+Include Guards and Statements
+
+
+
+
+## Naming Conventions
+
+
+#ifndef cPopulation_h
+#define cPopulation_h
+
+// Code goes here
+
+#endif
+
+
+
+
+
+
+i
+position
+this_is_my_var
+
+
+m_type
+m_lexeme
+m_my_component
+
+
+Sort()
+ThisIsMyFunction()
+cHardwareCPU::SingleProcess()
+
+
+cHardwareBase::doSlipMutation()
+cParser::parseCodeBlock()
+
+
+Genome
+Array
+HeadTypes
+SomeData
+
+
+NUM_REGISTERS
+MAX_STRING_LENGTH
+
+
+Genome.h
+Array.h
+Population.cc
+
+Class Dependency Guidelines
+Tools Classes
+ STL Usage
+ $ git clone https://github.com/devosoft/avida.git
+Note, however, that the Avida project uses the Apto library linked as a submodule. You must initialize the submodule following the clone command above before you will be able to build the project:
+$ cd avida
+$ git submodule init
+$ git submodule update
+At this point you should be able to proceed to compiling.
+
+## Compiling
+### Unix Command Line - CMake
+You will need a copy of CMake.
+
+
+### Mac OS X - Xcode
+./build_avida script.
+ -DAVD_GUI_NCURSES with ./build_avidacbuild/work
+
+
+### Windows - Visual Studio
+
+
+Some other notes:
+
+
+
+## Project Structure
+The Avida project master repository has been organized in the structure described below. This overview should help locate where the sub-projects you are interested in may be found. See specific sub-project pages for further information.
+
+
+
+## Contributing to the Repositories
+There are two main ways to contribute code changes to the repositories of the Avida project. The community at large is encouraged to fork the repositories on GitHub and to submit pull requests as appropriate. More details about using GitHub is available on their site.
+
+Core developers who have been granted direct push access will need to utilize the authenticated remote repository path. The authenticated repository is git@github.com:devosoft/avida.git. If you are working from a standard clone of the source code, you may update your push URLs with the following commands:
+$ git remote set-url --push origin git@github.com:devosoft/avida.git
diff --git a/docs/documentation/Development-|-Tutorial-|-Birth-Death-Cycle.md b/docs/documentation/Development-|-Tutorial-|-Birth-Death-Cycle.md
new file mode 100644
index 0000000..7b39679
--- /dev/null
+++ b/docs/documentation/Development-|-Tutorial-|-Birth-Death-Cycle.md
@@ -0,0 +1,228 @@
+The Death of an Organism
+
+
+void cPopulation::KillOrganism(cPopulationCell& in_cell)
+{
+ // do we actually have something to kill?
+ if (in_cell.IsOccupied() == false) return;
+
+ // Statistics...
+ cOrganism* organism = in_cell.GetOrganism();
+ cGenotype* genotype = organism->GetGenotype();
+ m_world->GetStats().RecordDeath();
+
+ num_organisms--;
+ genotype->RemoveOrganism();
+
+ // And clear it!
+ in_cell.RemoveOrganism();
+ if (!organism->GetIsRunning()) delete organism;
+ else organism->GetPhenotype().SetToDelete();
+
+ // Alert the scheduler that this cell has a 0 merit.
+ schedule->Adjust(in_cell.GetID(), cMerit(0));
+
+ // Update the archive (note: genotype adjustment may be deferred)
+ m_world->GetClassificationManager().AdjustGenotype(*genotype);
+}
+
+
+Activating an Organism in a Specific Cell
+
+
+void cPopulation::ActivateOrganism(cAvidaContext& ctx, cOrganism* in_organism, cPopulationCell& target_cell)
+{
+ in_organism->SetOrgInterface(new cPopulationInterface(m_world));
+
+ // If the organism does not have a genotype, give it one! No parent
+ // information is provided so we must set parents to NULL.
+ if (in_organism->GetGenotype() == NULL) {
+ cGenotype* new_genotype = m_world->GetClassificationManager().GetGenotype(in_organism->GetGenome(), NULL, NULL);
+ in_organism->SetGenotype(new_genotype);
+ }
+ cGenotype* in_genotype = in_organism->GetGenotype();
+
+ // Save the old genotype from this cell...
+ cGenotype* old_genotype = NULL;
+ if (target_cell.IsOccupied()) {
+ old_genotype = target_cell.GetOrganism()->GetGenotype();
+
+ // Sometimes a new organism will kill off the last member of its genotype
+ // in the population. Normally this would remove the genotype, so we
+ // want to defer adjusting that genotype until the new one is placed.
+ old_genotype->IncDeferAdjust();
+ }
+
+ // Update the contents of the target cell.
+ KillOrganism(target_cell);
+ target_cell.InsertOrganism(*in_organism);
+
+ // Update the archive...
+ in_genotype->AddOrganism();
+
+ if (old_genotype != NULL) {
+ old_genotype->DecDeferAdjust();
+ m_world->GetClassificationManager().AdjustGenotype(*old_genotype);
+ }
+ m_world->GetClassificationManager().AdjustGenotype(*in_genotype);
+
+ // Initialize the time-slice for this new organism.
+ schedule->Adjust(target_cell.GetID(), in_organism->GetPhenotype().GetMerit());
+
+ // Special handling for certain birth methods.
+ if (m_world->GetConfig().BIRTH_METHOD.Get() == POSITION_CHILD_FULL_SOUP_ELDEST) {
+ reaper_queue.Push(&target_cell);
+ }
+
+ num_organisms++;
+
+ // Statistics...
+ m_world->GetStats().RecordBirth(target_cell.GetID(), in_genotype->GetID(),
+ in_organism->GetPhenotype().ParentTrue());
+}
+
+
+reaper_queue if we keep track
+of the birth order of organisms so that we can always kill off the oldest in
+the population.
+Placing an Offspring in the Population
+
+Injecting an Organism into the Population
+
+Inject action) is somewhat easier to deal with.
+Basically, all that this method needs to do is build the organism with the
+proper genome, determine its genotype, setup its phenotype, put it into a
+test CPU to get its initial merit, and activate it! You should be able to
+go line-by-line through the code to see how exactly this happens for
+yourself. See
+cPopulation::InjectGenome,
+and more importantly
+cPopulation::InjectGenotype
+in cPopulation.cc.
+Objects and Classes
+cOrganism
+-- it is the class that all organism objects belong to. Here is an abbreviated
+version of the cOrganism class declaration (explained further below).
+
+
+class cOrganism
+{
+private: // Data in this class cannot be directly accessed from outside.
+ const Genome m_genome; // The initial genome that this organism was born with.
+ cPhenotype m_phenotype; // Maintains the status of this organism's phenotypic traits.
+
+ cOrgInterface* m_interface; // Interface back to the population.
+
+ cGenotype* m_genotype; // A pointer to the genotype that this organism belongs to.
+ cHardwareBase* m_hardware; // The virtual machinery that this organism's genome is run on.
+
+public: // The methods are accessible to other classes.
+ cOrganism(cWorld* world, cAvidaContext& ctx, const Genome& in_genome);
+ ~cOrganism();
+
+ // This batch of methods involve interaction with the population to resolve.
+ cOrganism* GetNeighbor() { return m_interface->GetNeighbor(); }
+ int GetNeighborhoodSize() { return m_interface->GetNumNeighbors(); }
+ void Rotate(int direction) { m_interface->Rotate(direction); }
+ int GetInput() { return m_interface->GetInput(); }
+ void Die() { m_interface->Die(); }
+
+ // Accessors -- these are used to gain access to private data.
+ const Genome& GetGenome() const { return m_genome; }
+ cHardwareBase& GetHardware() { return *m_hardware; }
+ cPhenotype& GetPhenotype() { return m_phenotype; }
+ cGenotype* GetGenotype() { return m_genotype; }
+};
+
+
+
+Style and Syntax Guide
+
+private: for those portions of the definition that can only
+be interacted with from within the class, and another labeled public:
+which defines the interface to the outside. In this case, we've made all
+of the variables private and the methods public.
+cPhenotype) and then the name of this particular instance
+of the variable. In this case, since organisms only have one phenotype,
+we called it merely m_phenotype. Not that because this
+variable is a member of cOrganism instances, it is
+prefixed with 'm_'.
+int for integer), or else
+lists void if there is no return value. Then the method name is
+given, followed by a set of parenthesis (which are what indicates to C++ that
+you are declaring a method). Inside of those parentesis, can be
+arguments, which are variables that must be given to the
+method in order for it to operate correctly. The declaration can stop at this
+point (ending in a semi-colon) if the method body is defined
+elsewhere. The body of the method is the sourcecode that details how the method
+operates, and can be included immediately after the declaration (within braces)
+or be placed elsewhere in the code. Typically short method bodies are included
+in the class definition, while longer ones are placed outside of it. A method is
+performed on an object, by listing the object name, followed by a dot ('.'), and
+then the name of the method to be called with all necessary arguments included.
+This is explained further below.
+
+
+
+Description of Data Elements
+
+private above lists those data that are unique
+to each organism; these are objects and pointers that exist inside of
+an organism object. First, m_genome keeps
+the initial state of the organism. Since we never want this genome to change
+over the organism's life, we place a const directive in front of
+it. The const command exists so that C++ knows to warn the
+programmer if they accidentally try to change an object (or variable) that
+is not supposed to be altered.
+cGenotype* genotype" indicates that the variable
+genotype points to a location in memory
+where an object of class cGenotype is
+stored. In this case, all of the organisms that are of a single genotype all
+point to the same cGenotype object so that the genotypic information
+is accessible to all organisms that may need to make use of it.
+Description of Methods
+
+const is used twice. The first time is to say that
+the object being passed out of the method is constant (that is, the programmer
+should be warned if somewhere else in the code it is being changed) and the
+second time is to say that the actions of this method will never change
+anything about the object they are being run on (that is, the object is being
+left constant even when the method is run.) The net effect of this is that an
+object marked const can only have const methods run on it. The compiler will
+assume that a non-const method being run will make a change to the object, and
+is therefore an error.
+Pointers, References, and Values
+
+
+ Genome GetGenomeValue();
+ Genome* GetGenomePointer();
+ Genome& GetGenomeReference();
+
+Memory Management
+
+new is used to allocate memory; for example if
+you wanted to allocate memory for a new genome containing 100 instructions,
+you could type:
+
+ Genome* created_genome = new Genome(100);
+
+new command.
+The Genome constructor (called with new) takes as an argument a single number
+that is the sequence length of the genome.
+
+ delete created_genome;
+
+Inherited Classes
+
+Other C++ Resources:
+
+
+
\ No newline at end of file
diff --git a/docs/documentation/Development-|-Tutorial-|-Environment.md b/docs/documentation/Development-|-Tutorial-|-Environment.md
new file mode 100644
index 0000000..0f355be
--- /dev/null
+++ b/docs/documentation/Development-|-Tutorial-|-Environment.md
@@ -0,0 +1,268 @@
+Task Entries
+
+
+typedef double (cTaskLib::*tTaskTest)(cTaskContext*) const;
+
+class cTaskEntry {
+private:
+ cString m_name; // Short keyword for task
+ cString m_desc; // For more human-understandable output...
+ int m_id;
+ tTaskTest m_test_fun;
+ cString m_info; // extra info (like the string or whatever to match)
+
+public:
+ cTaskEntry(const cString& name, const cString& desc, int in_id, tTaskTest test_fun, const cString& info);
+ : m_name(name), m_desc(desc), m_id(in_id), m_test_fun(test_fun), m_info(info)
+ {
+ }
+ ~cTaskEntry() { ; }
+
+ const cString& GetName() const { return m_name; }
+ const cString& GetDesc() const { return m_desc; }
+ const int GetID() const { return m_id; }
+ const tTaskTest GetTestFun() const { return m_test_fun; }
+ const cString& GetInfo() const { return m_info; }
+};
+
+
+Task Libraries
+
+
+class cTaskLib {
+private:
+ Apto::Array<cTaskEntry*> task_array;
+
+public:
+ int GetSize() const { return task_array.GetSize(); }
+
+ cTaskEntry* AddTask(const cString& name, const cString& info);
+ const cTaskEntry& GetTask(int id) const;
+
+ void SetupTests(cTaskContext& ctx) const;
+ inline double TestOutput(const cTaskEntry& task, cTaskContext* ctx) const;
+
+private:
+ double Task_Echo(cTaskContext* ctx) const;
+ double Task_Add(cTaskContext* ctx) const;
+ double Task_Sub(cTaskContext* ctx) const;
+
+ double Task_Not(cTaskContext* ctx) const;
+ double Task_Nand(cTaskContext* ctx) const;
+ double Task_And(cTaskContext* ctx) const;
+ // ... And a whole bunch more ...
+
+};
+
+
+
+double cTaskLib::Task_Add(cTaskContext* ctx) const
+{
+ const int test_output = ctx->output_buffer[0];
+ for (int i = 0; i < ctx->input_buffer.GetNumStored(); i++) {
+ for (int j = 0; j < i; j++) {
+ if (test_output == ctx->input_buffer[i] + ctx->input_buffer[j]) return 1.0;
+ }
+ }
+ return 0.0;
+}
+
+
+
+double cTaskLib::Task_AndNot(cTaskContext* ctx) const
+{
+ const int logic_id = ctx->logic_id;
+ if (logic_id == 10 || logic_id == 12 || logic_id == 34 ||
+ logic_id == 48 || logic_id == 68 || logic_id == 80) return 1.0;
+ return 0.0;
+}
+
+
+Building a Reaction
+
+Resources
+
+
+
+Tying it all together: The Environment
+
+
+class cEnvironment {
+private:
+ // Keep libraries of resources, reactions, and tasks.
+ cResourceLib resource_lib;
+ cReactionLib reaction_lib;
+ cTaskLib task_lib;
+ cInstLib inst_lib;
+ cMutationRates mut_rates;
+
+public:
+ bool Load(const cString& filename);
+
+ // Interaction with the organisms
+ bool TestOutput(cAvidaContext& ctx, cReactionResult& result, cTaskContext& taskctx,
+ const tBuffer<int>& send_buf, const tBuffer<int>& receive_buf,
+ const Apto::Array<int>& task_count, const Apto::Array<int>& reaction_count,
+ const Apto::Array<double>& resource_count) const;
+};
+
+
+The cInstruction Class
+
+
+class cInstruction {
+private:
+ unsigned char m_operand;
+
+public:
+ // Constructors and Destructor...
+ cInstruction() : m_operand(0) { ; }
+ cInstruction(const cInstruction& inst) { *this = inst; }
+ explicit cInstruction(int in_op) { SetOp(in_op); }
+ ~cInstruction() { ; }
+
+ // Accessors...
+ int GetOp() const { return static_cast<int>(m_operand); }
+ void SetOp(int in_op) { assert(in_op < 256); m_operand = in_op; }
+
+ // Operators...
+ void operator=(const cInstruction& inst) { m_operand = inst.m_operand; }
+ bool operator==(const cInstruction& inst) const { return (m_operand == inst.m_operand); }
+ bool operator!=(const cInstruction& inst) const { return !(operator==(inst)); }
+
+ // Some extra methods to convert too and from alpha-numeric symbols...
+ char GetSymbol() const;
+ void SetSymbol(char symbol);
+};
+
+
+unsigned char. A
+char is an 8 bit number, so when one is unsigned, it represents a number from 0
+to 255. As Avida is currently implemented, we are limited to 256 distinct
+instructions. To the outside world, we treat the instruction operand like an
+integer, so it would be easy to modify this class were we ever to need more
+than 256 instructions in the set. The only reason to limit it to 8 bits
+internally (rather than the 32 of an int) is to save memory when we have a very
+large number of instructions throughout a population. Instructions already
+make up over half of all the memory resources used by Avida.
+The Genome class
+
+
+class Genome
+{
+protected:
+ Apto::Array<cInstruction> genome;
+ int active_size;
+
+public:
+ Genome() { ; }
+ explicit Genome(int _size);
+ Genome(const Genome& in_genome);
+ Genome(const cString& in_string);
+ virtual ~Genome();
+
+ virtual void operator=(const Genome& other_genome);
+ virtual bool operator==(const Genome& other_genome) const;
+ virtual bool operator!=(const Genome& other_genome) const { return !(this->operator==(other_genome)); }
+ virtual bool operator<(const Genome& other_genome) const { return AsString() < other_genome.AsString(); }
+
+ cInstruction& operator[](int index) { assert(index >= 0 && index < active_size); return genome[index]; }
+ const cInstruction& operator[](int index) const { assert(index >= 0 && index < active_size); return genome[index]; }
+
+ virtual void Copy(int to, int from);
+
+ int GetSize() const { return active_size; }
+ cString AsString() const;
+};
+
+
+initial_genome, the
+statement initial_genome[15] would return the instruction at
+position fifteen in the genome. This occurs by calling one of these methods
+with the appropriate integer. The difference between these two operator
+methods is that one of them is for mutable genomes (i.e. those that can be
+modified) -- a reference to the instruction in question is returned allowing
+it to be altered. The other index operator (operator[] method) is for const
+genomes, which can never be changed so only the value of the instruction is
+returned.
+1. Allocation of Offspring Memory
+
+h-alloc,
+which will allocate space for an offspring to be placed into. If you look at
+the file source/cpu/cHardwareCPU.cc, you will see that this
+instruction is associated with the method
+cHardwareCPU::Inst_MaxAlloc().
+What this means is that the organism will automatically allocate as much
+space as it possibly can, without having to first calculate its needs. When
+the organism is finished copying itself and divides off its child, any excess
+allocated memory will automatically be discarded.
+2. Initial Self-Analysis
+
+search instruction or one of its variants. In the heads based
+instruction set, we call this h-search and associate it with the
+method cHardwareCPU::Inst_HeadSearch().
+mov-head instruction.
+mov-head instruction is followed by a nop-C it
+will move the write head to the flow head, and ideally be ready to start
+copying itself into the newly allocated space for the offspring.
+3. The Copy Loop
+
+h-search command with
+no template to direct its behavior. The default when this instruction does not
+have a template is to just drop the flow-head at the very next instruction,
+which is what it is used for here -- it places the flow head at the beginning
+of the portion of code that will actually be looped through copying each line.
+h-copy instruction
+that will read in an instruction from the location of the read-head, and write
+it out to the location of the write-head. It will then advance both heads to
+the next positions in the genomes. Take a look at the source code for the
+method cHardwareCPU::Inst_HeadCopy().
+if-label instruction, which tests to see if
+the most recent label copied is the complement of the one that follows it.
+If so, it will execute the next instruction (often a divide), otherwise it
+will skip that next instruction and execute a mov-head that will
+jump the instruction pointer back to the flow head that was placed at the
+beginning of the copy loop. It will continue this copy-test-jump cycle
+until all the lines have been copied.
+h-copy,
+if-label, and mov-head. But what if a second
+h-copy command were inserted after the first? Now the program
+would be one line longer, so it would have more to copy, but each time
+through the loop would now copy two instructions while executing four --
+that means that on average only two instructions need be executed to copy
+one. A *huge* savings. The main drawback to the organism is that its
+length will need to be a multiple of two, or else the test to see if it is
+finished won't occur at the proper time. This loop unrolling becomes less
+and less beneficial each time the organism does it, so it won't go completely
+out of control.
+4. Dividing off the Child
+
+h-divide command which calls the
+cHardwareCPU::Inst_HeadDivide()
+method.
+5. Other Bits
+
+1. Build the prototype of the method that will be used to test the new task
+
+
+double Task_Times2(cTaskContext& ctx) const;
+
+
+2. Build the body of the method that will be used to test the new task
+
+
+double cTaskLib::Task_Times2(cTaskContext& ctx) const
+{
+ const tBuffer<int>& input_buffer = ctx.GetInputBuffer();
+ const int test_output = ctx.GetOutputBuffer()[0];
+ const int input_size = ctx.GetInputBuffer().GetNumStored();
+ for (int i = 0; i < input_size ; i++)
+ {
+ if ( test_output == 2 * input_buffer[i])
+ {
+ return 1.0;
+ }
+ }
+ return 0.0;
+}
+
+
+3. Attach our new method to the name of its trigger
+
+
+else if (name == "times2")
+ NewTask(name, "Times2", &cTaskLib::Task_Times2);
+
+
+
+
+
+
+
+
+OFFSPRING_SIZE_RANGEThis is the maximal difference in genome size between a parent and offspring. The default of 2.0 means that the genome of the child must be between one-half and twice the length of the parent. This it to prevent out-of-control size changes. Setting this to 1.0 will ensure fixed length organisms (as long as you also change the other settings detailed in How to Set Up Fixed-Length Organisms).
+
+
+
+ MIN_COPIED_LINES
MIN_EXE_LINES These settings place limits on what the parent must have done before the offspring can be born; they set the minimum fraction of instructions that must have been copied into the offspring (vs. left as default) and the minimum fraction of instructions in the parent that must have been executed. If either of these are not met, the divide will fail. These settings prevent organisms from producing pathological offspring. In practice, either of them can be set to 0.0 to turn them off.
+
+
+
+REQUIRE_ALLOCATEIs an allocate required between each successful divide (in virtual hardware types where allocate is meaningful)? If so, this will limit the flexibility of how organisms produce children (they can't make multiple copies and divide them off all at once, for example). But if we don't require allocates, the resulting organisms can be a lot more difficult to understand.
+
+
+
+REQUIRED_TASKThis is a bit of a hack. It allows the user to set the ID number for a task that must occur for a divide to be successful. At -1, no tasks are required. Ideally, this should be incorporated into the environment configuration file. NOTE: A task can fire without triggering a reaction. To add a required reaction see below.
+
+
+
+IMMUNITY_TASKAllows user to set the ID number for a task which, if it occurs, provides immunity from the required task (above) -- divide will proceed even if the
+REQUIRED_TASK is not done if IMMUNITY_TASK is done. Defaults to -1, no immunity task present.
+
+
+REQUIRED_REACTIONAllows the user to set the ID number for a reaction that must occur for a divide to be successful. At -1, no reactions are required.
+
+
+
+IMMUNITY_REACTIONAllows the user to set the ID number for a reaction that, if it occurs, provides immunity from the required reaction (above) -- divide will proceed even if the
+REQUIRED_REACTION has not been performed as long as the IMMUNITY_REACTION has been performed. Defaults to -1, no immunity reaction present.
+
+
+
+REQUIRE_EXACT_COPYRequires the offspring to be an exact copy of the parent -- before divide mutations are imposed. At first glance this setting looks very similar to the
+STERILIZE_UNSTABLE setting in the Mutation Reversion group of settings. However, REQUIRE_EXACT_COPY allows any kind of divide mutation (see Mutation Settings)-- point, insertion, deletion, slip, etc. It does not allow before-divide mutations such as copy mutations. On the other hand, STERILIZE_UNSTABLE allows any kind of mutation, as long as the organism would be able to perfectly copy itself in the absence of mutations.MIN_GENOME_SIZE, MAX_GENOME_SIZE, REQUIRE_SINGLE_REACTION, REQUIRED_BONUS, REQUIRED_RESOURCE, REQUIRED_RESOURCE_LEVEL, REQUIRED_PRED_HABITAT, REQUIRED_PRED_HABITAT_VALUE, IMPLICIT_REPRO_BONUS, IMPLICIT_REPRO_CPU_CYCLES, IMPLICIT_REPRO_TIME, IMPLICIT_REPRO_END, and IMPLICIT_REPRO_ENERGY.Overview
+Settings
+avida.cfg
+
+### ENERGY_GROUP ###
+# Energy Settings
+ENERGY_ENABLED 0 # Enable Energy Model. 0/1 (off/on)
+ENERGY_GIVEN_ON_INJECT 0 # Energy given to organism upon injection.
+ENERGY_GIVEN_AT_BIRTH 0 # Energy given to offspring upon birth.
+FRAC_PARENT_ENERGY_GIVEN_AT_BIRTH 0.5 # Fraction of perent's energy given to offspring.
+FRAC_ENERGY_DECAY_AT_BIRTH 0.0 # Fraction of energy lost due to decay during reproduction.
+NUM_INST_EXC_BEFORE_0_ENERGY 0 # Number of instructions executed before energy is exhausted.
+ENERGY_CAP -1 # Maximum amount of energy that can be stored in an organism.
+ # -1 means the cap is set to Max Int
+APPLY_ENERGY_METHOD 0 # When should rewarded energy be applied to current energy?
+ # 0 = on divide
+ # 1 = on completion of task
+ # 2 = on sleep
+FRAC_ENERGY_TRANSFER 0.0 # Fraction of replaced organism's energy take by new resident
+LOG_SLEEP_TIMES 0 # Log sleep start and end times. 0/1 (off/on)
+ # WARNING: may use lots of memory.
+
+
+Flag that disables/enables the us of the energy model. + +0 = off, 1 = on +
+ +ENERGY_GIVEN_ON_INJECT ++How much energy is given to an injected organism. + +This number should be large enough to sustain the population until it can gather its own energy through tasks, etc.. +
+ +ENERGY_GIVEN_AT_BIRTH ++How much energy is given to an organism when it is born. +
+ +FRAC_PARENT_ENERGY_GIVEN_AT_BIRTH ++Fraction of the parent(s) energy which is taken from the parent and given to the offspring at birth. +
+ +FRAC_ENERGY_DECAY_AT_BIRTH ++Fraction of energy that decays on birth. +
+ +NUM_INST_EXC_BEFORE_0_ENERGY ++Number of instructions an organism can execute before it runs out of energy assuming no new energy. + +Note: if instructions have energy costs > 0 then this options needs to be altered accordingly. +
+ +ENERGY_CAP ++Maximum amount of energy that can be stored in an organism. +
+ +APPLY_ENERGY_METHOD +
+Specifies when newly received energy is applied to the organism energy store and metabolic rate.
+
+Note: the sleep instruction can also be used as an eat instructions if needed.
+
+Fraction of a replaced organism's energy transfered to the replacing organism. +
+ +LOG_SLEEP_TIMES +
+Logs start and end times, in updates, of all executions of the sleep instruction.
+
+Note: can use a lot of memory.
+
+This is the setup file for the task/resource system in Avida. +
++Six main keywords are used in this file, RESOURCE, GRADIENT_RESOURCE, REACTION, CELL, MUTATION, and SET_ACTIVE. Their formats are: +
+
+ RESOURCE resource_name[:options] {resource_name ...}
+ GRADIENT_RESOURCE gradient_resource_name[:options] {gradient_resource_name ...}
+ REACTION reaction_name task [process:...] [requisite:...]
+ CELL resource_name:cell_list[:flow]
+ MUTATION name trigger scope type rate
+ SET_ACTIVE type name new_status(default=true)
+
+
+
+All entries on a resource line are names of individual resources. Resources can have a global quantity depletable by all organisms or can have quantities that vary from cell to cell. The resource name infinite is used to refer to an undepletable resource. There are two basic commands to set up a general resource: RESOURCE and CELL. In addition, GRADIENT_RESOURCE is a specific instance of RESOURCE which allows the user to specify a cellular distribution of quantities that change (aka move) over time in an Avida run.
+
The syntax for the Resource command is:
+ +RESOURCE resource_name[:options] {resource_name ...}
+
++++Where
+resource_nameis a unique name of the resource. This name may be used by theCELLcommand to further define the resource or in theREACTIONto define which resource is consumed/created +by a reaction. ++Where
+optionsis a colon delimited list of factors that modify the +resource. The following chart specifies these options. +
+
+(blue variables used for all resources +while red variables are only used for +spatial resources) +
+| Argument | +Description | +Default | +
|---|---|---|
| inflow | ++ The number of units of the resource that enter the population over + the course of an update. For a global resource this inflow + occurs evenly throughout the update, not all at once. For a + spatial resource this inflow amount is added every update + evenly to all grid cells in the rectangle described by the + points (inflowx1,inflowy1) and (inflowx2,inflowy2). + | +0 | +
| outflow | ++ The fraction of the resource that will flow out of the population + each update. As with inflow, this happens continuously over the + course of the update for a global resource. In the case of a + spatial resource the fraction is withdrawn each update from + each cell in the rectangle described by the points + (outflowx1,outflowy1) and (outflowx2,outflowy2). + | +0.0 | +
| initial | ++ The initial abundance of the resource in the population at the + start of an experiment. For a spatial resource the initial + amount is spread evenly to each cell in the world grid. + | +0 | +
| geometry | +
+ The layout of the resource in space. + global -- the entire pool of a resource is + available to all organisms + grid -- organisms can only access resources in + their grid cell. Resource can not flow past the edges of the + world grid. (resource will use spatial parameters) + torus -- organisms can only access resources in + their grid cell. Resource can flow to the opposite edges of the + world grid. (resource will use spatial parameters) + |
+ global | +
| deme | ++ Is this resource going to be used by a deme. (True or + False) + | ++ false + | +
| energy | ++ Is this an energy resource. The energy model must be used. + (True or False) + | ++ false + | +
| inflowx1 | ++ Leftmost coordinate of the rectangle where resource will flow + into world grid. If not specified but an inflow rate is specified, + an x-coordinate will be determinstically assigned. + | +0 | +
| inflowx2 | ++ Rightmost coordinate of the rectangle where resource will flow + into world grid. If not specified, inflowx1's value will be used. + | +0 | +
| inflowy1 | ++ Topmost coordinate of the rectangle where resource will flow + into world grid. If not specified but an inflow rate is specified, + a y-coordinate will be determinstically assigned. + | +0 | +
| inflowy2 | ++ Bottommost coordinate of the rectangle where resource will flow + into world grid. If not specified, inflowy1's value will be used. + | +0 | +
| outflowx1 | ++ Leftmost coordinate of the rectangle where resource will flow + out of world grid. + | +0 | +
| outflowx2 | ++ Rightmost coordinate of the rectangle where resource will flow + out of world grid. If not specified, outflowx1's value will be used. + | +0 | +
| outflowy1 | ++ Topmost coordinate of the rectangle where resource will flow + out of world grid. + | +0 | +
| outflowy2 | ++ Bottommost coordinate of the rectangle where resource will flow + out of world grid. If not specified, outflowy1's value will be used. + | +0 | +
| xdiffuse | ++ How fast material will diffuse right and left. This flow + depends on the amount of resources in a given cell and amount in + the cells to the right and left of it. (0.0 - 1.0) + | +1.0 | +
| xgravity | ++ How fast material will move to the right or left. This + movement depends only on the amount of resource in a given cell. + (-1.0 - 1.0) + | +0 | +
| ydiffuse | ++ How fast material will diffuse up and down. This flow + depends on the amount of resources in a given cell and amount in + the cells above and below it. (0.0 - 1.0) + | +1.0 | +
| ygravity | ++ How fast material will move to the up or down. This + movement depends only on the amount of resource in a given cell. + (-1.0 - 1.0) + | +0 | +
+
+An example of a RESOURCE statement that begins a run with a fixed amount of the +(global) resource in the environment, but has no inflow or outflows is: +
+ RESOURCE glucose:initial=10000 ++ +
+If you wanted to make this into a chemostat with a 10000 equilibrium +concentration for unused resources, you could put: +
+ RESOURCE maltose:initial=10000:inflow=100:outflow=0.01 ++ +
+If you want a resource that exists spatially where the resource enters +from the top and flows towards the bottom where it exits the system, +you could use: +
+ RESOURCE lactose:geometry=grid:initial=100000:inflow=100:outflow=0.1:\ + inflowx1=0:inflowx2=100:inflowy1=0:inflowy2=0:outflowx1=0:outflowx2=100:\ + outflowy1=100:outflowy2=100:ygravity=0.5 ++ +
+Defining a resource with no parameters means that it will start at a zero +quantity and have no inflow or outflow. This is sometimes desirable if you +want that resource to only be present as a byproduct of a reaction. +Remember, though, that you should still have an outflow rate if it's in +a chemostat. + + +
+ ++Using Cell can help increase the detail of a spatial resource. Any cell in a +grid can be given their own initial amount of a resource, inflow amount and +outflow rate. These values are in addition to any other values set for the +spatial resource for the entire for the grid (diffusion and gravity for +instance). The command has the format: +
+CELL resource_name:cell_list[:options]+
+
+Where+ +resource_nameis the name of the spatial resource that this +cell command will modify. If this resource has not been defined yet, a new +resource with this name will be created. + ++Where
+cell_listis comma delimited list of cells that will be set. +We treat the grid like a one dimensional array where 0 is the upper left corner, +world_x - 1 is the upper right corner, and (world_x * world_y) - 1 is the +lower right corner. As well as single cell you can also enter a range of +cells by using the format a..b. ++Where
+optionsis a colon delimited list of factors that modify the +resource. The following chart specifies these options. +
+
| Argument | +Description | +Default | +
|---|---|---|
| inflow | ++ The number of units of the resource that enter a cell at the end of an + update. + | +0 | +
| outflow | ++ The fraction of the resource that will flow out a cell each update. + | +0.0 | +
| initial | ++ The initial abundance of the resource in a cell at the start of an + experiment. + | +0 | +
+
+An example of setting two cells in the glucose spatial resource: +
+CELL glucose:20,50:initial=100:inflow=10:outflow=0.1+ +
+An example of setting a 3 x 3 square of cells in the middle of a a maltose +spatial resource (assuming a 10 x 10 world): +
+CELL maltose:33..35,43..45,53..55:initial=500:inflow=5:outflow=0.01+ +
+Reactions are set to allow organisms to consume or produce resources when those +organisms preform certain tasks. Reactions can be used to reward (or punish) +organisms for performing tasks or to set up a "food web". They +are described by the task that triggers them, the processes they +perform (including resources used and the results of using them), and +requisites on when they can occur. +
+ +REACTION reaction_name task[:argument:...] [process:...] [requisite:...]+
+++ Where
+reaction_nameis a unique name for a reaction. ++ Where
+taskis the name of the task that must be be performed to + trigger the reaction. A list of common tasks is listed in Table 3. ++ Where
+ Whereargumentis a list of specific arguments needed by the + particular task. +processis a colon delimited list of information about how + resources are consumed/produced. Process settings are described in Table 4. + ++ Where
requisiteis a colon delimited list describing when + reactions can be triggered. Requisite settings are described in Table 5. +
+Each reaction must have a task that triggers it. Currently, eighty tasks +have been implemented, as summarized in the following table (in approximate +order of complexity): +
+ ++
| Task | +Description | +
|---|---|
| echo | ++ This task is triggered when an organism inputs a single number and + outputs it without modification. + | +
| add | ++ This task is triggered when an organism inputs two numbers, sums them + together, and outputs the result. + | +
| sub | ++ This task is triggered when an organism inputs two numbers, subtracts + one from the other, and outputs the result. + | +
| not | ++ This task is triggered when an organism inputs a 32 bit number, + toggles all of the bits, and outputs the result. This is typically + done either by nanding (by use of the nand instruction) the + sequence to itself, or negating it and subtracting one. The latter + approach only works since numbers are stored in twos-complement + notation. + | +
| nand | ++ This task is triggered when two 32 bit numbers are input, the values + are 'nanded' together in a bitwise fashion, and the result is output. + Nand stands for "not and". + The nand operation returns a zero if and only if both inputs are one; + otherwise it returns a one. + | +
| and | ++ This task is triggered when two 32 bit numbers are input, the values + are 'anded' together in a bitwise fashion, and the result is output. + The and operation returns a one if and only if both inputs are one; + otherwise it returns a zero. + | +
| orn | ++ This task is triggered when two 32 bit numbers are input, the values + are 'orn' together in a bitwise fashion, and the result is output. + The orn operation stands for or-not. It is returns true if for each + bit pair one input is one or the other one is zero. + | +
| or | ++ This task is triggered when two 32 bit numbers are input, the values + are 'ored' together in a bitwise fashion, and the result is output. + It returns a one if either the first input or the second input + is a one, otherwise it returns a zero. + | +
| andn | ++ This task is triggered when two 32 bit numbers are input, the values + are 'andn-ed' together in a bitwise fashion, and the result is output. + The andn operation stands for and-not. It only returns a one if + for each bit pair one input is a one and the other input is + not a one. Otherwise it returns a zero. + | +
| nor | ++ This task is triggered when two 32 bit numbers are input, the values + are 'nored' together in a bitwise fashion, and the result is output. + The nor operation stands for not-or and returns a one only if both + inputs are zero. Otherwise a zero is returned. + | +
| xor | ++ This task is triggered when two 32 bit numbers are input, the values + are 'xored' together in a bitwise fashion, and the result is output. + The xor operation stands for "exclusive or" and returns a one + if one, but not both, of the inputs is a one. Otherwise a zero is + returned. + | +
| equ | ++ This task is triggered when two 32 bit numbers are input, the values + are equated together in a bitwise fashion, and the result is output. + The equ operation stands for 'equals' and will return a one if both + bits are identical, and a zero if they are different. + | +
| logic_3AA- logic_3CP |
+ + These tasks include all 68 possible unique 3-input logic operations, + many of which don't have easy-to-understand human readable names. + | +
+
+When describing a reaction, the process portion determines consumption
+of resources, their byproducts, and the resulting bonuses. There are several
+arguments (separated by colons; example below) to detail the use of a resource.
+Default values are in brackets:
+
+
| Argument | +Description | +Default | +
|---|---|---|
| resource | ++ The name of the resource consumed. By default, no resource is being + consumed, and the 'max' limit is the amount absorbed. + | +infinite | +
| value | ++ Multiply the value set here by the amount of the resource consumed + to obtain the bonus. (0.5 may be inefficient, while 5.0 is very + efficient.) This allows different reactions to make use of the + same resource at different efficiency levels. + | +1.0 | +
| type | +
+ Determines how to apply the bonus (i.e. the amount of the resource
+ absorbed times the value of this process) to change the merit of the
+ organism.
+ add: Directly add the bonus to the current merit. + mult: Multiply the current merit by the bonus (warning: if + the bonus is ever less than one, this will be detrimental!) + pow: Multiply the current merit by 2bonus. + this is effectively multiplicative, but positive bonuses are + always beneficial, and negative bonuses are harmful. + enzyme: Add bonus * resource / (resource + ksubm) to the current merit. + This is gives a Michaelis-Menten enzyme type reward where bonus is the Kcat + and the Km is entered. Does not work with unlimited resources. + energy: Add the bonus energy to the organism's energy waiting to be applied buffer. Bonus energy can be applied on completion of a reaction, execution of the sleep/eat instruction, or when the organisms divides. See Energy Model documentation for more information. + |
+ add | +
| max | +The maximum amount of the resource consumed per occurrence. | +1.0 | +
| min | ++ The minimum amount of resource required. If less than this quantity + is available, the reaction ceases to proceed. + | +0.0 | +
| frac | +The maximum fraction of the available resource that can be consumed. | +1.0 | +
| product | ++ The name of the by-product resource. At the moment, only a single + by-product can be produced at a time. + | +none | +
| conversion | +The conversion rate to by-product resource | +1.0 | +
| inst | ++ The instruction that gets executed when this reaction gets performed. If + you do not want an organism to be able to have the instruction in their + genome, you still must put it in the instruction set file, but set its weight + to zero. The instruction is executed at no cost to the organism. + | +none | +
| lethal | +Whether the cell dies after performing the process | +0 | +
| random | +Whether any produced resource is placed randomly in the world instead of the focal cell. | +0 | +
| depletable | ++ Whether this resource is consumed by reactions. + | +1 | +
| phenplastbonus | +
+ Specify how to handle phenotypic plasticity at run-time.
+ This option may significantly slow an Avida experiment.
+ When requested in many of the settings below (*), task
+ bonuses will be adjusted by the plasticity
+ of each organism's genotype. Requisites will still be
+ honored, making true task completion information ambiguous.
+ default: Do not attempt to use the genotype's task plasticity. + *nobonus: Do not give a bonus to non-static tasks. + *fracbonus: Scale the bonus by how static the task is. + *fullbonus: Always reward a task when it is detected. + |
+ + default + | +
| ksubm | ++ Km for an enzyme reaction. + | ++ 0.0 + | +
+
+If no process is given, a single associated process with all default +settings is assumed. If multiple process statements are given, all are +acted upon when the reaction is triggered. Assuming you were going to set +all of the portions of process to be their default values, this portion of +the reaction statement would appear as: +
+ process:resource=infinite:value=1:type=add:max=1:min=0:frac=1:product=none:conversion=1 ++ +
+This statement has many redundancies; for example, it would indicate that the +associated reaction should use the infinite resource, making 'frac' and 'min' +settings irrelevant. Likewise, since 'product' is set to none, the +'conversion' rate is never considered. +
+
+The requisite entry limits when this reaction can be triggered. The
+following requisites (in any combination) are possible:
+
+
| Argument | +Description | +Default | +
|---|---|---|
| reaction | ++ This limits this reaction from being triggered until the other + reaction specified here has been triggered first. With this, the + user can force organisms to perform reactions in a specified order. + | +none | +
| noreaction | ++ This limits this reaction from being triggered if the reaction + specified here has already been triggered. This allows the user to + make mutually exclusive reactions, and force organisms to "choose" + their own path. + | +none | +
| min_count | ++ This restriction requires that the task used to trigger this reaction + must be performed a certain number of times before the trigger will + actually occur. This (along with max_count) allows the user to + provide different reactions depending on the number of times an + organism has performed a task. + | +0 | +
| max_count + | + This restriction places a cap on the number of times a task can + be done and still trigger this reaction. It allows the user to + limit the number of times a reaction can be done, as well as + (along with min_count) provide different reactions depending on the + number of times an organism as performed a task. + | +INT_MAX | +
| min_tot_count | ++ This restriction requires that the total number of tasks performed by + the organism must be at least this high before this reaction will trigger. + This (along with max_tot_count) allows the user to provide different + reactions depending on how many tasks an organism performs. + | +0 | +
| max_tot_count | ++ This restriction places a cap on the number of tasks an organism can do + and still trigger this reaction. It allows the user to limit the number + of tasks that will be rewarded, as well as (along with min_tot_count) provide + different reactions depending on the number of tasks an organism performs. + | +INT_MAX | +
| reaction_min_count | ++ This restriction requires that the reaction must be performed a certain number + of times before any rewards are given. The restriction refers to the number of + times the specific reaction has been triggered, regardless of how many times + the referenced task has been performed. The reaction process specs max and min + will restrict reactions and their counts, not tasks. + | +0 | +
| reaction_max_count | ++ This restriction caps the number of times an organism can perform the reaction, + effectively limiting the number of times a reaction will be rewarded. The + restriction refers to the number of times the specific reaction has been triggered, + regardless of how many times the referenced task has been performed. The reaction + process specs max and min will restrict reactions and their counts, not tasks. + | +INT_MAX | +
| divide_only | ++ This command decides when a task will be checked, if the value is 0 the task + will only be checked when an organism executes an IO. If the value is 1 the task + will only be checked when the organism divides. If the value is 2 the task will be + checked at both times. + | +0 | +
| parasite_only | ++ This command only allows parasites to get credit for the reaction, not host organisms. + | +False | +
+
+No restrictions are present by default. If there are multiple requisite +entries, only *one* of them need be satisfied in order to trigger the +reaction. Note though that a single requisite entry can have as many +portions as needed. +
+ ++We could simulate the pre-environment system (in which no resources were +present and task performance was rewarded with a fixed bonus) with a file +including only lines like: +
+ REACTION AND logic:2a process:type=mult:value=4.0 requisite:max_count=1 + REACTION EQU logic:2h process:type=mult:value=32.0 requisite:max_count=1 ++ + +
+No RESOURCE statements need be included since only the infinite resource is +used (by default, since we don't specify another resource's name) +# To create an environment with two resources that are converted back and +forth as tasks are performed, we might have: +
+ RESOURCE yummyA:initial=1000 + RESOURCE yummyB:initial=1000 + REACTION AtoB gobbleA process:resource=yummyA:frac=0.001:product=yummyB + REACTION BtoA gobbleB process:resource=yummyB:frac=0.001:product=yummyA ++ +
+A value of 1.0 per reaction is default. Obviously gobbleA and
+gobbleB would have to be tasks described within Avida.
+
+A requisite against the other reaction being performed would prevent a +single organism from garnering both rewards in equal measure. +
++As an example, to simulate a chemostat, we might have: +
+ RESOURCE glucose:inflow=100:outflow=0.01 ++ +
+This would create a resource called "glucose" that has a fixed inflow rate of +10000 units where 20% flows out every update. (Leaving a steady state of +50,000 units if no organism-consumption occurs). +
+ ++Limitations to this system: +
+The default setup is: +
+ REACTION NOT not process:value=1.0:type=pow requisite:max_count=1 + REACTION NAND nand process:value=1.0:type=pow requisite:max_count=1 + REACTION AND and process:value=2.0:type=pow requisite:max_count=1 + REACTION ORN orn process:value=2.0:type=pow requisite:max_count=1 + REACTION OR or process:value=3.0:type=pow requisite:max_count=1 + REACTION ANDN andn process:value=3.0:type=pow requisite:max_count=1 + REACTION NOR nor process:value=4.0:type=pow requisite:max_count=1 + REACTION XOR xor process:value=4.0:type=pow requisite:max_count=1 + REACTION EQU equ process:value=5.0:type=pow requisite:max_count=1 ++ + +
+This creates an environment where the organisms get a bonus for performing +any of nine tasks. Since none of the reactions are associated with a +resource, the infinite resource is assumed, which is non-depeletable. +The max_count of one means they can only get the bonus from each reaction +a single time. +
+ ++A similar setup that has 9 resources, one corresponding to each of the nine +possible tasks listed above is: +
+ RESOURCE resNOT:inflow=100:outflow=0.01 resNAND:inflow=100:outflow=0.01 + RESOURCE resAND:inflow=100:outflow=0.01 resORN:inflow=100:outflow=0.01 + RESOURCE resOR:inflow=100:outflow=0.01 resANDN:inflow=100:outflow=0.01 + RESOURCE resNOR:inflow=100:outflow=0.01 resXOR:inflow=100:outflow=0.01 + RESOURCE resEQU:inflow=100:outflow=0.01 + + REACTION NOT not process:resource=resNOT:value=1.0:frac=0.0025 + REACTION NAND nand process:resource=resNAND:value=1.0:frac=0.0025 + REACTION AND and process:resource=resAND:value=2.0:frac=0.0025 + REACTION ORN orn process:resource=resORN:value=2.0:frac=0.0025 + REACTION OR or process:resource=resOR:value=4.0:frac=0.0025 + REACTION ANDN andn process:resource=resANDN:value=4.0:frac=0.0025 + REACTION NOR nor process:resource=resNOR:value=8.0:frac=0.0025 + REACTION XOR xor process:resource=resXOR:value=8.0:frac=0.0025 + REACTION EQU equ process:resource=resEQU:value=16.0:frac=0.0025 ++ + +
+Allows user to activate or deactivate a reaction. If this command is not +used all reactions are active. +
++ SET_ACTIVE type name new_status(default=true) ++
+\ No newline at end of file diff --git a/docs/documentation/Events-file.md b/docs/documentation/Events-file.md new file mode 100644 index 0000000..8a78fc2 --- /dev/null +++ b/docs/documentation/Events-file.md @@ -0,0 +1,28 @@ +The events file controls events that need to occur throughout the course of a run. This includes the output of data files as well as active events that effect the population (such as extinction events or changes to the mutation rate). + + + +File Formats + +This file consists of a list of events that will be triggered either singly or periodically. The format for each line is: + ++ Where
+typeis the type of command to activate/deactivate. + Currently REACTION is the only choice. ++ Where
+nameis the name of the item to activate/deactivate. ++ Where
new_statussets if the item is active (0 or FALSE will + deactivate). +
type timing event arguments
+
+The type determines what kind of timings the event will be based off of. This can be immediate [i], based on update [u], or based on generation [g].
+
+The timing should only be included for non-immediate events. If a single number is given for timing, the event occurs at that update/generation. A second number can be included (separated by a colon ':') to indicate how often the event should be repeated. And if a third number is listed (again, colon seperated) this will be the last time the event can occur on. For example, the type and timing `u 100:100:5000` would indicate that the event that follows first occurs at update 100, and repeats every 100 updates thereafter until update 5000. A type timing of g 10:10 would cause the event to be triggered every 10 generations for the entire run.
+
+The event is simply the name of the action that should be performed, and the arguments detail exactly how it should work when it is triggered. Each action has its own arguments. See the List of Actions for details about all of the available options.
+
+Some examples:
+
+i Inject
+Inject an additional start creature immediately.
+
+u 100:100 PrintAverageData
+Print out all average measurements collected every one hundred updates, starting at update 100.
+
+g 10000:10:20000 PrintData dom_info.dat update,dom_fitness,dom_depth,dom_sequence
+Between generations 10,000 and 20,000, append the specified information to the file dom_info.dat every ten generations. Specifically, the first column in the file would be update number, second is the fitness of the dominant genotype, followed by the depth in the phylogentic tree of the dominant genotype, and finally its genome sequence.
+
+[List of Actions](List-of-actions)
diff --git a/docs/documentation/Experiment-and-analysis-guides.md b/docs/documentation/Experiment-and-analysis-guides.md
new file mode 100644
index 0000000..33784c0
--- /dev/null
+++ b/docs/documentation/Experiment-and-analysis-guides.md
@@ -0,0 +1,2 @@
+* [[Example Configs]]
+* [[Creating a Flame Graph]]
diff --git a/docs/documentation/File-settings.md b/docs/documentation/File-settings.md
new file mode 100644
index 0000000..1c68694
--- /dev/null
+++ b/docs/documentation/File-settings.md
@@ -0,0 +1,13 @@
+This section relates Avida to other files that it requires.
+DATA_DIR |
+The name (or path) of the directory where output files generated by Avida should be placed. | +
EVENT_FILE |
+These settings indicate the names of all of the other configuration files used in an Avida run. See their documentation for more information about how to use these files. | +
This section covers all of the basic variables that describe the Avida run. You will probably not need to change these settings.
+ RANDOM_SEED |
+The random number seed initializes the random number generator. You should alter only this seed if you want to perform a collection of replicate runs. Setting the random number seed to zero (or a negative number) will base the seed on the starting time of the run -- effectively a random random number seed. In practice, you want to always be able to re-do an exact run in case you want to get more information about what happened. | +
POPULATION_CAP |
+The carrying capacity of the population (in number of organisms), removing random organisms when new organisms are born. Use 0 for no cap. | +
POP_CAP_ELDEST |
+Also applies a population cap, but removes the oldest organisms in the world. | +
Other general settings are described in the avida.cfg file itself: VERBOSITY, SPECULATIVE, and POP_CAP_ELDEST.
GRADIENT_RESOURCE gradient_resource_name[:options] {gradient_resource_name ...}
+GRADIENT_RESOURCE gradient_resource_name[:options] {gradient_resource_name ...}
+| Argument | +Description | +Default | +
|---|---|---|
| habitat | +Type of gradient resource. This determines most of the behaviors and effects of the resource.0 = gradient (standard or halo), 1 = hills, 2 = barriers, 3 = nests(hidden), 4 = dens(visible), 5 = predatory, > 5 = other gradient resource (used to differentiate different 'kinds' of food. | +0 | +
| refuge | +Is the resource a refuge (predation prevented)? | +0 | +
| peakx | +Initial x-coordinate of cone peak cell. Only affects non-moving peaks. For moving peaks, random coordinates within appropriate bounds will be used. | +0 | +
| peaky | +Initial y-coordinate of cone peak cell. | +0 | +
| height | +Height in terms of resource value of the cone at the peak center. This affects values along the slope of the cone where the value of any cell on the slope = height/(distance to center + 1). Note that the height of the plateau may supersede the height of the cone, lowering or raising all cell resource values within the plateau to the plateau value. Since slope is height/distance, for a cone having a plateau and a height set to 10, the plateau will be the region of cells 10 or fewer cells from the center. | +0 | +
| plateau | +Standard and Halo: Actual initial height in terms of resource levels wherever cone height is greater or equal to 1. This will supersede the cone height in eligible cells. A value of -1 turns this option off. Barriers and Hills: Height of the topographic feature. Apart from when plateau = 0 (off) and plateau > 0 (on), the plateau value has no effect outside of providing values for drawing/rendering. | +-1.0 | +
| spread | +Radius of the cone in terms of cells (i.e. extent of cone base). Because the spread starts counting the center cell as radius == 0, a spread of 4 will have 9 cells along the E-W/N-S axes (center cell + 4 cells either side). However, the height of this same resource would need to be == 5 to cover the same area with res value >= 1 (since we add 1 to distance from center cell for height). | +0 | +
| decay | +Number of updates until gradient resource is refreshed after an organism initially consumes resources in the cone. The refresh will occur even if the plateau has not been completely consumed. If decay = 0, the peak will be regenerated at a new random location every update, regardless of whether any has been consumed. If decay = 1, the cone will never actually be regenerated, but will move continuously. If decay > 1, resources move until some has been consumed. Movement will then halt until decay # updates (including current) have passed and the cone will then be regenerated in a new random location. | +1 | +
| min_x | +Leftmost coordinate of the rectangle in which resource will move randomly. The resource will stop moving left and bounce in a new random direction (inside the rectangle) when the edge of the plateau hits min_x. The case is the same for max_x, min_y, and max_y. | +0 | +
| max_x | +Rightmost coordinate of the rectangle in which resource will move randomly. | +0 | +
| min_y | +Topmost coordinate of the rectangle in which resource will move randomly. | +0 | +
| max_y | +Bottommost coordinate of the rectangle in which resource will move randomly | +0 | +
| threshold | +This set how other parts of avida interact with the resource, specifically look instructions (for now). In the look instructions, anything at or above this value will be treated and counted as an 'edible' cell. | +1.0 | +
| move_a_scaler | +Measure of resource movement smoothness taken from the variable "A" in equation 1 from Morrison and DeJong's DF-1 Algorithm. Values range from 1 to 4. Values from 1 to around 3 yield smooth movements, while larger values yield chaotic movement. In the current implementation of gradient resources, this value is largely irrelevant, but move_a_scaler = 1 means no movement and the common setting for moving peaks is 3.8. | +1.0 | +
| updatestep | +Standard and Halo: How many updates to wait until changing gradient resouce movement direction. Resources move in random directions, only changing course if they bounce or when updatestep is reached. Low updatestep numbers result in chaotic peak movements (and peaks tend not to travel very far overall). Barriers and Hills: How many updates to wait until regenerating the topographic features at new locations. Any value less than 1 (or >= the number of updates in the run) will turn off regeneration. | +1 | +
| halo | +Determines if this is a halo gradient. Instead of moving in a predetermined box, halo resources move randomly in an orbit around some fixed anchor cell. 1 if true, 0 if false. Halos do not use the bounded box (min_x, max_x, min_y, max_y) variables. Instead, they rely on the radius and width definitions to determine movement bounds. Note that orbit distances are in terms of cells, so orbits are rectangle in Avida. A diagonal line of cells count as the same distance as a straight line of cells. | +0 | +
| halo_inner_radius | +Halo: Closest (in number of cells) the inner edge of a plateau of a halo resource can be to the anchor cell. If no plateau is set, then this will just be the closest the center peak cell can be to the anchor, i.e. the minimum orbit. If plateau is set, minimum orbit will be halo_inner_radius + height (since radius of plateau = height). If you want a plateau of size 10 to be centered on the anchor point, you would need to set halo_inner_radius = -10. If you want the same peak to orbit the anchor point with no space between the plateau and the anchor, halo_inner_radius would be set to 10. +Hills: Closest any part of any generated hill can be to the given anchor point. For hill placement, the box defined by the anchor point, inner_radius, and hill radius define an exclusion zone for placement of the hill center point and build of the hill. | +0 | +
| halo_width | +How wide in cells the orbit is. The farthest the outer edge of the plateau can be from the anchor cell is halo_inner_radius + halo_width. If halo_width = 2 * height, halo resouces will travel in a fixed orbit, randomly changing orbit direction every updatestep. If halo_width > 2 * height, halo resources will travel along a random orbit between halo_inner_radius and halo_inner_radius + halo_width, changing EITHER orbit or orbit direction every updatestep. | +0 | +
| halo_anchor_x | +X-coordinate of the anchor cell. For hills this is simply the center point of any exclusion zone and does not otherwise determine where the hill is drawn. | +0 | +
| halo_anchor_y | +Y-coordinate of the anchor cell. | +0 | +
| move_speed | +How 'fast' the gradient moves in the grid. Since gradient resources are built on spatial resources and spatial resources are only checked once per update, move_speed actually determines how far, in number of cells, the cone is moved between updates, not in an update. Thus move_speed > 1 will cause peaks to 'jump' ahead. Move speeds less than 1 will 'pause' resources for the abs(move_speed) number of updates between moves. This can be valuable if organisms, due to combinations of genome length and time slicing, are slow to react to resource moves and cannot otherwise keep up with the resource. | +1 | +
| common | +In determining the cell values within the plateau, do we treat them as a common (= 1) resource, or as individual cells (= 0)? If common = 1, and any plateau cells are depletabled by organisms, at each update we look to see how much of the plateau was consumed, divide that by the number of cells in the plateau, subtract that amount from the plateau value at the beginning of the previous update (before depletion), and set all plateau cells to this new value. Thus, at the updates, the effects of depletion is spread out across all plateau cells. Peak height is then recalculated to reflect the change in this value and the entire cone is redrawn, while preserving the original extent of the plateau. If common = 0 resource depletions affect only individual plateau cells and the peak slopes are not changed. | +0 | +
| initial | +Initial value for all plateau cells. If set to -1 (default), initial cell values will be set == plateau. | +-1.0 | +
| plateau_inflow | +Inflow rate of resources within the plateau. This amount will be added to each cell in the plateau at each update, regardless of common setting. Maximum value for plateau cells (if set at >= 0) remains original plateau value. If common = 1, the inflow is added to the current peak height and height is reset to the new value. All values in the peak are then recalculated, but keeping the original extent of the plateau. Maximum value for height (for cone shape) remains capped at original height value. | +0.0 | +
| plateau_outflow | +Outflow rate of resource within the plateau. The quantity of resources = outflow * height will be removed from each cell in the plateau at each update, regardless of common setting. Minimum resulting value for plateau cells is 0. If common = 1, the outflow quantity is subtracted from the current peak height and height is reset to the new value. All values in the peak are then recalculated, but keeping the original extent of the plateau. Minimum resulting value for height (cone shape) is 0. | +0.0 | +
| cone_inflow | +Inflow rate of resources for individual cells in the cone. This amount will be added to each cell in the cone at each update. The value for a cell will never exceed that expected based on cone height and distance from center (that is, this is a refill rate as much as it is an inflow). Will not affect height of the cone (as in plateau_inflow) and will not affect any plateau cells (use plateau_inflow and/or gradient_inflow for that). | +0.0 | +
| cone_outflow | +Outflow rate for non-plateau cells | +0.0 | +
| gradient_inflow | +Inflow rate of resources for individual cells in the cone scaled by distance from peak center. This amount / (this_distance + 1) will be added to each cell in the cone at each update. The value for a cell will never exceed that expected based on cone height and distance from center (that is, this is a refill rate as much as it is an inflow). Will not affect height of the cone (as in plateau_inflow) and will not affect any plateau cells (use plateau_inflow for that). Can be combined with cone_inflow and cone_outflow and / or plateau_inflow and plateau_outflow. +To 'grow' a cone, set the height to spread + 1, add gradient inflow, set initial to 0, and set plateau to be max desired reachable height. Cells in the cone will 'grow' at different rates, with cell height growth stopping when the cell value reaches the plateau value. | +0.0 | +floor | +Minimum value for cells within the cone. Cells that would otherwise have lower values (based on distance from center) will be set to this value. Floor does not affect plateau cells. Rather, it is intended to keep values along the spread from dropping below 1 for experiments where cell values along the slopes would affect merit rewards. | +0.0 | + +
| count | +The number of hills or walls/barriers to generate. | +1 | +
| max_size | +The maximum wall size in number of blocks(cells) or maximum hill radius. Actual hill and wall sizes will be determined by a random number selected between min and max (inclusive), minus any blocks placed off-world or overlapping with other blocks of the same resource (or self for walls, if config = 0). | +1 | +
| min_size | +The minimum wall or hill size. | +1 | +
| config | +The orientation of the wall. 0 = random (all blocks placed randomly, but neighboring, relative to previous block), 1 = vertical (rand N or S from seed block), 2 = horizontal (rand E or W from seed block), 3 = vertical from seed (peakx, peaky) to S, 4 = horizontal from seed (peakx, peaky) to W.For hills, if config == 1, generate 1 hill at the peakx X peaky coordinates. | +0 | +
| resistance | +This is implemented as a simple way of impacting the speed with which orgs can move through/across a hill. On average, an org on a hill will have to execute a number of move instructions equal to the resistance setting to move one cell.Setting resistance to 0 for a wall allows orgs to pass through it (creating a linear landmark rather than a barrier). | +1.0 | +
GRADIENT_RESOURCE food1:height=10:spread=180:plateau=1:decay=1:move_a_scaler=3.8:updatestep=200:halo=1:halo_inner_radius=10:halo_anchor_x=189:halo_anchor_y=249:halo_width=20:move_speed=1+An example of a gradient which will initialize at 189, 249 and is bounded by a 200x200 cell box. The cone height is 20, but the radius is only 10 cells. The plateau is of height 2, and the resource moves only every 10000 updates. +
GRADIENT_RESOURCE nest1:peakx=189:peaky=249:height=20:spread=19:plateau=2:decay=1:min_x=125:max_x=375:min_y=125:max_y=375: +move_a_scaler=1:updatestep=10000+Examples of barrier resources. Both will create 5 randomly placed vertical or horizontal walls, each between 10 and 200 cells long. For each barrier instance, the initial 'seed' block will be placed in a random cell. Then the build direction (N or S for the first, E or W for the second) will be chosen and the next block placed in the corresponding neighboring cell until the (randomly chosen) target size is met or the edge of the world is reached. All walls will be dismantled and new sets generated every 250 updates. +
GRADIENT_RESOURCE vert_walls:habitat=2:plateau=1.5:updatestep=250:count=5:max_size=200:min_size=10:config=1+
GRADIENT_RESOURCE horiz_walls:habitat=2:plateau=1.5:updatestep=250:count=5:max_size=200:min_size=10:config=2+An example of a hill resource. This will draw 10 randomly placed hills every 1000 updates, with each individual hill having a radius between 50 and 125 cells. No hills will be drawn/placed within 10 cells of the center of the world (49, 49). When crossing any of these hills, an organism, on average, will have to take two steps for every one cell traversed. +
GRADIENT_RESOURCE hills:habitat=1:plateau=0.2:updatestep=1000:count=10:max_size=125:min_size=50:halo_inner_radius=10:halo_anchor_x=49:halo_anchor_y=49:resistance=2+ +
+
+ The following hand-written programs perform the various one- and
+ two-input logic operations. These programs appear to be the shortest
+ ones to perform these operations that do not depend on the initial
+ content of stacks and registers (whose initial contents are represented
+ by a '?' below). However, it has not been proven that these are the
+ shortest programs. None of these programs permit self-replication;
+ rather, they merely perform a calculation.
+
+
+
+
| ECHO + | ||||||
|---|---|---|---|---|---|---|
| # | Inst | AX | BX | CX | Stack | Output + |
| 1 | IO | ? | X | ? | ? | ? + |
| 2 | IO | ? | Y | ? | ? | X + + |
| + | ||||||
| NOT + | ||||||
| # | Inst | AX | BX | CX | Stack | Output + |
| 1 | IO | ? | X | ? | ? | ? + |
| 2 | push | ? | X | ? | X, ? | + |
| 3 | pop | ? | X | X | ? | + |
| 4 | nop-C | + | ||||
| 5 | nand | ? | ~X | X | ? | + |
| 6 | IO | ? | Y | X | ? | ~X + + |
| + | ||||||
| NAND + | ||||||
| # | Inst | AX | BX | CX | Stack | Output + |
| 1 | IO | ? | X | ? | ? | ? + |
| 2 | IO | ? | X | Y | ? | ? + |
| 3 | nop-C | + | ||||
| 4 | nand | ? | X nand Y | Y | ? | + |
| 5 | IO | ? | Z | Y | ? | X nand Y + + |
| + | ||||||
| OR_N + | ||||||
| # | Inst | AX | BX | CX | Stack | Output + |
| 1 | IO | ? | X | ? | ? | ? + |
| 2 | IO | ? | X | Y | ? | ? + |
| 3 | nop-C | + | ||||
| 4 | nand | ? | X nand Y | Y | ? | + |
| 5 | nand | ? | X or ~Y | Y | ? | + |
| 6 | IO | ? | Z | Y | ? | X or ~Y + + |
| + | ||||||
| AND + | ||||||
| # | Inst | AX | BX | CX | Stack | Output + |
| 1 | IO | ? | X | ? | ? | ? + |
| 2 | IO | ? | X | Y | ? | ? + |
| 3 | nop-C | + | ||||
| 4 | nand | ? | X nand Y | Y | ? | + |
| 5 | push | ? | X nand Y | Y | X nand Y, ? | + |
| 6 | pop | ? | X nand Y | X nand Y | ? | + |
| 7 | nop-C | + | ||||
| 8 | nand | ? | X and Y | X nand Y | ? | + |
| 9 | IO | ? | Z | X nand Y | ? | X and Y + + |
| + | ||||||
| OR + | ||||||
| # | Inst | AX | BX | CX | Stack | Output + |
| 1 | IO | ? | X | ? | ? | ? + |
| 2 | push | ? | X | ? | X, ? | + |
| 3 | pop | ? | X | X | ? | + |
| 4 | nop-C | + | ||||
| 5 | nand | ~X | X | X | ? | + |
| 6 | nop-A | + | ||||
| 7 | IO | ~X | Y | X | ? | X + |
| 8 | push | ~X | Y | X | Y, ? | + |
| 9 | pop | ~X | Y | Y | ? | + |
| 10 | nop-C | + | ||||
| 11 | nand | ~X | ~Y | Y | ? | + |
| 12 | swap | Y | ~Y | ~X | ? | + |
| 13 | nop-C | + | ||||
| 14 | nand | Y | X or Y | ~X | ? | + |
| 15 | IO | Y | Z | ~X | ? | X or Y + + |
| + | ||||||
| AND_N + | ||||||
| # | Inst | AX | BX | CX | Stack | Output + |
| 1 | IO | ? | X | ? | ? | ? + |
| 2 | IO | ? | X | Y | ? | ? + |
| 3 | nop-C | + | ||||
| 4 | nand | ? | X nand Y | Y | ? | + |
| 5 | nand | ? | X or ~Y | Y | ? | + |
| 6 | push | ~X | X or ~Y | Y | ~X or Y, ? | + |
| 7 | pop | ~X | X or ~Y | X or ~Y | ? | + |
| 8 | nop-C | + | ||||
| 9 | nand | ? | ~X and Y | X or ~Y | ? | + |
| 10 | IO | ? | Z | X or ~Y | ? | ~X and Y + + |
| + | ||||||
| NOR + | ||||||
| # | Inst | AX | BX | CX | Stack | Output + |
| 1 | IO | ? | X | ? | ? | ? + |
| 2 | push | ? | X | ? | X, ? | + |
| 3 | pop | ? | X | X | ? | + |
| 4 | nop-C | + | ||||
| 5 | nand | ~X | X | X | ? | + |
| 6 | nop-A | + | ||||
| 7 | IO | ~X | Y | X | ? | X + |
| 8 | push | ~X | Y | X | Y, ? | + |
| 9 | pop | ~X | Y | Y | ? | + |
| 10 | nop-C | + | ||||
| 11 | nand | ~X | ~Y | Y | ? | + |
| 12 | swap | Y | ~Y | ~X | ? | + |
| 13 | nop-C | + | ||||
| 14 | nand | Y | X or Y | ~X | ? | + |
| 15 | push | Y | X or Y | X | X or Y, ? | + |
| 16 | pop | Y | X or Y | X or Y | ? | + |
| 17 | nop-C | + | ||||
| 18 | nand | Y | X nor Y | X or Y | ? | + |
| 19 | IO | Y | Z | X or Y | ? | X nor Y + + |
| + | ||||||
| XOR + | ||||||
| # | Inst | AX | BX | CX | Stack | Output + |
| 1 | IO | ? | X | ? | ? | ? + |
| 2 | IO | ? | X | Y | ? | ? + |
| 3 | nop-C | + | ||||
| 4 | push | ? | X | Y | X, ? | + |
| 5 | nand | ? | X nand Y | Y | X, ? | + |
| 6 | swap | ? | Y | X nand Y | X, ? | + |
| 7 | nand | ? | X or ~Y | X nand Y | X, ? | + |
| 8 | swap | X or ~Y | ? | X nand Y | X, ? | + |
| 9 | nop-A | + | ||||
| 10 | pop | X or ~Y | X | X nand Y | ? | + |
| 11 | nand | X or ~Y | Y or ~X | X nand Y | ? | + |
| 12 | swap | X nand Y | Y or ~X | X or ~Y | ? | + |
| 13 | nop-C | + | ||||
| 14 | nand | X nand Y | X xor Y | X or ~Y | ? | + |
| 15 | IO | X nand Y | Z | X or ~Y | ? | X xor Y + + + |
| + | ||||||
| EQU + | ||||||
| # | Inst | AX | BX | CX | Stack | Output + |
| 1 | IO | ? | X | ? | ? | ? + |
| 2 | IO | ? | X | Y | ? | ? + |
| 3 | nop-C | + | ||||
| 4 | push | ? | X | Y | X, ? | + |
| 5 | nand | ? | X nand Y | Y | X, ? | + |
| 6 | swap | ? | Y | X nand Y | X, ? | + |
| 7 | nand | ? | X or ~Y | X nand Y | X, ? | + |
| 8 | swap | X or ~Y | ? | X nand Y | X, ? | + |
| 9 | nop-A | + | ||||
| 10 | pop | X or ~Y | X | X nand Y | ? | + |
| 11 | nand | X or ~Y | Y or ~X | X nand Y | ? | + |
| 12 | swap | X nand Y | Y or ~X | X or ~Y | ? | + |
| 13 | nop-C | + | ||||
| 14 | nand | X nand Y | X xor Y | X or ~Y | ? | + |
| 15 | push | X nand Y | X xor Y | X or ~Y | X xor Y, ? | + |
| 16 | pop | X nand Y | X xor Y | X xor Y | ? | + |
| 17 | nop-C | + | ||||
| 18 | nand | X nand Y | X equ Y | X xor Y | ? | + |
| 19 | IO | X nand Y | Z | X xor Y | ? | X equ Y + + |
This tutorial will walk you through the steps involved in creating a deme replication event. It assumes that you have basic familiarity with C++ and Avida-ish stuff. There are several different deme replication events. Currently, they include events such as replicate when the deme is full, when the corners are occupied, when a set number of resources has been amassed (the consume-res event). For this tutorial, we'll be using 'consume-res' as an example. To add your new event:Β
+Β Β DEME_TRIGGER_CONSUME_RESOURCES, Β // 10
+Define your 'trigger' event as part of the Replicate Demes action. To do that, in PopulationActions.cc go to the classΒ cActionReplicateDemes : public Action. Add the name of your trigger and a brief description to the comment:Β
+'consume-res' ...demes that have consumed a sufficienct amount of resources
+Then, add the same trigger to the end of the list of else if statements Β
+Β else if (in_trigger == "consume-res") m_rep_trigger = DEME_TRIGGER_CONSUME_RESOURCES
+Next, add the code that describes when your replication event will occur. In cPopulation.cc, locate the ReplicateDemes function:Β
+void cPopulation::ReplicateDemes(int rep_trigger, cAvidaContext& ctx)Β
+Within this function, add your new trigger both to the comments and to the switch statement. For example, for the 'consume-res' event the following line was added to the comment:Β
+Β 10:'consume-res' ...demes that have consumed a sufficienct amount of resources
+case DEME_TRIGGER_CONSUME_RESOURCES: {
+Β Β Β Β // check how many resources have been consumed by the deme
+Β Β Β Β if (source_deme.GetTotalResourceAmountConsumed() <
+Β Β Β Β Β Β m_world->GetConfig().RES_FOR_DEME_REP.Get()) {
+Β Β Β Β Β continue;
+Β }
+Note that this code is using information about the deme. Clearly, if your method needs information from the deme and that information doesn't exist, you'll also need to write some code to do that...Β
++
u 1:1:end ReplicateDemes consume-res
+COLOR_DIFF, COLOR_SAME, COLOR_NEG2, COLOR_NEG1, COLOR_POS1, COLOR_POS2, COLOR_MUT_POS, COLOR_MUT_NEUT, COLOR_MUT_NEG, and COLOR_MUT_LETHAL.
diff --git a/docs/documentation/Instruction-Set.md b/docs/documentation/Instruction-Set.md
new file mode 100644
index 0000000..9cc0ac6
--- /dev/null
+++ b/docs/documentation/Instruction-Set.md
@@ -0,0 +1,333 @@
+An instruction set is actually a whole set of configurations, usually contained in their own file and included in the avida.cfg file with #include INST_SET=instset.cfg.
+
+Instruction sets are actually part of the avida.cfg file. However, instead of writing the instruction set out in avida.cfg itself, which would be rather long and messy, each instruction set is placed in a separate file. A preprocessor include (of the form #include $filename) is then used to include each instruction set in avida.cfg. Multiple instruction sets may be included.
+
For example, to include the two instruction sets contained in the files instset-heads.cfg and instset-heads-sex.cfg, these lines are placed in avida.cfg: +
+
+#include instset-heads.cfg
+#include instset-heads-sex.cfg
+
You may optionally name each instruction set as you include it. This allows you to change which file the name refers to when running avida from the command line, using the -def option. The default avida.cfg contains this line:
+#include INST_SET=instset-heads.cfg
+
This means you may change which file INST_SET refers (for example, change it to instset-heads-sex.cfg) to on the command line like this:
+./avida -def INST_SET instset-heads-sex.cfg
+
In this case, INST_SET is simply a variable name with no special meaning. The line might just as easily been #include BOBS_YOUR_UNCLE=instset-heads.cfg
+
Organisms in an avida run may have different instruction sets. Therefore, it is necessary to specify the instruction used by each .org file. At the top of the .org file you must specify the instruction set with the #inst_set keyword, and the hardware type with the hw_type keyword. For example, default-heads.org starts with these two lines:
+
+#inst_set heads_default
+#hw_type 0
+
Note: the name of the instruction set may not be the same as the name of the file containing the instruction set. (Indeed, one file may contain multiple instruction sets.) The name of the instruction set is defined inside its .cfg file by the INSTSET keyword, which also defines the hardware type. + + + +
+
An instruction set consists of a name and hardware type, followed by a list of instructions that belong to +that instruction set, each of which may be followed by a series of options that +define how that instruction should be used. The exact format is as follows: +
+
+INSTSET instset-name:hw_type=$hardware_type
+INST inst-name[:options]
+...
+
Multiple instruction sets with unique names may be defined in the same file. All INST statements must follow the
+INSTSET statement defining the instruction set.
The following options may be specified (as name=value, separated by colons):
+
+
For example, to specify that the nand instruction is both twice as common and twice as expensive as other instructions, you would use this line:
+INST nand:redundancy=2:cost=2
+
+
+
+
+Below are the descriptions of the instructions turned on in the file +instset-classic.cfg. The one-letter codes are assigned +automatically to each instruction in the set, so if additional instructions +are turned on, the letters given below may no longer correspond to the +instructions they are presented with. If more than 26 instructions are in +a set, both lowercase and capital letters will be used, and then numbers. +Currently, no more than 62 distinct instructions will be represented by +unique symbols. +
++Most terminology below that may not be familiar to you has been given a +link to a file containing its definition. +
+ +nop-A (a), nop-B
+(b), and nop-C (c) are no-operation
+instructions, and will not do
+anything when executed. They will, however, modifiy the behavior of the
+instruction preceeding it (by changing the [CPU](Glossary-- CPU)
+component that it affects; see also
+nop-register notation and
+nop-head notation) or act as part
+of a label to denote positions in the
+genome.
+
+
+if-n-equif-lesspoppushswap-stkswapshift-rshift-linc and (m) decadd and (o) subnandIOh-alloch-divideh-copyh-searchmov-headjmp-headget-headif-labelset-flowAvida has the ability to allow organisms to uptake resources from the environment and keep them in a private store of "resource bins". These internal resources may then be used instead of the normal environmental resources to complete reactions. + +
Most configuration of internal resource use is done with config options in avida.cfg, all of which are found in the HOARD_RESOURCE_GROUP. Some more advanced uses require modifications to the environment file as well. There is also a family of instructions which allows organisms to manipulate resources. + +
Most internal resource code is protected by a guard to make sure it does not slow Avida down if internal resources are not being used. In order to use internal resources, you must change a line in avida.cfg: +
USE_RESOURCE_BINS 0+to +
USE_RESOURCE_BINS 1+ +
+ABSORB_RESOURCE_FRACTION .0025+This setting controls the fraction of the available environmental resource the organism may absorb. The default value is the same as the default value for the 'frac' reaction specification, so that an organism will remove the same amount of resource from the environment whether it is storing it or using it to complete a reaction. +
MAX_TOTAL_STORED -1+This setting defines a cap on the maximum total amount of internal resource an organism can store. The default is -1, indicating that there is no cap. + +
collect always affects a single resource. If there are no nops follwing it, it chooses randomly from all the resources. Increasing levels of specification narrow down the range of the resource spectrum from which it chooses randomly. For example, in a three-nop, nine-resource system, collect nop-A nop-B affects resource 1 (remember resource ids are 0-based), which is usually the resource tied to NOR. + +
+
+COLLECT_PROB_DIVISOR 1000+This setting defines the divisor for probabilistic collect instructions, which have a chance of (current level of resource) / COLLECT_PROB_DIVISOR of succeeding -- this chance is capped at 1. As it is a divisor, it should not be set to 0. + +
+
+
+
+COLLECT_SPECIFIC_RESOURCE 0+This setting determines which resource the collect-specific instruction affects. (Remember that resources are numbered from 0 in the order they appear in the environment file.) It also specifies which resource should be added to injected or newborn organisms if non-zero amounts are specified by RESOURCE_GIVEN_ON_INJECT or RESOURCE_GIVEN_AT_BIRTH. It should not be given a value outside of the range of resource ids. + +
+Every time the collect-specific-ratio instruction is executed, the organism executing it collects one of each resource not mentioned in the config setting and the amount specified after the colon for each other resource. (Remember that resources are numbered from 0 in the order they appear in the environment file - resource_index should not be a value outside of the range of resource ids). For instance, a config setting like this: +NON_1_RESOURCE_RATIOS resource_index1:amount, resource_index2:amount
+Would result in the organism collecting 1 unit of resource 0, 2 units of resource 1, .5 units of resource 3, and 1 unit of any additional resources. + +NON_1_RESOURCE_RATIOS 1:2, 3:.5
+USE_STORED_FRACTION 1.0+This setting controls the fraction of the internal resource that the organism will use to complete a reaction. By default this 1.0, meaning that the organism will use all the available internal resource to complete a reaction. As a fraction, this value should remain between 0.0 and 1.0. +
ENV_FRACTION_THRESHOLD 1.0+This setting controls how much of the available environmental resource the organism should consider when deciding which type of resource to use. By default it is set to 1.0, indicating that the organism should consider all the available environmental resource. As a fraction, this value should remain between 0.0 and 1.0 + +
+ENV_FRACTION_THRESHOLD 1.0+to +
ENV_FRACTION_THRESHOLD 0.0+As a precaution, you should also change the 'frac' specification of the REACTIONs in your environment file to be 0.0 (rather than the common .0025 or the default 1.0). + +
The most common source of internal resource is via collect or one of its variants, in most cases from the environment (but see collect-no-env-remove). However, an organism may also receive new internal resource when it is injected (if RESOURCE_GIVEN_ON_INJECT is set above 0) or when it is born (if RESOURCE_GIVEN_AT_BIRTH is set above 0). +
RESOURCE_GIVEN_ON_INJECT 0+This setting specifies the units of the resource given by COLLECT_SPECIFIC_RESOURCE that should be added to an organism when it is injected. The default is to add no resource. +
RESOURCE_GIVEN_AT_BIRTH 0+This setting specifies the units of the resource given by COLLECT_SPECIFIC_RESOURCE that should be added to an organism when it is born. The default is to add no resource. + +
+When an organism splits into two daughter organisms, each daughter gets half of the original internal resource store if SPLIT_ON_DIVIDE is set. (If it is set to 0, the resource disappears.) +
SPLIT_ON_DIVIDE 1+This setting determines whether the mother cell's resources should be split between its two daughter cells on division. It defaults to true; if set to 0 (false), the mother cell's internal resource simply disappears. This setting has not been tested with DIVIDE_METHODs other than 1. + +
+When an organism dies, its internal resources are returned to the environment if RETURN_STORED_ON_DEATH is set. +
RETURN_STORED_ON_DEATH+This setting determines whether an organsim's internal resources are returned to the environment when the organism dies. It defaults to true; if set to 0 (false), the resource simply disappears. This setting has not been tested with deaths not by old age or being overwritten. diff --git a/docs/documentation/Introduction-to-parasites.mediawiki b/docs/documentation/Introduction-to-parasites.mediawiki new file mode 100644 index 0000000..795b185 --- /dev/null +++ b/docs/documentation/Introduction-to-parasites.mediawiki @@ -0,0 +1,48 @@ +
This introduction assumes some basic knowledge about Avida. In particular, familiarity with the basic organism and hardware as described here will be very useful to have.
+With that said, parasites currently do not work in the default hardware but rather one that supports better threading capabilities β the TransSMT hardware. The differences arenβt huge, but they deserve their own documentation. Instead, I will just highlight major differences between the hardware types important for parasites, namely memoryspaces and threads.
+Memory spaces are regions of memory reserved for genetic instructions such as an individualβs genome. To access these memory spaces, organisms execute the Set-Memory instruction followed by one or more Nop instructions specifying which space to use. In this hardware, the genome copy produced during self-replication must also be in a seperate memory space, as well as any thread processes an individual spawns.
Threads in this hardware are distinct code sequences that are executed either in parallel, where all threads execute an instruction per CPU cycle awarded to an individual, or round-robin, where a single instruction from a single thread is exected per awarded CPU cycle and each thread executes in turn. The number of threads an organism is allowed to have, as well as how they are scheduled is controlled by the following config options in the avida.cfg file.
Parasites in Avida are almost identical to hosts, self-replicating by copying their genome instruction-by-instruction into a new memory space. However, instead of dividing this new genome off into the world, parasites attempt to infect a random organism in its hostβs neighborhood (globaly if BIRTH_METHOD=4 or WORLD_GEOMETRY=7, and honoring the WORLD_GEOMETRY if BIRTH_METHOD is set to any other value) with their offspring parasite genome, becoming a new thread on the host organism. Parasites attempt infection by calling the Inject instruction, which is also Nop-modified to identify the memory space the parasitic thread should occupy.
In order for infection to succede, the host must be able to accept a new thread in the memory space the parasite is attempting to occupy. This means the host must have fewer than MAX_CPU_THREADS and that the host has not used the memory space specified by the Inject instruction. More than one parasite per host is not currently supported, thus we typicaly set MAX_CPU_THREADS=2. We can eliminate the effect of host-parasite coevolution via memory space allocation and specification (and as any unforseen side-effects such as parasites overwriting host offspring when specificying a particular memory space) by giving parasites memory spaces entirely seperate from their hostβs (PARASITE_MEM_SPACES=1).
Parasites as well as hosts can perform logic tasks, and we can use their task-based phenotypes to implement additional mechanisms determining if infection will succeed or not. The config option INFECTION_MECHANISM already has several mechanisms implemented. The implemented options have the following behavior:
To have more control over how many CPU cycles a parasite steals from itβs host, PARASITE_VIRULENCE determines the probability that a CPU cycle will be given to the parasite. Thus, when this option is set to 1, the parasite is completely virulent and overtakes all of its hostβs CPU cycles. It is also possible to let the parasites evolve their own virulence by setting VIRULENCE_SOURCE=1, and choosing values for both VIRULENCE_MUT_RATE, which controls the probability of mutating a parasites virulence when a new parasite is born, and VIRULENCE_SD, which is the standard deviation of a normal distribution used to determine how much virulence changes when it mutates.
+
+
++
+
Β Depiction of a Host-Parasite Interaction
++
InjectParasite is typically called near the beginning of a run to infect a range of cells. It takes a parasite organism file, the memory space label, and the range of cells which should be infected.
PrintParasiteTasksData and PrintHostTasksData print the tasks performed by parasites and hosts respectively. Similarly, PrintHostPhenotypeData and PrintParasitePhenotypeData split up the phenotype data, such as the Shannon Diversity and Richness of unique host and parasite phenotypes.
+
A set of complete config files and ancestral organisms can be found here.
diff --git a/docs/documentation/List-of-actions.md b/docs/documentation/List-of-actions.md new file mode 100644 index 0000000..24ae0a1 --- /dev/null +++ b/docs/documentation/List-of-actions.md @@ -0,0 +1,1484 @@ +Generated Thu Mar 15 08:45:28 2012 by make_actions_html ++ SetGradientResource + <string env_string> +
+
+ Action designed to read in and process a line for ONE gradient resource,
+ formatted as if it were in the environment file.
+ This will change environmental settings for this one gradient resource on the fly.
+ You should create the resource in the environment file and only use this file to
+ change this resource.
+ Unlike with ChangeEnvironment, no resources other than the one specified in the event
+ will be affected.
+
+ SetGradientInflow + <string res_name> <double res_inflow> +
++ Set existing gradient resource plateau inflow rate to a new value, without redrawing + the entire resource. +
++ SetGradientOutflow + <string res_name> <double res_outflow> +
++ Set existing gradient resource plateau outflow rate to a new value, without redrawing + the entire resource. +
++ SetGradientConeInflow + <string res_name> <double res_inflow> +
++ SetGradientConeOutflow + <string res_name> <double res_outflow> +
++ SetGradientPlatInflow + <string res_name> <double res_inflow> +
++ SetGradientPlatOutflow + <string res_name> <double res_outflow> +
++ SetGradPlatVarInflow + <string res_name> <double mean> <double variance> <int type> +
++ Set existing gradient resource plateau inflow rate to a new value, without redrawing + the entire resource, based on a random number pull from normal distribution of this + mean and variance. As such, this uses a half normal or folded normal approach with + expected value = sigma * sqrt(2 /pi). + If type == 0, new inflow will be the random number pulled. + If type > 0, new inflow will be mean + abs(the random number pulled). + If type == 1, new inflow will be max (0, mean - abs(the random number pulled)). + If type == 2, new inflow will be max (0, mean + the random number pulled). +
++ SetPopCapEnforcement + [int cap=0] [int rate=1] +
++ Will set POPULATION_CAP to cap and begin killing orgs off at rate rate by killing rate # orgs + 1 every time a new org is born. + Accepts string args (e.g. SetPopCapEnforcement cap=0:rate=1). +
++ SetPredatoryResource + <string res_name> <double kill_odds> <double guarded_juvs_per_adult>double detection_prob> +
++ A gradient resource with teeth. If set in motion, will kill with prob kill_odds 1 random org + in each cell of plateau. If it passes over a den resource, will kill unguarded offspring with + probability kill_odds. If an org steps on the resource, the org is killed with probability + kill_odds. detection_prob sets the probability of orgs detecting the predator via look sensors. +
+MT_CONCURRENCY to the number
+of logical processors available to make use of all processor resources
+for these compuations.
++ AttackDen + [double probability=0.0] [int juvs_per_adult=1] +
++ Kills each unguarded juv in dens (habitat == 3 or 4) with set probability. juvs_per_adult sets + the ratio of guarding adults to juvs. E.g. if ratio is set to 5 and there are 2 guards and 12 + juveniles in a den, two random juveniles will be attacked with their probability of death at + the set probability. +
+competition_type controls how the fitnesses of multiple trials determine the overall fitness
+used for the competition: 0=geometric mean of fitnesses, 1=scaled geometric mean of fitnesses (the greatest fitness
+of each trial is scaled to 1.0 before taking the geometric mean), 2=arithmetic mean, 3=geometric mean plus
+rescales effective fitness values by the geometric mean of the difference from the top score and the median.Setting parents_survive to 1, causes the first copy of an organism that makes it into the new
+population to be the original (unmutated) parent organism.+ FlushTopNavTraceNo arguments
InjectRange 000-aaaaa.org 0 10Will inject 10 organisms into cells 0 through 9.InjectSequence ckdfhgklsahnfsaggdsgajfg 0 10 100Will inject 10 organisms into cells 0 through 9 with a merit of 100.+ PrintMiniTraces + [boolean random=0] [boolean save_dominants=0] [boolean save_groups=0] [boolean save_foragers=0] [int orgs_per=1] [int max_samples=0] [boolean print_genomes=0] [boolean initial] +
+Prints a condensed trace of execution during a lifetime. Who is traced is determined by arguements. + E.g. with the args save_dominants=1:orgs_per=2, at the specified update(s) a list is + created containing the two most abundant genotypes. The next offspring born to parents with those specified + genotypes will then be traced for their entire lifetimes. If save_foragers is set to 1, the list + would contain the two most abundant genotypes for EACH existing forager type. Multiple types can + be saved without duplicating traces. E.g. save_dominants=1:save_foragers=1:orgs_per=2 would + trace one org from each of the two most dominant genotypes and one org from each of the two most + common genotypes for each of the existing forager types if those genotypes were not also one of the + two most abundant overall. If max_samples is > 0, this will cap the total number of orgs traced with + priorities on fullfilling orgs_per quota for: dominants > forager types > group ids. +
+Setting random will look at current population, select individuals up to max_samples (without replacement) + record the sampled genotypes (one per individual, including genotype duplicates) and then trace the next orgs + born with those genotypes, removing the genotype instance from the 'to-do' list with each new trace. Random option + is not currently compatible with (will override) other save_ arguements or orgs_per. +
+Minitraces are currently only fully implemented for the experimental hardware and partially for + the SMT hardware because of differences in the way some minitrace variables are tracked by the + different hardware types. +
+Each call to PrintMiniTraces resets the genotype list, rather than appending to it. +
++ +
+Same general operation behavior as PrintMiniTraces but only saves executed instruction symbols along with + org id, genotype id, forager type, and birth and death updates. Microtraces map executions as 'what the org was trying + to do'. So, failed executions are recorded except when CPU costs are being paid. If CPU costs are being paid, we record + the execution when the instruction was submitted, not necessarily when it was actually executed. Each microtrace is + saved on a single line in microtrace.dat. +
+rand_pred and rand_prey are compatible with each other, building a single list of genotypes to trace based on + current genotypes in the population for each of the two general forager types (will generate a list of 2 X max_samples + if both arguements are used). +
+Each call to PrintMicroTraces appends to the genotype list, rather than replacing it (opposite of mini traces). +
+If next_prey or next_pred are used, the organisms born to parents with prey or predator + foraging targets will be traced, regardless of genotype, until the set arg number have been traced (requested number will + be replaced, not appended to, by subsequent event calls).
++
+ +Tests all demes in a population and replicates those wherein a specific trigger condition has been met. The available triggers are: +
+ Record and print some nav data up to first reproduction for best of orgs alive now, including trace execution, + locations, and facings. Will print these data for the org among those with the highest reaction achieved By + time of reproduction in shortest amount of time (as measured by cycles). Will print nothing if any of the + candidate orgs are still alive when avida exits and no FlushTopNavTrace events were called. +
+ + ++ LoadPopulation + <cString fname> [int update=-1] [int cellid_offset=0] [int lineage_offset=0] [bool load_groups=0] [bool load_birth_cells=0] [bool load_avatars=0] [bool load_rebirth] +
+
+ Sets up a population based on a save file such as written out by
+ SavePopulation. It is also possible to append a history file to the
+ save file, in order to preserve the history of a previous run.
+ update allows user to set the current update number to a new value
+ load_groups allows users to load population files containing individual
+ group ids (opinions) and forager types (aka saved populations with save_groups = 1)
+ load_birth_cells allows users to drop each org into it's original birth cell. This
+ can be important for populations in spatial environments where state information
+ would have been collected as the org moved around the world.
+ e.g to load a population with birth cells and group ids, but without cell, lineage, or update offsets:
+ i LoadPopulation -1 0 0 1 1 0
+ load_rebirth will override load_groups, load_birth_cells, load avatars and inject orgs into their saved birth cells,
+ put avatars in their birth cells (if avatars are on), assign parent's merit to org (if inherit merit is on) and assign the
+ parent's forage target if the parent was a 'teacher'
+ i LoadPopulation -1 0 0 0 0 0 1
+
class cActionMyAction : public cAction
+{
+ private:
+ // Private data members for this action
+ public:
+ cActionMyAction(cWorld* world, const cString& args) : cAction(world, args) { ; }
+
+ static const cString GetDescription() { return "Arguments: My Arguments"; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ //Perform whatever processing is needed when the action is triggered.
+ }
+};
+action_lib->Register<cActionMyAction>("MyAction");
+ These settings control how and when mutations occur in organisms. The array of options is dizzying, but only the most commonly used are detailed here. Except that POINT_MUT_PROB isn't actually commonly used.
POINT_MUT_PROB |
+Point mutations (sometimes referred to as "cosmic ray" mutations) occur every update; the rate set here is a probability for each site that it will be mutated each update. In other words, this should be a very low value if it is turned on at all. If a mutation occurs, that site is replaced with a random instruction. In practice this also slows Avida down if it is non-zero because it requires so many random numbers to be tested every update. | +
COPY_MUT_PROB |
+The copy mutation probability is tested each time an organism copies a single instruction. If a mutation occurs, a random instruction is copied to the destination. In practice this is the most common type of mutations that we use in most of our experiments. The default value is 0.0075, but this is actually higher than you want to use; it is designed to produce pretty results when showing off the viewer. The value we commonly use for our experiments is 0.0025. |
+
DIV_INS_PROB |
+These probabilities are tested once per gestation cycle (when an organism is first born) at each position where an instruction could be inserted or deleted, respectively. Each of these mutations change the genome length. Deletions just remove an instruction while insertions add a new, random instruction at the position tested. Multiple insertions and deletions are possible each generation. By default these mutations are turned off. | +
DIVIDE_MUT_PROB |
+Divide mutation probabilities are tested when an organism is being divided off from its parent. If one of these mutations occurs, a random site is picked for it within the genome. At most one divide mutation of each type is possible during a single divide. By default, DIVIDE_MUT_PROB is turned off, and both DIVIDE_INS_PROB and DIVIDE_DEL_PROB are set to 0.05, which is a value we often use in our experiments. If you want your organisms never to change in length, obviously, you should turn these insertion and deletion mutations off! (This is not the only thing you need to do; see Fixed-Length Organisms.) |
+
COPY_INS_PROB, COPY_DEL_PROB, COPY_UNIFORM_PROB, COPY_SLIP_PROB, DIV_MUT_PROB, DIV_UNIFORM_PROB, DIVIDE_UNIFORM_PROB, DIVIDE_SLIP_PROB, DIVIDE_POISSON_MUT_MEAN, DIVIDE_POISSON_INS_MEAN, DIVIDE_POISSON_DEL_MEAN, DIVIDE_POISSON_SLIP_MEAN, INJECT_INS_PROB, INJECT_DEL_PROB, INJECT_MUT_PROB, SLIP_FILL_MODE, SLIP_COPY_MODE, PARENT_MUT_PROB, SPECIAL_MUT_LINE, META_COPY_MUT, META_STD_DEV, and MUT_RATE_SOURCE. Whew.
diff --git a/docs/documentation/Mutations-reversion-settings.md b/docs/documentation/Mutations-reversion-settings.md
new file mode 100644
index 0000000..287b3eb
--- /dev/null
+++ b/docs/documentation/Mutations-reversion-settings.md
@@ -0,0 +1,17 @@
+This section covers tests that are (mostly) very CPU intensive, but allow for Avida experiments that would not be possible in any other system. Basically, each time a mutation occurs, we can run the resulting organism in a test CPU, and determine if that effect of the mutation was lethal, detrimental, neutral, or beneficial. This section allows us to act on this. (Note that as soon as anything here is turned on, the mutations need to be tested. Turning multiple settings on will not cause additional speed decrease)
+ REVERT_FATAL |
+When a mutation occurs of the specified type, the number listed next to that entry is the probability that the mutation will be reverted. That is, the child organism's genome will be restored as if the mutation had never occurred. This allows us both to manually manipulate the abundance of certain mutation types, or to entirely eliminate them. | +
STERILIZE_FATAL |
+The sterilize options work similarly to revert; the difference being that an organism never has its genome restored. Instead, if the selected mutation category occurs, the child is sterilized so that it still takes up space, but can never produce an offspring of its own. | +
STERILIZE_UNSTABLE |
+If this toggle is set, organisms must be able to produce exact copies of themselves or else they are sterilized and cannot produce any offspring. An organism that naturally (without any external effects) produces an inexact copy of itself is said to have implicit mutations. If this flag is set, explicit mutations (as described in the mutations section above) can still occur. This particular setting does not seem to be terribly CPU intensive. You must turn this setting on to ensure fixed-length organisms. | +
| Keyword | Description |
|---|---|
update | Current Update |
sub_update | Instructions executed within update |
generation | Average Generation in Population |
entropy | Genotype Entropy (Diversity) |
species_entropy | Species Entropy (Diversity) |
energy | Average Inferiority (Energy) |
dom_merit | Ave Merit of Dominant Genotype |
dom_gest | Ave Gestation Time of Dominant Genotype |
dom_fitness | Ave Fitness of Dominant Genotype |
dom_repro | Ave Repro-Rate of Dominant Genotype |
dom_length | Genome Length of Dominant Genotype |
dom_copy_length | Copied Length of Dominant Genotype |
dom_exe_length | Executed Length of Dominant Genotype |
dom_id | ID of Dominant Genotype |
dom_name | Name of Dominant Genotype |
dom_births | Birth Count of Dominant Genotype |
dom_breed_true | Breed-True Count of Dominant Genotype |
dom_breed_in | Breed-In Count of Dominant Genotype |
dom_breed_out | Breed-Out Count of Dominant Genotype |
dom_num_cpus | Abundance of Dominant Genotype |
dom_depth | Tree Depth of Dominant Genotype |
dom_sequence | Sequence of Dominant Genotype |
num_births | Count of Births in Population |
num_deaths | Count of Deaths in Population |
breed_in | Count of Non-Breed-True Births |
breed_true | Count of Breed-True Births |
bred_true | Count of Organisms that have Bred True |
num_cpus | Count of Organisms in Population |
num_genotypes | Count of Genotypes in Population |
num_threshold | Count of Threshold Genotypes |
num_species | Count of Species in Population |
thresh_species | Count of Threshold Species |
num_lineages | Count of Lineages in Population |
num_parasites | Count of Parasites in Population |
num_no_birth | Count of Childless Organisms |
tot_cpus | Total Organisms ever in Population |
tot_genotypes | Total Genotypes ever in Population |
tot_threshold | Total Threshold Genotypes Ever |
tot_species | Total Species ever in Population |
tot_lineages | Total Lineages ever in Population |
ave_repro_rate | Average Repro-Rate (1 / Gestation) |
ave_merit | Average Merit |
ave_age | Average Age |
ave_memory | Average Memory Used |
ave_neutral | Average Neutral Metric |
ave_lineage | Average Lineage Label |
ave_gest | Average Gestation Time |
ave_fitness | Average Fitness |
ave_gen_age | Average Genotype Age |
ave_length | Average Genome Length |
ave_copy_length | Average Copied Length |
ave_exe_length | Average Executed Length |
ave_thresh_age | Average Threshold Genotype Age |
ave_species_age | Average Species Age |
max_fitness | Maximum Fitness in Population |
max_merit | Maximum Merit in Population |
BIRTH_METHOD |
+The birth method sets how the placement of a child organism is determined. Currently, there are six ways of doing this -- the first four (0-3) are all grid-based (offspring are only placed in the immediate neighborhood), and the last two (4-5) assume a well-stirred population. In all non-random methods, empty sites are preferred over replacing a living organism. See the avida.cfg file itself for details. | +
DEATH_METHOD |
+By default, replacement is the only way for an organism to die in Avida. However, if a death method is set, organisms will die of old age. In method one, organisms will die when they reach the user-specified age limit. In method 2, the age limit is a multiple of their length, so larger organisms can live longer. | +
ALLOC_METHOD |
+During the replication process in the default virtual CPU, parent organisms must allocate memory space for their child-to-be. Before the child is copied into this new memory, it must have an initial value. Setting the alloc method to zero sets this memory to a default instruction (typical nop-A). Mode 1 leaves it uninitialized (and hence keeps the contents of the last organism that inhabited that space; if only a partial copy occurs, the child is a hybrid if the parent and the dead organism, hence the name necrophilia). Mode 2 just randomizes each instruction. This means that the organism will behave unpredictably if the uninitialized code is executed. | +
DIVIDE_METHOD |
+When a divide occurs, does the parent divide into two children, or else do we have a distinct parent and child? The latter method will allow more age structure in a population where an organism may behave differently when it produces its second or later offspring. | +
GENERATION_INC_METHOD |
+The generation of an organism is the number of organisms in the chain between it and the original ancestor. Thus, the generation of a population can be calculated as the average generation of the individual organisms. When a divide occurs, the child always receives a generation one higher than the parent, but what should happen to the generation of the parent itself? In general, this should be set the same as divide method. | +
DIVIDE_FAILURE_RESETS, PREFER_EMPTY, ALLOW_PARENT, DISPERSAL_RATE, DEATH_PROB, AGE_LIMIT, AGE_DEVIATION, EPIGENETIC_METHOD, RESET_INPUTS_ON_DIVIDE, INHERIT_MERIT, and INHERIT_MULTITHREAD.
diff --git a/docs/documentation/Resource-hoarding-settings.md b/docs/documentation/Resource-hoarding-settings.md
new file mode 100644
index 0000000..09abc9e
--- /dev/null
+++ b/docs/documentation/Resource-hoarding-settings.md
@@ -0,0 +1,5 @@
+These settings control internal resources for organisms: how much can be collected at once, limitations on the amount that can be stored, how the internal resources are used to acquire task rewards, and the internal resource state of new organisms. Details are available in the avida.cfg file itself.
+
+For more information on resource uptake, see Internal Resources: an explanation and guide to use.
+
+See avida.cfg for these settings: USE_RESOURCE_BINS, ABSORB_RESOURCE_FRACTION, MULTI_ABSORB_TYPE, MAX_TOTAL_STORED, USE_STORED_FRACTION, ENV_FRACTION_THRESHOLD, RETURN_STORED_ON_DEATH, SPLIT_ON_DIVIDE, COLLECT_SPECIFIC_RESOURCE, RESOURCE_GIVEN_ON_INJECT, and RESOURCE_GIVEN_AT_BIRTH.
diff --git a/docs/documentation/Sample-analyze-programs.mediawiki b/docs/documentation/Sample-analyze-programs.mediawiki
new file mode 100644
index 0000000..e8d4699
--- /dev/null
+++ b/docs/documentation/Sample-analyze-programs.mediawiki
@@ -0,0 +1,8 @@
+Example analyze programs, with explanations.
+
+* [[Analyze Mode : Working with Batches|Working With Batches]]
+* [[Analyze Mode : Testing a Genome Sequence|Testing a Genome Sequence]]
+* [[Analyze Mode : Using Variables|Using Variables]]
+* [[Analyze Mode : Finding Lineages|Finding Lineages]]
+* [[Analyze Mode : Building Your Own Commands|Building Your Own Commands]]
+* [[Analyze Mode : Try It Yourself Exercises|Try It Yourself Exercises]]
diff --git a/docs/documentation/Setting-up-fixed-length-organisms.mediawiki b/docs/documentation/Setting-up-fixed-length-organisms.mediawiki
new file mode 100644
index 0000000..2330101
--- /dev/null
+++ b/docs/documentation/Setting-up-fixed-length-organisms.mediawiki
@@ -0,0 +1,21 @@
+In almost all of our experiments, organisms that are all the same length are easier to analyze. We are often willing to be a little less natural to be much more understandable! Here are the avida.cfg settings you will need to change from the default:
+
+DIVIDE_INS_PROB and DIVIDE_DEL_PROB |
+Insertion and deletion mutations should be turned off; change these settings to 0.0. | +
OFFSPRING_SIZE_RANGE |
+Offspring should be exactly the same size as their parents; change this setting to 1.0 | +
STERILIZE_UNSTABLE option, organisms may have bizarre implicit mutations which break the assumptions of this easy alignment.
+
+STERILIZE_UNSTABLE |
+Sometimes organisms have messed-up reproduction cycles that actually causes them to grow or shrink by copying an instruction multiple times or skipping over it entirely. These are not insertion and deletion caused by the process of division, but inherent in the organism's copy loop, so they are not turned off when you turn off DIVIDE_INS_PROB and DIVIDE_DEL_PROB. Avida can, however, check for organisms that are not able to make perfect copies of themselves (i.e. before mutations are imposed) and sterilize them so they do not produce offspring, and this is the setting that turns that checking on. Change it to 1, i.e. "yes". |
+
These settings control how Avida monitors and deals with genotypes in the Test CPU.
+THRESHOLD |
+For some statistics, we only want to measure organisms that we are sure are alive, but its not worth taking the time to run them all in isolation, without outside effect (and in some eco-system situations that isn't even possible!). For these purposes, we call a genotype "threshold" if there have ever been more than a certain number of organisms of that genotype. A higher number here ensures a greater probability that the organisms are indeed "alive". | +
TEST_CPU_TIME_MOD |
+Many of our analysis methods require that we be able to run organisms in isolation. Unfortunately, some of these organisms we test might be non-viable. At some point, we have to give up the test and label it as non-viable, but we can't give up too soon or else we might miss a viable, though slow, replicator. This setting is multiplied by the length of the organism's genome in order to determine how many CPU-cycles to run the organism for. A setting of 20 effectively means that the average instruction must be executed twenty times before we give up. In practice, most organisms have an efficiency here of about 5, so 20 works well, but for accurate tests on some pathological organisms, we will be required to raise this number. | +
The viewer has a number of one character commands that can be typed while the program is running. Often the most common commands are shown on the screen between square brackets (for example [Q]). A list of the most common commands:
+Available key strokes are shown on the screen (note that the number of keys at the top screen will vary based on the width of the screen):
+
Draft Documentation based on: "Avida User's Manual" C. Ofria, C.T. Brown, and C. Adami in Introduction to Artificial Life by C. Adami:
+For the most part the text interface to Avida is simple and straightforward to use; most of the options available are listed on the screen. For example at all times there is a menu bar at the top of the screen which lists the current update and the keys to press to go to any of the most used Avida screens. These sections further explain each screen:
+This screen displays all of the current statistics about the ongoing run. A typical snapshot of the screen looks like this:
+
Starting at the upper left column of the screen the first block of statistics describes the current state of the soup. These statistics are defined as follows:
+To the right of the soup status column we have some information about the dominant genotype. This section simply lists the name of this genotype, its ID, its Species ID and its age (how many updates it has existed for). The first three of these statistics are purely for identification purposes.
+On the right side of the screen more statistics are given for a number of common measurements on the dominant genotype as well as the average across all genotypes.
+In the middle left side of the screen we have information about the various taxonomic levels in Avida; we give the current abundance of each in the Current column, the total number of each that have existed over the entire run in the Total column, the average number of updates each have existed in the Ave Age column and finally the entropy of each in the Entropy column.
+Finally along the bottom of this screen we list the total number of organisms which have completed each of the assortment of tasks available in Avida. These numbers reflect only those organisms which have actually finished the task so even if every organism in the soup is capable of completing a task not all of them may be listed because the newborns would not have finished it for the first time.
+This screen is a histogram of the most abundant genotypes or species (use '
+
The first number here represents the fitness of the organism; this is the relative replication rate as compared to the other organisms in the population.
+Next comes the name of the genotype (For example 096-aaacf). This is an identifier for the genotype and the name of the file it will be saved under if it is extracted. The number portion (before the dash) of the name is the length of the code for that genotype and the letter sequence after the dash gives a unique identifier for it. These are never repeated throughout a single run.
+The repeated '#' after the name is the actual histogram; the number of characters which appear here is the relative current abundance of the genotype This allows quick recognition of which genotypes are dominant in the soup.
+Finally each line ends with a number which is the exact abundance of organisms currently within this genotype.
+If species information is being recorded (i.e. the SPECIES_RECORDING flag in the avida.cfg file is set to 1 or 2) the Genotype Abundance and Species Abundance Views might look like:
+
Notice that the '#' have been replaced with letters that represent the species of this genotype so any two lines with the same letter are of the same species.
+
This screen shows reactions and resources that are defined in the environment.cfg file. An example of the Reaction View:
+
One the left side of the main screen is a list of all the defined reactions. To the right is the number of organisms that have completed this reaction. Using the up and down arrow keys one of the reactions is highlighted. If there are any resources associated with the selected reaction they are displayed in the bottom pane.
+The Resource View is similar:
+
In this case the resource names are shown with the inflow amount, outflow rate and total quantity of that resource in the environment. The reaction(s) associated with this resource are shown in the bottom pane.
+This screen lists all of the options which are both currently available and were used to initialize this run. A typical screen looks like:
+
The upper left corner of this screen gives information about the active genotype in the soup and the remainder of the upper portions of the screen list values from the avida.cfg file and what they were initialized to.
+The lower part of the screen (within a box) shows the special options available to the user They are:
+[H]istogram Screen: This will go to the histogram screen described above.
+[B]lank Screen: This option will clear the screen making avida run marginally faster (since it will not be wasting much CPU time on the display).
+[R]edraw Screen: If the screen gets garbled this will erase it and refresh all text which is supposed to appear.
+[C]hoose New CPU: This option will put avida in map screen with the cursor on the screen Position the cursor over the CPU you would like to select and press enter. Additionally in the Windows version of avida the mouse can be used to select CPUs while in this screen. A single click highlights the CPU targeted and a double click selects it as the new active CPU and exits from this screen. The selected CPUs inner workings and genome can then be viewed in the Zoom screen (see below).
+[E]xtract organism: This will save the genotype of the active organism (the one currently selected) to a file by the same name as the genotype An extracted organism will include all of its statistics as comments (gestation time fitness tasks completed etc) and can be loaded into another soup without modifying the file.
+[P]ause: Freezes activity in the soup but still allows navigation through the interface and examination of the soup. Additionally many screens have additional options when the soup is paused.
+[N]ext Update: When paused this will advance the soup a single update.
+This screen contains all of the information about the state of the active CPU has three views (CPU Stats Zoom, Component Zoom and Genotype Zoom). This screen is especially useful while avida is paused The space bar will cause the active organism to advance a single instruction and the return key will cause it to advance a full update In this way the execution of the organism can be fully examined.
+Here is a typical screen shot:
+
The column on the left of the screen gives all of the current statistics for this CPU and the right of the screen contains information about the actual hardware in the CPU; the memory the stack the registers and the I/O buffers. The execution statistics recorded here are:
+
This view consists of a number of panes that can be accessed by using the TAB key.
+The top left pane shows the genome of the current organism. The number at the top box shows how many instructions are in the memory. The bottom box shows the individual instructions, if they are executate or were copied, and the location of the flow, write and read heads. Instructions can be edited here as well.
+The top middle pane shows a miniature version of the map view around the current organism.
+The bottom left pane shows the content of the registers, the Stack and the input values used by the organism.
+The bottom right pane shows general information atou the organism
+
The Map screen displays the spatial representation of the population of organisms in Avida. The grid itself is toroidal and typically will not fit entirely on the screen. You can use the arrow keys to adjust which part of the map appears on the screen. (On computers using a "curses" interface the arrow keys will often not function properly; instead, you can use the number keys 8, 2, 4 and 6 to move up, down, left and right respectively.) You reach the Map Screen by pressing the 'M' key.
+Here is an example map screen (showing genotype view on a color terminal):
+
Many different features can be displayed by the different map views. You can cycle through these views with the less-than and greater-than keys (< and >), as shown at the bottom-right of the map screen.
+Genotype View: This view of displays the genotype of the organism at each location. Each organism is displayed as a hash mark ('#'); organisms with the same genotype have the same "color". (Hash marks might be bold; the bold version of a color represents a different genotype than the not-bold version. The bold and not-bold genotypes are not related in any particular way -- we're just using the bold versions as a way to get more "colors".)
+As long as there are enough colors, each genotype has its own color, no matter how many or how few organisms have that genotype. When there are more genotypes than colors, the most abundant genotypes get their own colors, and all other genotypes are represented by a white not-bold hash mark (or by '+' if you cannot display color).Β Which color is marking a genotype doesn't have any meaning at all.Β (You can see the fitness, id, hash mark, and number of organisms for each of the most-abundant genotypes on the Histogram Screen, which you can reach by pressing the 'H' key.)
+Breed True View: This view simply displays a bold or not-bold hash mark ('*' or '-' if you can't display colors) for each organism, indicating whether it is an exact copy of its mother (bold white hash mark, or '*') or not (normal white hash mark, or '-').
+Parasite View: This view displays a bold or not-bold white hash mark ('*' or '-' if you can't display color) for each organism, indicating whether it is a parasite (bold white hash mark, or '*') or not (normal white hash mark, or '-').
+Forager View: If you know what this view shows, please edit this page!
+Avatar View: If you know what this view shows, please edit this page!
+Territory View: If you know what this view shows, please edit this page!
+Mutation View: This view displays a bold or not-bold white hash mark ('*' or '-' if you can't display color) for each organism, indicating whether it has been hit by mutations (bold white hash mark, or '*') or not (normal white hash mark, or '-').
+Thread View: This view displays the number of the thread that each organism is currently executing. For runs where organisms have only one thread (which is typical), all the numbers will be 1.
+Modified View: If you know what this view shows, please edit this page!
+Lineage View: This view displays the lineage of the organism at each location; each color corresponds to a single lineage. (Presumably the choice of colors and what happens when there are more lineages than colors is very similar to the way colors are handled in Genotype View.)
+ +This screen is a histogram of the most abundant genotypes or species (use '
+
The first number here represents the fitness of the organism; this is the relative replication rate as compared to the other organisms in the population.
+Next comes the name of the genotype (For example 096-aaacf) This is an identifier for the genotype and the name of the file it will be saved under if it is extracted The number portion (before the dash) of the name is the length of the code for that genotype and the letter sequence after the dash gives a unique identifier for it These are never repeated throughout a single run.
+The repeated '#' after the name is the actual histogram; the number of characters which appear here is the relative current abundance of the genotype This allows quick recognition of which genotypes are dominant in the soup.
+Finally each line ends with a number which is the exact abundance of organisms currently within this genotype.
+If species information is being recorded (i.e. the SPECIES_RECORDING flag in the avida.cfg file is set to 1 or 2) the Genotype Abundance and Species Abundance Views might look like:
+
Notice that the '#' have been replaced with letters that represent the species of this genotype so any two lines with the same letter are of the same species.
+
These settings describe exactly what an update is, and how CPU time is allocated to organisms during that update.
+AVE_TIME_SLICE |
+This sets the average number of instructions an organism should execute each update. Organisms with a low merit will consistently obtain fewer, while organisms of a higher merit will receive more. | +
SLICING_METHOD |
+This setting determines the method by which CPU time is handed out to the organisms. Method 0 ignores merit, and hands out time on the CPU evenly; each organism executes one instruction for the whole population before moving onto the second. Method 1 is probabilistic; each organism has a chance of executing the next instruction proportional to it merit. This method is slow due to the large number of random values that need to be obtained and evaluated (and it only gets slower as merits get higher). Method 2 is fully integrated; the organisms get CPU time proportional to their merit, but in a fixed, deterministic order. | +
BASE_MERIT_METHOD |
+This setting determines the base value of an organism's merit. Merit is typically proportional to genome length otherwise there is a strong selective pressure for shorter genomes (shorter genome => less to copy => reduced copying time => replicative advantage). Unfortunately, organisms will cheat if merit is proportional to the full genome length -- they will add on unexecuted and uncopied code to their genomes creating a code bloat. This isn't the most elegant fix, but it works. | +
MAX_LABEL_EXE_SIZE |
+Labels are sequences of nop (no-operation) instructions used only to modify the behavior of other instructions. Quite often, an organism will have these labels in their genomes where the nops are used by another instruction, but never executed directly. To represent the executed length of an organism correctly, we need to somehow count these labels. Unfortunately, if we count the entire label, the organisms will again "cheat" artificially increasing their length by growing huge labels. This setting limits the number of nops that are counted as executed when a label is used. | +
MAX_CPU_THREADS |
+Determines the number of simultaneous processes that an organism can run. That is, basically, the number of things it can do at once. This setting is meaningless unless threads are supported in the virtual hardware and the instructions are available within the instruction set. | +
SLICING_BURST_SIZE, BASE_CONST_MERIT, MERIT_BONUS_INST, MERIT_BONUS_EFFECT, FITNESS_VALLEY, FITNESS_VALLEY_START, FITNESS_VALLEY_STOP, DEFAULT_BONUS, MERIT_DEFAULT_BONUS, MERIT_INC_APPLY_IMMEDIATE, TASK_REFRACTORY_PERIOD, FITNESS_METHOD, FITNESS_COEFF_1, FITNESS_COEFF_2, THREAD_SLICING_METHOD, NO_CPU_CYCLE_TIME, PRECALC_PHENOTYPE, FASTFORWARD_UPDATES, FASTFORWARD_NUM_ORGS, and GENOTYPE_PHENPLAST_CALC.
diff --git a/docs/documentation/Topology-settings.md b/docs/documentation/Topology-settings.md
new file mode 100644
index 0000000..d2fb7f3
--- /dev/null
+++ b/docs/documentation/Topology-settings.md
@@ -0,0 +1,12 @@
+This section covers all of the basic topology variables that describe the structure of the world.
+
+ WORLD_X |
+The settings determine the size of the Avida grid that the organisms populate; the world consists of WORLD_X * WORLD_Y cells. In mass action mode the shape of the grid is not relevant, only the number of organisms that are in it. |
+
WORLD_GEOMETRY, SCALE_FREE, SCALE_FREE_ALPHA, and SCALE_FREE_ZERO_APPEAL.
diff --git a/docs/documentation/Using-mating-types-(separate-sexes).mediawiki b/docs/documentation/Using-mating-types-(separate-sexes).mediawiki
new file mode 100644
index 0000000..f158d47
--- /dev/null
+++ b/docs/documentation/Using-mating-types-(separate-sexes).mediawiki
@@ -0,0 +1,66 @@
+Although by default, reproduction in Avida is asexual, Avida can be configured to allow organisms to reproduce with sexual reproduction. By default, when sexual reproduction is turned on, any organism can mate with any other organism. However, Avida is also capable of sexual reproduction with two distinct mating types (e.g., males and females), mimicking the mating systems found in many biological organisms, in which only matings between opposite mating types are successful. (Note: this page is intended as an overview of how to implement these distinct mating types and their associated configuration options, not as an exhaustive guide to all of the other options involved in sexual reproduction in general).
+
First, you will need to turn on mating types in avida.cfg:
MATING_TYPES 1
However, this change by itself is not enough. You will also need to modify your instruction set so that the organisms can set their mating types, by adding the following two instructions to your instruction set:
+INST set-mating-type-male
INST set-mating-type-female
Once an organism sets its mating type, it is irreversible -- repeated execution of a different set-mating-type-X instruction will fail. If you want your organisms to be able to change their mating type during their lifetime, you can add another instruction that lets them de-differentiate, after which they can re-set their mating type to something else:
+INST set-mating-type-juvenile
Then, you also need to make sure that your organisms are using the proper instruction to divide, or else their mating types may not be checked properly. So you should replace the divide instruction in your instruction set (probably h-divide or divide-sex) with div-sex-mating-type.
While we're in the instruction set, you might want to consider adding instructions allowing organisms to conditionally execute instructions based on their phenotypic sex (otherwise, they have no real mechanism to detect what their phenotypic sex is):
+INST if-mating-type-male
INST if-mating-type-female
INST if-mating-type-juvenile
Next, you'll need to modify your events file to make sure that the population is initialized with a male and a female organism. You can create a new default organism by modifying default-heads-sex.org (make two, say, default-heads-sex-male.org and default-heads-sex-female.org). Simple add a set-mating-type-male or set-mating-type-female instruction to the beginning of each .org file (you'll probably want it to be the first instruction that they execute, but it doesn't necessarily have to be). Then replace the original divide instruction with the div-sex-mating-type instruction.
+Now, modify your events file to inject both organisms at the start of the run:
+u begin Inject default-heads-sex-male.org 0
u begin Inject default-heads-sex-female.org 1
At this point, you should be able to get a run going, but read on for some further options and points to consider.
+-------------------------------------------
+When an organism reproduces sexually, it needs to find a mate. When the first organism in the population successfully divides, its 'offspring' goes into what is called the birth chamber, rather than being placed into the population. This is sort of a waiting area in which organisms can find mates. When another organism divides, Avida checks the birth chamber to see if there are any 'offspring' waiting to find a mate that were generated by a parent of the opposite mating type. If so, then they recombine, and the sexual offspring are placed into the population. If not, then this organism's 'offspring' goes into the birth chamber to wait as well. Because of this waiting process, you can almost think of these 'offspring' as being more like sperm or eggs, that need to join up with a gamete of the opposite type before they can form a zygote together.
+There are a few options regarding the birth chamber. First, you'll want to set its maximum size -- how many 'offspring' (or gametes) can be waiting in the birth chamber at any given time? The default is 3600, the same as the size of the default population. This can be changed in avida.cfg:
+MAX_GLOBAL_BIRTH_CHAMBER_SIZE 3600
Another thing to consider regarding the birth chamber is how long 'offspring' or gametes can wait there before dying. The default setting for this parameter (MAX_BIRTH_WAIT_TIME) is -1, meaning there is no limit -- they will remain in the birth chamber indefinitely, until they get picked by a mate. You will almost certainly want to change this. For example:
MAX_BIRTH_WAIT_TIME 3
would tell Avida that an 'offspring' or gamete can wait for three updates to be chosen as a mate, but any gametes that are not picked as mates within three updates after they go into the birth chamber will die. In practice, three seems to give good results.
+One final thing to consider is spatial organization. Currently, the birth chamber has no spatial organization to it; any organism can mate with any other organism regardless of their "physical" location in the population. Since mating has no spatial structure, you therefore may not want any spatial structure in your population at all. To do so, change:
+BIRTH_METHOD 4
-------------------------------------------
+By default, organisms will choose mates randomly. However, organisms can choose mates based on various phenotypic attributes by executing instructions that confer certain mating preferences. To enable this, simply add one or more of the following instructions to the instruction set:
+INST set-mate-preference-highest-merit
INST set-mate-preference-random
INST set-mate-preference-highest-display-a
INST set-mate-preference-highest-display-b
For example, suppose a female organism executes a set-mate-preference-highest-merit instruction, and then later divides. If there is more than one male 'offspring' (or sperm) waiting in the birth chamber when she divides, she will pick the one that came from a parent with the highest merit. Likewise, a female that has declared a preference for males with higher values of display A will select the one with the highest value of display A from among the available offspring of males in the birth chamber at the time of her divide.
+But wait -- what are these displays? Organisms can develop displays by executing instructions, which you will have to add to the instruction set:
+increment-mating-display-a
increment-mating-display-b
set-mating-display-a
set-mating-display-b
When an organism is born, its value for both display A and display B are both set to 0. Executing an increment-mating-display-A instruction adds 1 unit to its display. Using this method, an organism can only develop a large display by repeatedly executing this increment instruction. The set-mating-display-A and -B instructions, on the other hand, will copy the value of the ?BX? register (which register is used can be nop-modified) into its mating display. So using these instructions, organisms can develop exaggerated displays relatively quickly by using mathematical operations to generate a large value in their registers and then copying it to their displays.
Of course, in nature, organisms don't always perceive signals with 100% accuracy. Thus, in Avida, you can introduce noise into an organism's perception of other organisms' signals or phenotypic traits, using the NOISY_MATE_ASSESSMENT config option (0 = noise off [default]; 1 = noise on):
NOISY_MATE_ASSESSMENT 1
How much noise is introduced? When an organism assesses a phenotypic trait of a potential mate, the perceived value is drawn from a normal distribution with the mean at the actual value, and with a coefficient of variation of 0.1. This coefficient of variation can be changed with the MATE_ASSESSMENT_CV config option:
MATE_ASSESSMENT_CV 0.15
-------------------------------------------
+In nature, males and females of many animals can differ in certain traits because of sex-specific selective pressures. Avida can reflect this by implementing sex-specific costs for instructions. For example, in many animals, females invest more in reproduction. In Avida, we can make females pay extra CPU cycles to execute an instruction. This is an especially important consideration for the div-sex-mating-type instruction. Making females pay extra CPU cycles to complete division not only reflects the biological characteristics of many species, but also slows down female reproductive rates. As a result of males dividing more quickly than females (on average), the offspring of male organisms (i.e., sperm) will accumulate in the birth chamber. Females, then, will usually not be mate-limited, and will have more opportunities for mate choice -- again reflecting patterns that are often seen in nature. You can do this as follows, by modifying the div-sex-mating-types instruction in the instruction set file:
INST div-sex-mating-type:female_cost=50
This will require females to pay an extra 50 CPU cycles to complete their divide statements. Note that another work-around to forcing females to be the choosy sex is with the LEKKING option in avida.cfg. If you set its value to 1, all the offspring of male organisms will always go into the birth chamber -- in other words, males can never choose females as mates; females are always the 'choosers'.
Another important element is the cost of mate choice. In nature, mate choice can impose substantial costs on organisms. (For example, spending a lot of time searching for mates rather than mating with the first guy that comes along can put you at greater risk of being eaten by a predator.) You can force females who mate non-randomly to pay even greater CPU costs as follows:
+INST div-sex-mating-type:female_cost=50:choosy_female_cost=50
In this setup, males will pay 1 CPU cycle for executing a div-sex-mating-type instruction. Randomly mating females will pay an additional 50 CPU cycles. Females who mate non-randomly (e.g., choose the male with the highest merit or highest display A) will pay another 50 on top of that (i.e., 1 + 50 [for being female] + 50 [for being choosy] = 101).
-------------------------------------------
Normally, Avida keeps a record of every genotype (i.e., genome sequence) that has ever existed in the population. This is very useful when you want to trace an organism's lineage back through its ancestors. However, when sexual reproduction is turned on (and especially when separate mating types are turned on), all that recombination generates much more diversity. This means that Avida can take up quite a bit of memory (and will probably crash if you're doing a long run), and will get slower and slower as the run progresses and there are more and more genotypes to keep track of.
+If you don't need detailed information on organismal ancestry, you can turn off lineage tracking with the following config setting:
+DISABLE_GENOTYPE_CLASSIFICATION 1
-------------------------------------------
There are a variety of print actions that can be used to gather data on mating types and mate preferences as your population evolves:
+PrintMatingTypeHistogram: This action will print the number of juvenile, female, and male organisms in the population at the current update
PrintMatingDisplayData: This action prints the average display values (display-A and display-B) of all of the juveniles, females, and males in the population at the current update
PrintFemaleMatePreferenceData: This action prints the number of females with each different type of mating preference at the current update
PrintBirthChamberMatingTypeHistogram: This action prints the number of "sperm" and "eggs" in the birth chamber at the current update
PrintSuccessfulMates: This action prints the genotypes and some useful phenotypic information (e.g., merit, mating types, displays, preferences) of the parents of all the successful matings that occurred during the current update
PrintBirthChamber: This action prints the genotypes and some useful phenotypic information (e.g., merit, mating types, displays, preferences) of the parents of all the "sperm" or "eggs" waiting in the birth chamber at the current update
(Note: by using PrintBirthChamber to print all the organisms currently waiting to be chosen as mates, and PrintSuccessfulMates to print all the organisms that were successfully chosen as mates, you can estimate sexual selection differentials.)
+-------------------------------------------
+There are a few phenotypic attributes that can be used with the DETAIL statement in analyze mode (pretty self-explanatory):
+mating_typemate_preferencemating_display_amating_display_b
Using these, you can take a genotype and run it through analyze mode to find out what mating type it develops as (useful if there are multiple set-mating-type-XXX instructions in a genome and it's hard to tell which one will be executed first), what kind of mate preference it will exhibit, how large its sexual displays are, etc.
+diff --git a/docs/documentation/glossary/Glossary--Bitwise.md b/docs/documentation/glossary/Glossary--Bitwise.md new file mode 100644 index 0000000..e6be4b1 --- /dev/null +++ b/docs/documentation/glossary/Glossary--Bitwise.md @@ -0,0 +1,6 @@ + +
+A register is a storage space for a single number. +Each classic CPU in Avida contains three registers, each of which is made up of 32 bits. All math-based instructions opperate on the registers, and various instruction will move the values in the registers around. +
+ diff --git a/docs/documentation/glossary/Glossary--Stack.md b/docs/documentation/glossary/Glossary--Stack.md new file mode 100644 index 0000000..1363c4d --- /dev/null +++ b/docs/documentation/glossary/Glossary--Stack.md @@ -0,0 +1,8 @@ + ++Each classic CPU in Avida has two stacks used for storage of numbers. The push and pop instructions are used to move numbers between the registers and the stack, and the swap-stk instruction toggles the active stack in use. +
+ diff --git a/docs/documentation/glossary/Glossary--Tasks.md b/docs/documentation/glossary/Glossary--Tasks.md new file mode 100644 index 0000000..7fac88f --- /dev/null +++ b/docs/documentation/glossary/Glossary--Tasks.md @@ -0,0 +1,6 @@ + +This instruction reads in the contents of the BX and CX registers and sums them together. The result of this operation is then placed in the ?BX? register.
+ diff --git a/docs/documentation/glossary/Glossary--dec.md b/docs/documentation/glossary/Glossary--dec.md new file mode 100644 index 0000000..72e0daa --- /dev/null +++ b/docs/documentation/glossary/Glossary--dec.md @@ -0,0 +1,6 @@ + +