def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) exec_key = init_exec_key(props) groups = [] groups.append( Composite("value_investors", {"color": BLUE}, member_creator=create_value_investor, num_members=get_prop("value_investors", DEF_NUM_VALUE_INVESTOR, execution_key=exec_key), execution_key=exec_key)) groups.append( Composite("trend_followers", {"color": RED}, member_creator=create_trend_follower, num_members=get_prop("trend_followers", DEF_NUM_TREND_FOLLOWER, execution_key=exec_key), execution_key=exec_key), ) groups.append(create_market_maker(MARKET_MAKER)) Env(MODEL_NAME, members=groups, width=UNLIMITED, height=UNLIMITED, pop_hist_setup=initial_price, execution_key=exec_key) get_env(execution_key=exec_key).exclude_menu_item("scatter_plot") set_env_attrs(execution_key=exec_key)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) execution_key = int(props[EXEC_KEY].val) \ if props is not None else CLI_EXEC_KEY width = get_prop('grid_width', DEF_WIDTH, execution_key=execution_key) height = get_prop('grid_height', DEF_HEIGHT, execution_key=execution_key) groups = [] for i in range(NUM_GROUPS): groups.append( Composite(str(i), {"marker": CIRCLE}, execution_key=execution_key)) for y in range(height): for x in range(width): groups[0] += create_grain(x, y, execution_key=execution_key) sandpile_env = Env(MODEL_NAME, action=sandpile_action, height=height, width=width, members=groups, attrs={ "size": 65, "hide_axes": True, "hide_legend": True }, random_placing=False, execution_key=execution_key) # these settings must be re-done every API re-load: set_env_attrs(execution_key) return sandpile_env, groups
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) execution_key = int(props[EXEC_KEY].val) \ if props is not None else CLI_EXEC_KEY blue_agents = Composite(group_names[BLUE_GRP_IDX], {"color": BLUE}, member_creator=create_resident, num_members=get_prop('num_blue', NUM_BLUE, execution_key=execution_key), group=BLUE, execution_key=execution_key) red_agents = Composite(group_names[RED_GRP_IDX], {"color": RED}, member_creator=create_resident, num_members=get_prop('num_red', NUM_RED, execution_key=execution_key), group=RED, execution_key=execution_key) city = Env(MODEL_NAME, members=[blue_agents, red_agents], height=get_prop('grid_height', DEF_CITY_DIM, execution_key=execution_key), width=get_prop('grid_width', DEF_CITY_DIM, execution_key=execution_key), execution_key=execution_key) city.exclude_menu_item("line_graph")
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) exec_key = init_exec_key(props) members = [] members.append( Composite(WOLF_GROUP, attrs={"color": TAN}, member_creator=create_wolf, num_members=get_prop('num_wolves', NUM_WOLVES, execution_key=exec_key), execution_key=exec_key)) members.append( Composite(SHEEP_GROUP, attrs={"color": GRAY}, member_creator=create_sheep, num_members=get_prop('num_sheep', NUM_SHEEP, execution_key=exec_key), execution_key=exec_key)) Env(MODEL_NAME, members=members, attrs={ "prey_dist": get_prop("prey_dist", PREY_DIST, execution_key=exec_key) }, height=get_prop('grid_height', MEADOW_HEIGHT, execution_key=exec_key), width=get_prop('grid_width', MEADOW_WIDTH, execution_key=exec_key), execution_key=exec_key)
def set_up(props=None): # testcase??? """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props, model_dir="ml") group = [] group.append( Composite(DEALER_GRP, {"color": BLUE}, member_creator=generate_dealer, num_members=get_prop('num_dealers', DEF_NUM_DEALER))) # can we put the testing period in to composite too? group.append( Composite(AVA_BUYER_GRP, {"color": RED}, member_creator=ava_cb, num_members=get_prop('num_buyers', DEF_NUM_BUYER))) group.append( Composite(SELINA_BUYER_GRP, {"color": RED}, member_creator=selina_cb, num_members=get_prop('num_buyers', DEF_NUM_BUYER))) Env(MODEL_NAME, height=get_prop('grid_height', DEF_HEIGHT), width=get_prop('grid_width', DEF_WIDTH), members=group)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) execution_key = int(props[EXEC_KEY].val) \ if props is not None else CLI_EXEC_KEY blue_group = Composite("Blues", {"color": BLUE}, member_creator=create_agent, num_members=get_prop('num_blue', DEF_NUM_BLUE, execution_key=execution_key), execution_key=execution_key) red_group = Composite("Reds", {"color": RED}, member_creator=create_agent, num_members=get_prop('num_red', DEF_NUM_RED, execution_key=execution_key), execution_key=execution_key) Env(MODEL_NAME, height=get_prop('grid_height', DEF_HEIGHT, execution_key=execution_key), width=get_prop('grid_width', DEF_WIDTH, execution_key=execution_key), members=[blue_group, red_group], execution_key=execution_key)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) execution_key = int(props[EXEC_KEY].val) \ if props is not None else CLI_EXEC_KEY toxins = Composite(TOXINS, {"color": RED}, member_creator=create_toxin, num_members=get_prop('num_toxins', NUM_TOXINS, execution_key=execution_key), execution_key=execution_key) nutrients = Composite(NUTRIENTS, {"color": GREEN}, member_creator=create_nutrient, num_members=get_prop('num_nutrients', NUM_TOXINS, execution_key=execution_key), execution_key=execution_key) bacteria = Composite(BACTERIA, {"color": BLUE}, member_creator=create_bacterium, num_members=get_prop('num_toxins', DEF_NUM_BACT, execution_key=execution_key), execution_key=execution_key) Env(MODEL_NAME, height=get_prop('grid_height', DEF_HEIGHT, execution_key=execution_key), width=get_prop('grid_width', DEF_WIDTH, execution_key=execution_key), members=[toxins, nutrients, bacteria], execution_key=execution_key)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) execution_key = int(props[EXEC_KEY].val) \ if props is not None else CLI_EXEC_KEY population_prop = \ get_prop('population', DEF_POPULATION, execution_key=execution_key) drinkers = Composite(DRINKERS, {"color": RED}, member_creator=create_drinker, num_members=population_prop // 2, execution_key=execution_key) non_drinkers = Composite(NON_DRINKERS, {"color": BLUE}, member_creator=create_non_drinker, num_members=population_prop // 2, execution_key=execution_key) Env(MODEL_NAME, height=get_prop('grid_height', DEF_HEIGHT, execution_key=execution_key), width=get_prop('grid_width', DEF_WIDTH, execution_key=execution_key), members=[drinkers, non_drinkers], pop_hist_setup=setup_attendance, execution_key=execution_key) population = len(drinkers) + len(non_drinkers) set_env_attr(POPULATION, population, execution_key=execution_key) set_env_attr(OPT_OCCUPANCY, int(population * DEF_MOTIV), execution_key=execution_key) set_env_attr(AGENTS_DECIDED, 0, execution_key=execution_key) set_env_attr(ATTENDANCE, 0, execution_key=execution_key) set_env_attrs(execution_key=execution_key)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) groups = [] groups.append( Composite("value_investors", {"color": BLUE}, member_creator=create_value_investor, num_members=get_prop("value_investors", DEF_NUM_VALUE_INVESTOR))) groups.append( Composite("trend_followers", {"color": RED}, member_creator=create_trend_follower, num_members=get_prop("trend_followers", DEF_NUM_TREND_FOLLOWER))) groups.append(create_market_maker("market_maker")) Env("fmarket", members=groups, width=UNLIMITED, height=UNLIMITED, census=market_report, line_data_func=plot_asset_price) get_env().exclude_menu_item("scatter_plot")
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) execution_key = int(props[EXEC_KEY].val) \ if props is not None else CLI_EXEC_KEY calm = Composite(CALM, {"color": BLUE}, member_creator=create_resident, num_members=get_prop('num_people', NUM_CALM_AGENTS, execution_key=execution_key), group=BLUE, execution_key=execution_key) panic = Composite(PANIC, {"color": RED}, member_creator=create_resident, num_members=NUM_PANIC_AGENTS, group=RED, execution_key=execution_key) city = Env(MODEL_NAME, members=[calm, panic], height=get_prop('grid_height', DEF_CITY_DIM, execution_key=execution_key), width=get_prop('grid_width', DEF_CITY_DIM, execution_key=execution_key), execution_key=execution_key) set_env_attr(STATES, [CALM, PANIC], execution_key=execution_key) city.exclude_menu_item("line_graph")
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) execution_key = int(props[EXEC_KEY].val) \ if props is not None else CLI_EXEC_KEY num_members = get_prop('num_babysitter', DEF_BABYSITTER, execution_key=execution_key) co_op_members = Composite(CO_OP_MEMBERS, {"color": RED}, num_members=num_members, member_creator=create_babysitter, execution_key=execution_key) central_bank = Composite("central_bank", {"color": GREEN}, num_members=1, member_creator=create_central_bank, execution_key=execution_key) Env(MODEL_NAME, members=[co_op_members, central_bank], action=coop_action, width=UNLIMITED, height=UNLIMITED, pop_hist_setup=initial_exchanges, attrs={ "last_per_exchg": 0, "last_per_unemp": 0, "num_rounds": 0, "CB_interven_pts": [] }, execution_key=execution_key) set_env_attrs(execution_key=execution_key)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) execution_key = int(props[EXEC_KEY].val) \ if props is not None else CLI_EXEC_KEY groups = [] groups.append( Composite(BLUE_TSETTERS, {"color": NAVY}, execution_key=execution_key)) groups.append(Composite(RED_TSETTERS, {"color": DARKRED}, member_creator=create_tsetter, num_members=get_prop('num_tsetters', NUM_TSETTERS, execution_key=execution_key), execution_key=execution_key)) groups.append( Composite(RED_FOLLOWERS, {"color": RED}, execution_key=execution_key)) groups.append(Composite(BLUE_FOLLOWERS, {"color": BLUE}, member_creator=create_follower, num_members=get_prop('num_followers', NUM_FOLLOWERS, execution_key=execution_key), execution_key=execution_key)) Env(MODEL_NAME, members=groups, attrs={OPP_GROUP: opp_group}, execution_key=execution_key)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ global population global optimal_occupancy global agents_decided init_props(MODEL_NAME, props) agents_decided = 0 drinkers = Composite(DRINKERS, {"color": RED}, member_creator=create_drinker, num_members=get_prop('population', DEF_POPULATION) // 2) non_drinkers = Composite(NON_DRINKERS, {"color": BLUE}, member_creator=create_non_drinker, num_members=get_prop('population', DEF_POPULATION) // 2) population = len(drinkers) + len(non_drinkers) optimal_occupancy = int(population * 0.6) Env("bar", height=get_prop('grid_height', DEF_HEIGHT), width=get_prop('grid_width', DEF_WIDTH), members=[drinkers, non_drinkers])
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) num_members = get_prop('num_babysitter', DEF_BABYSITTER) co_op_members = Composite(CO_OP_MEMBERS, num_members=num_members, member_creator=create_babysitter) central_bank = Composite("central_bank", num_members=1, member_creator=create_central_bank) Env('coop_env', members=[co_op_members, central_bank], action=coop_action, width=UNLIMITED, height=UNLIMITED, census=coop_report, pop_hist_setup=initial_exchanges, pop_hist_func=record_exchanges, attrs={ "show_special_points": CB_intervention_points, "special_points_name": "CB intervention points" })
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) height = get_prop("grid_height", DEF_HEIGHT) width = get_prop("grid_width", DEF_WIDTH) simulation = get_prop("simulation", 0) black = Composite("Black", {"color": BLACK, "marker": SQUARE}) groups = [black] Env("Game of Life", action=gameoflife_action, height=height, width=width, members=groups, attrs={"size": 100, "change_grid_spacing": (0.5, 1), "hide_xy_ticks": True, "hide_legend": True}, random_placing=False) populate_board_dict[simulation](width, height) return groups
def set_up(props=None): """ A func to set up a run that can also be used by test code. """ init_props(MODEL_NAME, props) execution_key = int(props[EXEC_KEY].val) \ if props is not None else CLI_EXEC_KEY forest_height = get_prop('grid_height', DEF_DIM, execution_key=execution_key) forest_width = get_prop('grid_width', DEF_DIM, execution_key=execution_key) new_fire = get_prop('new_fire', DEF_NEW_FIRE, execution_key=execution_key) set_trans(state_trans, HE, NF, float(new_fire), HE) forest_density = get_prop('density', DEF_DENSITY, execution_key=execution_key) tree_cnt = int(forest_height * forest_width * forest_density) groups = [] groups.append( Composite(HEALTHY, { "color": GREEN, "marker": TREE }, member_creator=plant_tree, num_members=tree_cnt, execution_key=execution_key)) groups.append( Composite(NEW_FIRE, { "color": TOMATO, "marker": TREE }, execution_key=execution_key)) groups.append( Composite(ON_FIRE, { "color": RED, "marker": TREE }, execution_key=execution_key)) groups.append( Composite(BURNED_OUT, { "color": BLACK, "marker": TREE }, execution_key=execution_key)) groups \ .append(Composite(NEW_GROWTH, {"color": SPRINGGREEN, "marker": TREE}, execution_key=execution_key)) Env(MODEL_NAME, height=forest_height, width=forest_width, members=groups, execution_key=execution_key) # the next set should just be done once: set_env_attr(TRANS_TABLE, state_trans, execution_key=execution_key) # whereas these settings must be re-done every API re-load: set_env_attrs(execution_key=execution_key)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) execution_key = int(props[EXEC_KEY].val) \ if props is not None else CLI_EXEC_KEY width = get_prop('grid_width', DEF_WIDTH, execution_key=execution_key) height = (width // 2) + (width % 2) groups = [ Composite(WHITE, {"color": WHITE}, execution_key=execution_key), Composite(BLACK, { "color": BLACK, "marker": SQUARE }, execution_key=execution_key) ] for y in range(height): for x in range(width): groups[W] += create_wolf_cell(x, y, execution_key) wolfram_env = Env(MODEL_NAME, action=wolfram_action, height=height, width=width, members=groups, attrs={ "size": 50, "hide_grid_lines": True, "hide_legend": True }, random_placing=False, execution_key=execution_key) rule_num = get_prop('rule_number', DEF_RULE, execution_key=execution_key) wolfram_env.set_attr("rule_num", rule_num) wolfram_env.set_attr("rule_dict", get_rule(rule_num)) wolfram_env.exclude_menu_item("line_graph") ''' This switch needs to happen before the environment is executed. Using add switch doesn't process the switch until after the environment is executed which breaks the model. ''' top_center_agent = \ wolfram_env.get_agent_at(width // 2, top_row(execution_key)) switch(top_center_agent.name, WHITE, BLACK, execution_key=execution_key) # top row is the "previous" because we just processed it set_env_attr("prev_row_idx", top_row(execution_key), execution_key=execution_key)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ pa = init_props(MODEL_NAME, props, model_dir="capital") execution_key = int(props[EXEC_KEY].val) \ if props is not None else CLI_EXEC_KEY traders = Composite("Traders", member_creator=create_trader, props=pa, num_members=get_prop('num_traders', DEF_NUM_TRADERS, execution_key=execution_key), execution_key=execution_key) check_props(execution_key=execution_key) nature_to_traders(traders, natures_goods) Env(MODEL_NAME, height=get_prop('grid_height', DEF_HEIGHT, execution_key=execution_key), width=get_prop('grid_width', DEF_WIDTH, execution_key=execution_key), members=[traders], attrs={"goods": natures_goods}, pop_hist_setup=initial_amt, execution_key=execution_key) set_env_attrs(execution_key=execution_key)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) blue_group = Composite("Blues", {"color": BLUE}, member_creator=create_agent, num_members=get_prop('num_blue', DEF_NUM_BLUE)) red_group = Composite("Reds", {"color": RED}, member_creator=create_agent, num_members=get_prop('num_red', DEF_NUM_RED)) Env("env", height=get_prop('grid_height', DEF_HEIGHT), width=get_prop('grid_width', DEF_WIDTH), members=[blue_group, red_group])
def set_up(props=None): """ A func to set up run that can also be used by test code. """ global resource_holders global entrepreneurs pa = init_props(MODEL_NAME, props, model_dir="capital") entrepreneurs = Composite("Entrepreneurs", {"color": BLUE}, member_creator=create_entr, props=pa, num_members=pa.get('num_entr', DEF_NUM_ENTR)) resource_holders = Composite("Resource_holders", {"color": RED}, member_creator=create_rholder, props=pa, num_members=pa.get('num_rholder', DEF_NUM_RHOLDER)) Env("neighborhood", height=get_prop('grid_height', DEF_HEIGHT), width=get_prop('grid_width', DEF_WIDTH), members=[resource_holders, entrepreneurs]) return resource_holders, entrepreneurs
def set_up(props=None): """ A func to set up run that can also be used by test code. """ global max_util pa = init_props(MODEL_NAME, props, model_dir="capital") cheese_group = Composite("Cheese holders", {"color": BLUE}, member_creator=create_cagent, props=pa, num_members=get_prop('num_cagents', DEF_NUM_CAGENTS)) wine_group = Composite("Wine holders", {"color": RED}, member_creator=create_wagent, props=pa, num_members=get_prop('num_wagents', DEF_NUM_WAGENTS)) Env("EdgeworthBox", height=get_prop('grid_height', DEF_HEIGHT), width=get_prop('grid_width', DEF_WIDTH), members=[cheese_group, wine_group]) start_cheese = 0 start_wine = 0 if pa is not None: start_cheese = get_prop('start_cheese', DEF_NUM_CHEESE) start_wine = get_prop('start_wine', DEF_NUM_WINE) max_util = max(start_cheese, start_wine) else: props_max_util = max(start_cheese, start_wine) max_util = max(props_max_util, DEF_MAX_UTIL) return (cheese_group, wine_group, max_util)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ # global max_util -> not in use now init_props(MODEL_NAME, props, model_dir="capital") traders = Composite("Traders", member_creator=create_trader, num_members=get_prop('num_traders', DEF_NUM_TRADERS)) nature_to_traders(traders, natures_goods) Env("MengerMoney", height=get_prop('grid_height', DEF_HEIGHT), width=get_prop('grid_width', DEF_WIDTH), members=[traders], attrs={"goods": natures_goods})
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) blue_agents = Composite(group_names[BLUE_TEAM], {"color": BLUE}, member_creator=create_resident, num_members=get_prop('num_blue', NUM_BLUE)) red_agents = Composite(group_names[RED_TEAM], {"color": RED}, member_creator=create_resident, num_members=get_prop('num_red', NUM_RED)) city = Env("A city", members=[blue_agents, red_agents], height=get_prop('grid_height', DEF_CITY_DIM), width=get_prop('grid_width', DEF_CITY_DIM)) city.exclude_menu_item("line_graph")
def set_up(num_dealers, props=None): # testcase??? """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) group = [] group.append( Composite(DEALER_GRP, {"color": BLUE}, member_creator=create_dealer, num_members=num_dealers)) group.append( Composite(BUYER_GRP, {"color": RED}, member_creator=create_buyer, num_members=get_prop('num_buyers', DEF_NUM_RED))) Env("Car market", height=get_prop('grid_height', DEF_HEIGHT), width=get_prop('grid_width', DEF_WIDTH), members=group)
def set_up(props=None): """ Create an Env for Big box. """ init_props(MODEL_NAME, props) width = get_prop("grid_width", DEF_WIDTH) height = get_prop("grid_height", DEF_HEIGHT) num_consumers = get_prop("consumer_num", NUM_OF_CONSUMERS) num_mp = get_prop("mp_num", NUM_OF_MP) mp_pref = get_prop("mp_pref", MP_PREF) hood_size = get_prop("hood_size", HOOD_SIZE) multiplier = get_prop("multiple", MULTIPLIER) bb_capital = multiplier * STANDARD period = get_prop("period", PERIOD) consumer_group = Composite(CONSUMER, {"color": GRAY}, member_creator=create_consumer, num_members=num_consumers) bb_group = Composite(BIG_BOX, {"color": BLUE}) groups = [consumer_group, bb_group] for stores in range(0, len(mp_stores)): store_name = list(mp_stores.keys())[stores] groups.append(Composite(store_name, {"color": mp_stores[store_name][COLOR_INDX]})) for kind in range(0, len(mp_stores)): groups[kind+2] += create_mp(groups[kind+2], kind) if num_mp > len(mp_stores): for mp in range(len(mp_stores), num_mp): rand = random.randint(2, len(groups) - 1) groups[rand] += create_mp(groups[rand], mp) box = Env(MODEL_NAME, action=town_action, members=groups, height=height, width=width) box.set_attr("consumer_group", consumer_group) box.set_attr("bb_group", bb_group) box.set_attr("hood_size", hood_size) box.set_attr("mp_pref", mp_pref) box.set_attr("period", period) box.set_attr("bb_capital", bb_capital)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) geneng_group = Composite(GENENG, {"color": BLUE}, member_creator=create_geneng, num_members=get_prop('num_geneng', DEF_NUM_GENENG)) natural_group = Composite(NATURAL, {"color": RED}, member_creator=create_natural, num_members=get_prop('num_natural', DEF_NUM_NATURAL)) Env(MODEL_NAME, height=get_prop('grid_height', DEF_HEIGHT), width=get_prop('grid_width', DEF_WIDTH), members=[geneng_group, natural_group]) set_env_attrs()
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) members = [] members.append(Composite(WOLF_GROUP, attrs={"color": TAN}, member_creator=create_wolf, num_members=get_prop('num_wolves', NUM_WOLVES))) members.append(Composite(SHEEP_GROUP, attrs={"color": GRAY}, member_creator=create_sheep, num_members=get_prop('num_sheep', NUM_SHEEP))) Env("meadow", members=members, height=get_prop('meadow_height', MEADOW_HEIGHT), width=get_prop('meadow_width', MEADOW_WIDTH))
def set_up(props=None): """ Create an Env for Big box. """ init_props(MODEL_NAME, props) width = get_prop("grid_width", DEF_WIDTH) height = get_prop("grid_height", DEF_HEIGHT) num_consumers = get_prop("consumer_num", NUM_OF_CONSUMERS) num_mp = get_prop("mp_num", NUM_OF_MP) mp_pref = get_prop("mp_pref", MP_PREF) hood_size = get_prop("hood_size", HOOD_SIZE) multiplier = get_prop("multiple", MULTIPLIER) bb_capital = multiplier * STANDARD period = get_prop("period", PERIOD) consumer_group = Composite(CONSUMER, {"color": GRAY}, member_creator=create_consumer, num_members=num_consumers) bb_group = Composite(BIG_BOX, {"color": BLUE}) groups = [consumer_group, bb_group] # add mom and pop stores to groups: groups.extend(mp_stores) # loop over m&p store types and add stores: for i in range(num_mp): store_num = i % len(mp_stores) # keep store_num in range mp_stores[store_num] += create_mp(mp_stores[store_num], i) box = Env(MODEL_NAME, action=town_action, members=groups, height=height, width=width) box.set_attr("consumer_group", consumer_group) box.set_attr("bb_group", bb_group) box.set_attr("hood_size", hood_size) box.set_attr("mp_pref", mp_pref) box.set_attr("period", period) box.set_attr("bb_capital", bb_capital)
def set_up(props=None): """ A func to set up run that can also be used by test code. """ global period period = 0 init_props(MODEL_NAME, props) newly_freed = Composite("Girlfriend", {"color": BLUE}, member_creator=create_newly_freed, num_members=1) ex_boyfriend = Composite("Ex-Boyfriend", {"color": RED}, member_creator=create_boyfriend, num_members=1) Env("bar", height=get_prop('grid_height', DEF_HEIGHT), width=get_prop('grid_width', DEF_WIDTH), members=[ex_boyfriend, newly_freed])
def set_up(props=None): """ A func to set up run that can also be used by test code. """ init_props(MODEL_NAME, props) toxins = Composite(TOXINS, {"color": RED}, member_creator=create_toxin, num_members=get_prop('num_toxins', NUM_TOXINS)) nutrients = Composite(NUTRIENTS, {"color": GREEN}, member_creator=create_nutrient, num_members=get_prop('num_nutrients', NUM_TOXINS)) bacteria = Composite("Bacteria", {"color": BLUE}, member_creator=create_bacterium, num_members=get_prop('num_toxins', DEF_NUM_BACT)) Env("Petrie dish", height=get_prop('grid_height', DEF_HEIGHT), width=get_prop('grid_width', DEF_WIDTH), members=[toxins, nutrients, bacteria])