How to use the indra.agent.Agent function in indra

To help you get started, we’ve selected a few indra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gcallah / indras_net / models / fashion.py View on Github external
def create_tsetter(name, i, props=None, color=RED_SIN):
    """
    Create a trendsetter: all RED to start.
    """
    return Agent(TSETTER_PRENM + str(i),
                 action=tsetter_action,
                 attrs={COLOR_PREF: color,
                        DISPLAY_COLOR: color})
github gcallah / indras_net / models / models_to_rewrite / bigbox.py View on Github external
def create_bb(name):
    """
    Create a big box store.
    """
    global bb_capital

    bb_book = {"expense": 150,
               "capital": bb_capital}
    return Agent(name=name, attrs=bb_book, action=bb_action)
github gcallah / indras_net / models / wolfsheep.py View on Github external
def create_sheep(i):
    global sheep_created
    sheep_created += 1
    return Agent(AGT_SHEEP_NAME + str(i), duration=SHEEP_LIFESPAN,
                 action=sheep_action,
                 attrs={"time_to_repr": SHEEP_REPRO_PERIOD})
github gcallah / indras_net / capital / cap_struct.py View on Github external
* random.uniform(0.5,
                                                                    1.5))))

    starting_cash = DEF_RHOLDER_CASH
    if props is not None:
        starting_cash = get_prop('rholder_starting_cash',
                                 DEF_RHOLDER_CASH)

    if props is not None:
        total_resources = get_prop('rholder_starting_resource_total',
                                   DEF_TOTAL_RESOURCES_RHOLDER_HAVE)
        for k in resources.keys():
            resources[k] = int((total_resources * 2)
                               * (random.random() / num_resources))

    return Agent(name + str(i), action=rholder_action,
                 attrs={"cash": starting_cash,
                        "resources": resources,
                        "price": price_list})
github gcallah / indras_net / models / models_to_rewrite / gameoflife.py View on Github external
def create_game_cell(x, y):
    """
    Create an agent with the passed x, y value as its name.
    """
    return Agent(name=("(%d,%d)" % (x, y)),
                 action=game_agent_action,
                 attrs={"save_neighbors": True})
github gcallah / indras_net / models / fashion.py View on Github external
def create_follower(i, color=BLUE):
    """
    Create a follower: all BLUE to start.
    """
    return Agent(FOLLOWER_PRENM + str(i),
                 action=follower_action,
                 attrs={COLOR_PREF: color,
                        DISPLAY_COLOR: color})
github gcallah / indras_net / models / wolfsheep.py View on Github external
def create_wolf(i):
    global wolves_created
    wolves_created += 1
    return Agent(AGT_WOLF_NAME + str(i), duration=WOLF_LIFESPAN,
                 action=wolf_action,
                 attrs={"time_to_repr": WOLF_REPRO_PERIOD})
github gcallah / indras_net / models / sandpile.py View on Github external
def create_grain(x, y):
    """
    Create an agent with the passed x, y value as its name.
    """
    return Agent(name=("(%d,%d)" % (x, y)),
                 action=None,
                 attrs={"save_neighbors": True})
github gcallah / indras_net / models / fashion.py View on Github external
def create_follower(name, i, props=None, color=BLUE_SIN):
    """
    Create a follower: all BLUE to start.
    """
    return Agent(FOLLOWER_PRENM + str(i),
                 action=follower_action,
                 attrs={COLOR_PREF: color,
                        DISPLAY_COLOR: color})
github gcallah / indras_net / capital / trade.py View on Github external
def create_trader(name, i, props=None):
    return Agent(name + str(i), action=seek_a_trade,
                 attrs={"goods": {"penguin": {AMT_AVAIL: 0,
                                              UTIL_FUNC: "penguin_util_func",
                                              "incr": 0},
                                  "cat": {AMT_AVAIL: 0,
                                          UTIL_FUNC: "cat_util_func",
                                          "incr": 0},
                                  "bear": {AMT_AVAIL: 0,
                                           UTIL_FUNC: "bear_util_func",
                                           "incr": 0},
                                  "pet food": {AMT_AVAIL: 0,
                                               UTIL_FUNC: GEN_UTIL_FUNC,
                                               "incr": 0}
                                  },
                        "util": 0,
                        "pre_trade_util": 0,
                        "trades_with": "trader"})