Exemple #1
0
# coding: utf-8
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')
Exemple #2
0
import matplotlib.pyplot as plt
import seaborn as sns

if __name__ == "__main__":
    # set agent num
    agent_num = 201
    # set round number from 10000 to 100000
    round_num = 10000
    depth_grid = range(3,11)
    strategy_num = [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_grid:
        for sn in strategy_num:
            game = MinorityGameWithStrategyTable(agent_num, round_num,depth,sn)
            game.run_game()
            mean,stdd = game.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")

    g = sns.factorplot(x="d", y="std", hue="strategy_num", data=result,
                       palette="YlGnBu_d", size=6, aspect=1.3)
    plt.xlabel('Memory Size')
    plt.ylabel('winner number stdd')
Exemple #3
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())
Exemple #4
0
import matplotlib.pyplot as plt
import seaborn as sns

if __name__ == "__main__":
    # set agent num
    agent_num = 201
    # set round number from 10000 to 100000
    round_num = 10000
    depth_grid = range(3, 11)
    strategy_num = [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_grid:
        for sn in strategy_num:
            game = MinorityGameWithStrategyTable(agent_num, round_num, depth,
                                                 sn)
            game.run_game()
            mean, stdd = game.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")