Reference 〉 Function

Helipad.addGood( str name, str color, num|tuple|func(str) endowment = None, bool money = False, dict{str: num|tuple|func(str)} props = {} )

Registers a good that model agents can carry or trade. Agents will keep track of stocks of the good in the dict-like agent.stocks. Quantities of a good can be accessed with agent.stocks[good], and properties of the good with a two-argument index, e.g. agent.stocks[good, 'property'].


  • name str, required

    The name of the good.

  • color str, required

    The color that ought to represent the good in the control panel and visualizations. Can take a hex string, a color name string (see the Matplotlib documentation for valid values), an RGB tuple with ranges from 0.0 to 1.0, or a Color object.

  • endowment num|tuple|func(str), optional

    Determines how much of the good agents begin the model with.

    • If a number (int or float), agents instantiate with that amount of the good.
    • Can also be a function that takes the breed as its only argument and returns a number.
    • A two-int tuple will endow the agent with a random amount uniformly distributed between those two ints.

    Default value: None

  • money bool, optional

    Sets the good as the medium of exchange for the purpose of functions such as Only one good can be declared the monetary good.

    Default value: False

  • props dict{str: num|tuple|func(str)}, optional

    A set of per-agent properties attached to the good. The values of the dict set the initial value of the property on agent instantiation, and have the same possibilities as the endowment argument, e.g. a number, a tuple, or a function.

    Default value: {}

Return Value Good

The newly created Good object.

Notes and Examples

  1. charwick

    Jun 19, 2021 at 20:01

    In this example agents have a reserve quantity, a minimum price, and a surplus for each good:

    def maxReserve(breed): return random.randint(1,2000)
    heli.addGood('sugar', '#FFFF00', props={'reserve': maxReserve, 'price': 1, 'surplus': False})
    heli.addGood('water', '#00FFFF', props={'reserve': maxReserve, 'price': 1, 'surplus': False})

    This gives agents ‘reserve’, ‘price’, and ‘surplus’ properties for each of the two goods, and sets the initial values to a random integer between 1 and 2000, 1, and False, respectively.

    The quantity of the good held by the agent can be accessed with agent.stocks[good]. The other properties can be accessed with a two-argument index. agent.stocks['water', 'reserve'], for example, will return the value of the agent’s 'reserve' property for water. Agents’ good properties can be set using the two-argument index as well.

  2. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.