Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. import json
  2. from mpl_toolkits.mplot3d import Axes3D
  3. from pprint import pprint
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6. #import pandas as pd
  7. import pygal
  8.  
  9. p1_x = []
  10. p1_y = []
  11. p2_x = []
  12. p2_y = []
  13.  
  14. with open('games_results.json', 'r') as f:
  15. file = json.load(f)
  16.  
  17. dos_1 = list(set([result["player_1"]["minmax_dept_of_search"] for result in file['results']]))
  18. iter_1 = list(set([result["player_1"]["montecarlo_iter_max"] for result in file['results']]))
  19. dos_1.sort()
  20. iter_1.sort()
  21. print(dos_1, iter_1)
  22.  
  23. mc_i1 = []
  24. whiteWins = []
  25. blackWins = []
  26. draw_l = []
  27. for iter in iter_1:
  28. a = 0
  29. whitewon, blackwon, draw = 0, 0, 0
  30. for result in file["results"]:
  31. if result["player_1"]["montecarlo_iter_max"] == iter and result["player_1"]["player_type"] == "MonteCarlo" and \
  32. result["board_size"] == 6 and result["player_2"]["montecarlo_iter_max"] == iter:
  33. if result["winner"] == "White":
  34. whitewon += 1
  35. elif result["winner"] == "Black":
  36. blackwon += 1
  37. else:
  38. draw += 1
  39. a += 1
  40. mc_i1.append(a)
  41. whiteWins.append(whitewon)
  42. blackWins.append(blackwon)
  43. draw_l.append(draw)
  44.  
  45. mc_i2 = []
  46. for iter in iter_1:
  47. a = 0
  48. for result in file["results"]:
  49. if result["player_2"]["montecarlo_iter_max"] == iter and result["player_2"]["player_type"] == "MonteCarlo":
  50. a += 1
  51. mc_i2.append(a)
  52.  
  53. # print(mc_i1, mc_i2)
  54.  
  55. print(whiteWins, blackWins, draw_l)
  56.  
  57. ind_1 = [1, 100] + [i*100 for i in range(2, 11, 2)] + [10000]
  58. ind = np.arange(len(ind_1))# the x locations for the groups
  59. width = 0.35 # the width of the bars: can also be len(x) sequence
  60.  
  61. fig, ax = plt.subplots()
  62.  
  63. p1 = ax.bar(ind, whiteWins, width, color='w', bottom=0)
  64. p2 = plt.bar(ind + width, blackWins, width, color='k', bottom=0)
  65. p3 = plt.bar(ind + width, draw_l, width, color='b', bottom=0)
  66.  
  67. ax.set_facecolor('g')
  68. ax.set_title('Scores by number of simulations (board size 6x6)')
  69. ax.set_xticks(ind + width / 2)
  70. ax.set_xlabel('Number of simulations')
  71. ax.set_ylabel('Number of Wins')
  72. ax.set_xticklabels(ind_1)
  73. ax.legend((p1[0], p2[0], p3[0]), ('Whites', 'Blacks', "Draws"))
  74. # plt.yticks(np.arange(0, 81, 10))
  75. #plt.savefig('Summary_SOB=' + str(SOB) + '.png')
  76. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement