Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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})
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)
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})
* 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})
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})
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})
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})
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})
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})
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"})