-
Notifications
You must be signed in to change notification settings - Fork 113
Internal resources
Avida 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 0to
USE_RESOURCE_BINS 1
ABSORB_RESOURCE_FRACTION .0025This 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 -1This 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. The collect instruction (and most of its variants) determine which resource to affect by looking at the nop instructions which follow it. This specification is robust to both the number of specifying nops (i.e. nop-A, nop-B, and nop-C, but not nop-X) in the instruction set and the number of resources in the environment file.
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 1000This 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 0This 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. Rather than collecting a single specific resource, the collect-specific-ratio instruction collects some amount of all resources. By default, it collects one unit of each resource. A different ratio for a given resource can be specified with the config option NON_1_RESOURCE_RATIOS.
NON_1_RESOURCE_RATIOS resource_index1:amount, resource_index2:amountEvery 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 1:2, 3:.5Would 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.
USE_STORED_FRACTION 1.0This 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.0This 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.0to
ENV_FRACTION_THRESHOLD 0.0As 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 0This 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 0This 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 1This 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_DEATHThis 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.