예제 #1
0
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)
예제 #2
0
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)
    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
    },
                      execution_key=exec_key)
    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,
        execution_key=exec_key)

    populate_board_dict[simulation](width, height)
    reset_env_attrs()
예제 #3
0
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)
예제 #4
0
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)
    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
    },
                      execution_key=exec_key)
    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,
        execution_key=exec_key)

    center = (width // 2, height // 2)
    patterns = [
        [(center[X], center[Y]), (center[X] - 1, center[1] + 1),
         (center[X] + 1, center[Y] + 1), (center[X] + 1, center[Y]),
         (center[X], center[1] - 1)],
        [(center[X], center[Y]), (center[X], center[1] + 1),
         (center[X] - 1, center[Y]), (center[X] + 1, center[Y]),
         (center[X] - 1, center[1] - 1), (center[X] + 1, center[Y] - 1),
         (center[X], center[Y] - 2)],
        [(center[X], center[Y]), (center[X], center[1] - 4),
         (center[X] - 2, center[Y]), (center[X] + 2, center[Y]),
         (center[X] - 2, center[Y] - 1), (center[X] + 2, center[Y] - 1),
         (center[X] - 2, center[Y] - 2), (center[X] + 2, center[Y] - 2),
         (center[X] - 2, center[Y] - 3), (center[X] + 2, center[Y] - 3),
         (center[X] - 2, center[Y] - 4), (center[X] + 2, center[Y] - 4)],
        [
            (center[X], center[Y]),
            (center[X] + 1, center[Y]),
            (center[X] - 1, center[Y]),
            (center[X] + 2, center[Y]),
            (center[X] - 2, center[Y]),
            (center[X] + 3, center[Y]),
            (center[X] - 3, center[Y]),
            (center[X] + 4, center[Y]),
            (center[X] - 4, center[Y]),
        ],
        [(center[X], center[Y]), (center[X] - 1, center[Y]),
         (center[X] - 2, center[Y]), (center[X] - 3, center[Y]),
         (center[X], center[Y] - 1), (center[X], center[Y] - 2),
         (center[X] - 4, center[Y] - 1), (center[X] - 1, center[Y] - 3),
         (center[X] - 4, center[Y] - 3)],
        [(center[X] - 1, center[Y]), (center[X] - 2, center[Y]),
         (center[X] + 1, center[Y]), (center[X] + 2, center[Y]),
         (center[X] - 1, center[Y] - 1), (center[X] - 2, center[Y] - 1),
         (center[X] + 1, center[Y] - 1), (center[X] + 2, center[Y] - 1),
         (center[X] - 1, center[Y] - 2), (center[X] - 1, center[Y] - 3),
         (center[X] - 1, center[Y] - 4), (center[X] + 1, center[Y] - 2),
         (center[X] + 1, center[Y] - 3), (center[X] + 1, center[Y] - 4),
         (center[X] - 3, center[Y] - 3), (center[X] - 3, center[Y] - 4),
         (center[X] - 3, center[Y] - 5), (center[X] - 2, center[Y] - 5),
         (center[X] + 3, center[Y] - 3), (center[X] + 3, center[Y] - 4),
         (center[X] + 3, center[Y] - 5), (center[X] + 2, center[Y] - 5)]
    ]
    populate_board(patterns, simulation)
    reset_env_attrs()