Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- from mpl_toolkits.mplot3d import Axes3D
- from pprint import pprint
- import matplotlib.pyplot as plt
- import numpy as np
- #import pandas as pd
- import pygal
- p1_x = []
- p1_y = []
- p2_x = []
- p2_y = []
- with open('games_results.json', 'r') as f:
- file = json.load(f)
- dos_1 = list(set([result["player_1"]["minmax_dept_of_search"] for result in file['results']]))
- iter_1 = list(set([result["player_1"]["montecarlo_iter_max"] for result in file['results']]))
- dos_1.sort()
- iter_1.sort()
- print(dos_1, iter_1)
- mc_i1 = []
- whiteWins = []
- blackWins = []
- draw_l = []
- for iter in iter_1:
- a = 0
- whitewon, blackwon, draw = 0, 0, 0
- for result in file["results"]:
- if result["player_1"]["montecarlo_iter_max"] == iter and result["player_1"]["player_type"] == "MonteCarlo" and \
- result["board_size"] == 6 and result["player_2"]["montecarlo_iter_max"] == iter:
- if result["winner"] == "White":
- whitewon += 1
- elif result["winner"] == "Black":
- blackwon += 1
- else:
- draw += 1
- a += 1
- mc_i1.append(a)
- whiteWins.append(whitewon)
- blackWins.append(blackwon)
- draw_l.append(draw)
- mc_i2 = []
- for iter in iter_1:
- a = 0
- for result in file["results"]:
- if result["player_2"]["montecarlo_iter_max"] == iter and result["player_2"]["player_type"] == "MonteCarlo":
- a += 1
- mc_i2.append(a)
- # print(mc_i1, mc_i2)
- print(whiteWins, blackWins, draw_l)
- ind_1 = [1, 100] + [i*100 for i in range(2, 11, 2)] + [10000]
- ind = np.arange(len(ind_1))# the x locations for the groups
- width = 0.35 # the width of the bars: can also be len(x) sequence
- fig, ax = plt.subplots()
- p1 = ax.bar(ind, whiteWins, width, color='w', bottom=0)
- p2 = plt.bar(ind + width, blackWins, width, color='k', bottom=0)
- p3 = plt.bar(ind + width, draw_l, width, color='b', bottom=0)
- ax.set_facecolor('g')
- ax.set_title('Scores by number of simulations (board size 6x6)')
- ax.set_xticks(ind + width / 2)
- ax.set_xlabel('Number of simulations')
- ax.set_ylabel('Number of Wins')
- ax.set_xticklabels(ind_1)
- ax.legend((p1[0], p2[0], p3[0]), ('Whites', 'Blacks', "Draws"))
- # plt.yticks(np.arange(0, 81, 10))
- #plt.savefig('Summary_SOB=' + str(SOB) + '.png')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement