Reference 〉Function

Agent.reproduce( list[str|tuple] inherit = [], dict mutate = {}, list[Agent] partners = [] )

Spawns a new agent, inheriting specified properties from the parent agent. The parent agent is stored in the child’s agent.parent, and the child agent is added to the parent agent’s agent.children list. Properties not specified in either the inherit or mutate arguments will be instantiated according to the agent.__init__() function.

NOTE. This function accounts for parents and children by creating a directed network titled 'lineage'.


  • inherit list[str|tuple], optional

    A list of strings or tuples referring to properties that should be copied from the parent agent to the child agent. Any properties not listed in inherit will take their initial value at the instantiation of the primitive object. If a string, the child property will be a mean of the property values of the parents, or the property value of the first parent for non-numeric property values.

    If a tuple, the first element is a string referring to the property value to inherit. The second value is a string referring to a statistic determining how the properties of the parent agents should be inherited, or a function that takes a list of parents' property values and returns a value. Possible statistic values are:

    • 'mean' – averages the values of the parents' properties.
    • 'gmean' – Calculates the geometric mean of the parents' properties.
    • 'sum' – Totals the values of the parents' properties.
    • 'max' – chooses the maximum value of the parents' properties.
    • 'min' – chooses the minimum value of the parents' properties.
    • 'first' – passes the value to the child of the agent on whom the reproduce() function was called.
    • 'last' – Passes the value of the last parent in the parents argument.
    • 'rand' – chooses a random parent whose property value to pass to the child.

    Default value: []

  • mutate dict, optional

    Properties to be mutated, either from the inherited value if specified in inherit, or the initial value otherwise. The keys of the dict indicate properties to be mutated. The values can be either:

    1. a number, in which case the value is drawn from a normal distribution with a mean of the old value and a standard devation of the number,
    2. a tuple, the first item of which is a numeric standard deviation, and the second of which is either 'log' or 'linear' (this allows the mutated value to be drawn from a log-normal distribution), or
    3. a function that takes a value and returns a value, useful for more complex mutations.

    Default value: {}

  • partners list[Agent], optional

    A list of other agents (not including the self) whose attributes should be used in parentage.

    Default value: []

Return Value Agent

The new agent object.

Fatal error: Uncaught TypeError: Unsupported operand types: string - string in /home/dh_nzhxm7/ Stack trace: #0 [internal function]: {closure}(Object(WP_Comment), Object(WP_Comment)) #1 /home/dh_nzhxm7/ usort(Array, Object(Closure)) #2 /home/dh_nzhxm7/ {closure}(Array) #3 /home/dh_nzhxm7/ WP_Hook->apply_filters(Array, Array) #4 /home/dh_nzhxm7/ apply_filters('comments_array', Array, 166) #5 /home/dh_nzhxm7/ comments_template() #6 /home/dh_nzhxm7/ include('/home/dh_nzhxm7...') #7 /home/dh_nzhxm7/ require_once('/home/dh_nzhxm7...') #8 /home/dh_nzhxm7/ require('/home/dh_nzhxm7...') #9 {main} thrown in /home/dh_nzhxm7/ on line 200