<commit_before>import numpy as np
import matplotlib.pyplot as plt
import logging
from time import time

from players.players import generate_players
from games.games import NIPDGame, PGGGame, PGGiGame, PGGiNetwork
from network.network import regular_network, scale_free_network

logger = logging.getLogger(__name__)

N = 200
HUMAN_PLAYER = False
PMATRIX = np.array([[0.8, 0.0],
                    [1.0, 0.2]])
GENERATIONS = 2000
THRESHOLD = 0
cost = 1.0
# r = 3
r_min = 1.25
r_max = 5.0
r_step = 0.25
nu = 1.0
runs = 1
realizations = 1
ncoop = 0.5
ninsp = 0.0
z = 4
show_micro_simulations = True
store_plots = False
store_plots_dir = ""
store_data = False
store_data_dir = ""

# players = generate_players(N, [['TFTPlayer', 0.8], ['RandomPlayer', 0.0], ['ParlovPlayer', 0.2]])
# game = NIPDGame(THRESHOLD, GENERATIONS, players)
# players = generate_players([['PureStrategyPlayer', 1.0]], nplayers=N, ncoop=0.5)
# game = PGGGame(players, threshold=THRESHOLD, generations=GENERATIONS, r=r, cost=cost)

# players = generate_players([['PureStrategyPlayer', 1.0]], nplayers=N, ncoop=ncoop, ninsp=ninsp)
# game = PGGiGame(players, threshold=THRESHOLD, generations=GENERATIONS, r=r, cost=cost, nu=nu)

players = generate_players([['PGGiPlayer', 1.0]], nplayers=N)
# regular_network(players, z)
scale_free_network(players, m0=5)
game = PGGiNetwork(players, threshold=THRESHOLD, generations=GENERATIONS, cost=cost, nu=nu)

if __name__ == "__main__":
    level = logging.INFO
    logging.basicConfig(level=level)

    x = np.arange(THRESHOLD, THRESHOLD + GENERATIONS)
    r_params = np.arange(r_min, r_max, r_step)
    coop_avg_run = np.empty([1, runs])
    insp_avg_run = np.empty([1, runs])
    coop_avg_real = np.empty([1, realizations])
    insp_avg_real = np.empty([1, realizations])
    coop_avg = np.arange(r_min, r_max, r_step)
    insp_avg = np.arange(r_min, r_max, r_step)

    if show_micro_simulations:
        plt.ion()  # Note this correction
        fig = plt.figure(1)
        ax = plt.axes(xlim=(-1, THRESHOLD + GENERATIONS), ylim=(-0.1, 1.2))

    for idx, r_param in enumerate(r_params):
        # Update r value
        logger.info("Starting simulation with r = %f", r_param)
        game.r = r_param
        r_start_time = time()
        for s in range(realizations):
            # Init graph<commit_msg>Changes on the game call.<commit_after>import numpy as np
import matplotlib.pyplot as plt
import logging
from time import time

from players.players import generate_players
from games.games import NIPDGame, PGGGame, PGGiGame, PGGiNetwork
from network.network import regular_network, scale_free_network

logger = logging.getLogger(__name__)

N = 500
HUMAN_PLAYER = False
PMATRIX = np.array([[0.8, 0.0],
                    [1.0, 0.2]])
GENERATIONS = 100
THRESHOLD = 100000
cost = 1.0
# r = 3
r_min = 0.00
r_max = 5.25
r_step = 0.25
nu = 1.0
runs = 1
realizations = 1
ncoop = 0.5
ninsp = 0.0
z = 4
show_micro_simulations = True
store_plots = False
store_plots_dir = ""
store_data = False
store_data_dir = ""

# players = generate_players(N, [['TFTPlayer', 0.8], ['RandomPlayer', 0.0], ['ParlovPlayer', 0.2]])
# game = NIPDGame(THRESHOLD, GENERATIONS, players)
# players = generate_players([['PureStrategyPlayer', 1.0]], nplayers=N, ncoop=0.5)
# game = PGGGame(players, threshold=THRESHOLD, generations=GENERATIONS, r=r, cost=cost)

# players = generate_players([['PureStrategyPlayer', 1.0]], nplayers=N, ncoop=ncoop, ninsp=ninsp)
# game = PGGiGame(players, threshold=THRESHOLD, generations=GENERATIONS, r=r, cost=cost, nu=nu)

players = generate_players([['PGGiPlayer', 1.0]], nplayers=N)
# players = generate_players([['PureStrategyPlayer', 1.0]], nplayers=N)
regular_network(players, z)
# scale_free_network(players, m0=5)
game = PGGiNetwork(players, threshold=THRESHOLD, generations=GENERATIONS, cost=cost, nu=nu)
# game = PGGGame(players, threshold=THRESHOLD, generations=GENERATIONS, cost=cost)

if __name__ == "__main__":
    level = logging.INFO
    logging.basicConfig(level=level)

    x = np.arange(THRESHOLD, THRESHOLD + GENERATIONS)
    r_params = np.arange(r_min, r_max, r_step)
    coop_avg_run = np.empty([1, runs])
    insp_avg_run = np.empty([1, runs])
    coop_avg_real = np.empty([1, realizations])
    insp_avg_real = np.empty([1, realizations])
    coop_avg = np.arange(r_min, r_max, r_step)
    insp_avg = np.arange(r_min, r_max, r_step)

    if show_micro_simulations:
        plt.ion()  # Note this correction
        fig = plt.figure(1)
        ax = plt.axes(xlim=(-1, THRESHOLD + GENERATIONS), ylim=(-0.1, 1.2))

    for idx, r_param in enumerate(r_params):
        # Update r value
        logger.info("Starting simulation with r = %f", r_param)
        game.r = r_param
        r_start_time = time()
        for s in range(realizations):
            # Init graph
{'fraction_non_alphanumeric': 0.13093255620316402, 'fraction_numerical': 0.02726894254787677, 'mean_word_length': 4.177801724137931, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4453775', 'n_tokens_mistral': 1900, 'n_tokens_neox': 1806, 'n_words': 406}