def run_batch(batch_size,
              US_strat,
              Iran_strat,
              default_strat="low",
              coop_multiplier=1,
              conflict_multiplier=1,
              coop_gain=0.01,
              war_cost=0.5,
              war_steal=0.5,
              power_scale=0.1):
    data = []

    for i in range(batch_size):
        data.append(
            run(end_at_tick=1000,
                US_strat=US_strat,
                Iran_strat=Iran_strat,
                default_strat=default_strat,
                coop_multiplier=coop_multiplier,
                conflict_multiplier=conflict_multiplier,
                coop_gain=coop_gain,
                war_cost=war_cost,
                war_steal=war_steal,
                power_scale=power_scale).get_model_run(0, 1000)[0])

    return data
Exemple #2
0
def figure_6_data():
    if not os.path.exists('Heatmaps'):
        os.makedirs('Heatmaps')

    data = np.array([]).reshape(0, 50)

    for coop in np.arange(0.14, 0.71, 0.01):
        result = run(cooperate_probability=coop).get_log_wealth_heatmap(
            0, 0.05, 51)[:, 1:]
        data = np.concatenate([data, result])

    np.savetxt('Heatmaps/CooperateHeatmap.csv', data, fmt='%d', delimiter=',')
Exemple #3
0
def figure_10_data():
    if not os.path.exists('Dwell Time'):
        os.makedirs('Dwell Time')

    data = np.array([]).reshape([0, 2])

    for _ in range(10):
        data = np.concatenate([data, run(linear_power=False).get_dwell_time()])

    np.savetxt('Dwell Time/Logarithmic.csv',
               data,
               fmt=['%d', '%f'],
               delimiter=',')
Exemple #4
0
def figure_8_and_9_data():
    if not os.path.exists('Model Runs'):
        os.makedirs('Model Runs')

    data = run(end_at_tick=2001,
               cooperate_probability=0.3,
               linear_power=False,
               power_exponent=1.75).get_model_run(1000, 2001)
    np.savetxt('Model Runs/Log 0.3 coop.csv', data.T, fmt='%f', delimiter=',')

    data = run(end_at_tick=2001,
               cooperate_probability=0.5,
               linear_power=False,
               power_exponent=1.75).get_model_run(1000, 2001)
    np.savetxt('Model Runs/Log default.csv', data.T, fmt='%f', delimiter=',')

    data = run(end_at_tick=2001,
               cooperate_probability=0.7,
               linear_power=False,
               power_exponent=1.75).get_model_run(1000, 2001)
    np.savetxt('Model Runs/Log 0.7 coop.csv', data.T, fmt='%f', delimiter=',')

    data = run(end_at_tick=2001,
               cooperate_probability=0.5,
               linear_power=False,
               power_exponent=3.0).get_model_run(1000, 2001)
    np.savetxt('Model Runs/Log 3.0 exponent.csv',
               data.T,
               fmt='%f',
               delimiter=',')

    data = run(end_at_tick=2001,
               cooperate_probability=0.5,
               linear_power=False,
               power_exponent=1.0).get_model_run(1000, 2001)
    np.savetxt('Model Runs/Log 1.0 exponent.csv',
               data.T,
               fmt='%f',
               delimiter=',')
Exemple #5
0
def figure_3_data():
    if not os.path.exists('Model Runs'):
        os.makedirs('Model Runs')

    data = run(end_at_tick=2001,
               cooperate_probability=0.3).get_model_run(1000, 2001)
    np.savetxt('Model Runs/Linear 0.3 coop.csv',
               data.T,
               fmt='%f',
               delimiter=',')

    data = run(end_at_tick=2001,
               cooperate_probability=0.5).get_model_run(1000, 2001)
    np.savetxt('Model Runs/Linear default.csv',
               data.T,
               fmt='%f',
               delimiter=',')

    data = run(end_at_tick=2001,
               cooperate_probability=0.7).get_model_run(1000, 2001)
    np.savetxt('Model Runs/Linear 0.7 coop.csv',
               data.T,
               fmt='%f',
               delimiter=',')
Exemple #6
0
def figure_11_data():
    if not os.path.exists('Dwell Time'):
        os.makedirs('Dwell Time')

    data = np.array([]).reshape(0, 3)

    for exponent in [1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0]:
        result = run(linear_power=False,
                     power_exponent=exponent).get_dwell_time()
        exponent_values = np.array([[exponent]] * len(result))
        result = np.concatenate([exponent_values, result], axis=1)
        data = np.concatenate([data, result])

    np.savetxt('Dwell Time/LogarithmicColours.csv',
               data,
               fmt=['%.2f', '%d', '%f'],
               delimiter=',')
Exemple #7
0
def figure_5_data():
    if not os.path.exists('Dwell Time'):
        os.makedirs('Dwell Time')

    data = np.array([]).reshape(0, 3)

    for coop in [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7]:
        result = run(end_at_tick=100000,
                     cooperate_probability=coop).get_dwell_time()
        coop_values = np.array([[coop]] * len(result))
        result = np.concatenate([coop_values, result], axis=1)
        data = np.concatenate([data, result])

    np.savetxt('Dwell Time/LinearColours.csv',
               data,
               fmt=['%.1f', '%d', '%f'],
               delimiter=',')
Exemple #8
0
def figure_12_data():
    if not os.path.exists('Heatmaps'):
        os.makedirs('Heatmaps')

    data = np.array([]).reshape(0, 700)

    for exponent in np.arange(1.0, 3.01, 0.01):
        print('{:.1%} done'.format((exponent - 1) / 2))
        result = []
        for _ in range(4):
            result.append(
                run(linear_power=False,
                    power_exponent=exponent).get_log_wealth_heatmap(
                        -5, 0.01, 700))
        result = np.array(result).mean(axis=0)
        data = np.concatenate([data, result])

    np.savetxt('Heatmaps/ExponentHeatmap.csv', data, fmt='%g', delimiter=',')
Exemple #9
0
def figure_4_data():
    if not os.path.exists('Dwell Time'):
        os.makedirs('Dwell Time')

    data = run(end_at_tick=100000).get_dwell_time()
    np.savetxt('Dwell Time/Linear.csv', data, fmt=['%d', '%f'], delimiter=',')