Exemplo n.º 1
0
from src.minority_game import  MinorityGameWithStrategyTable
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
if __name__ == "__main__":
    # set agent num
    agent_num = 201
    # set round number from 10000 to 100000
    round_num = 100000
    depth = 3
    strategy_num = 2
    mean_list = []
    stdd_list = []
    # Run the game for different round number
    game = MinorityGameWithStrategyTable(agent_num, round_num,depth,strategy_num)
    mean_list,stdd_list = game.run_game()

    # print result
    print(mean_list)
    print(stdd_list)
    # plot mean
    rounds = list(range(10000,110000,10000))
    fig = plt.figure(figsize=(10, 4))
    plt.plot(rounds,mean_list)
    plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.2)

    fig.suptitle('Mean Value')
    plt.xlabel('Iteration number')
    plt.ylabel('Average numbers of winners')
    fig.savefig('ex3-2-S2-D3-mean.jpg')
Exemplo n.º 2
0
# !/usr/bin/env python3
# coding: utf-8
from src.minority_game import MinorityGameWithStrategyTable
game = MinorityGameWithStrategyTable(201, 50000, 3, 2,64)
game.run_game()
print(game.winner_for_diff_group())
Exemplo n.º 3
0
from src.minority_game import  MinorityGameWithStrategyTable
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
if __name__ == "__main__":
    # set agent num
    agent_number = 201
    # set round number from 10000 to 100000
    round_number = 100000
    depth = 3
    strategy_number = 2
    means = []
    stdds = []
    # Run the game for different round number
    mg = MinorityGameWithStrategyTable(agent_number, round_number,depth,strategy_number)
    means,stdds = mg.run_game()

    # print result
    print(means)
    print(stdds)
    # plot mean
    round_number = list(range(10000,110000,10000))
    fig = plt.figure(figsize=(10, 4))
    plt.plot(round_number,means)
    plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.2)

    fig.suptitle('Mean Value')
    plt.xlabel('Iteration number')
    plt.ylabel('Average numbers of winners')
    fig.savefig('ex3-2-S2-D3-mean.jpg')
Exemplo n.º 4
0
# !/usr/bin/env python3
# coding: utf-8
from src.minority_game import MinorityGameWithStrategyTable
game = MinorityGameWithStrategyTable(201, 50000, 3, 2, 64)
game.run_game()
print(game.winner_for_diff_group())
Exemplo n.º 5
0
if __name__ == "__main__":
    # set agent num
    agent_number = 201
    # set round number from 10000 to 100000
    round_number = 10000
    depth_range = range(3, 11)
    strategy_number = [3, 4, 8, 16, 32, 64]
    result = pd.DataFrame(columns=["strategy_num", "d", "mean", "std"])
    # Run the game for different round number
    i = 0
    for depth in depth_range:
        for sn in strategy_number:
            mg = MinorityGameWithStrategyTable(agent_number, round_number,
                                               depth, sn)
            mg.run_game()
            mean, stdd = mg.score_mean_std
            result.loc[i] = [sn, depth, mean, stdd]
            i += 1

    g = sns.factorplot(x="d",
                       y="mean",
                       hue="strategy_num",
                       data=result,
                       palette="YlGnBu_d",
                       size=6,
                       aspect=1.3)
    plt.xlabel('Memory Size')
    plt.ylabel('Average numbers of winners')
    g.savefig("differerentSDmean")