45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
import json
|
|
from matplotlib import pyplot as plt
|
|
from island.match import Match
|
|
from island.matches import Matches
|
|
|
|
matches = Matches('wos-data-new')
|
|
max_round = 17
|
|
|
|
coopr = []
|
|
yerr_min = []
|
|
yerr_max = []
|
|
x = []
|
|
bx = []
|
|
|
|
survivals = {}
|
|
with open('winner.json','r') as f:
|
|
survivals = json.load(f)
|
|
|
|
for i in range(max_round):
|
|
co = []
|
|
for j in range(len(matches.data)):
|
|
nodes = set()
|
|
rows = matches.data[j].query('action', 'done').where(lambda x: x['rno']==i+1).raw_data
|
|
for row in rows:
|
|
nodes.add(row['a'])
|
|
nodes.add(row['b'])
|
|
|
|
if rows:
|
|
co.append(float(len(rows) * 2) / float(len(nodes)))
|
|
|
|
bx.append(co)
|
|
|
|
if co:
|
|
coopr.append(sum(co) / len(co))
|
|
|
|
yerr_min.append(coopr[-1] - min(co))
|
|
yerr_max.append(max(co) - coopr[-1])
|
|
print("%f, %f, %f"%(yerr_min[-1], yerr_max[-1], coopr[-1]))
|
|
x.append(i+1)
|
|
|
|
plt.figure()
|
|
# plt.errorbar(x, coopr, yerr=[yerr_min, yerr_max], fmt='o', capsize=4)
|
|
plt.boxplot(bx, showmeans=True, meanline=True)
|
|
plt.show()
|
|
# plt.savefig('graph/co_per_round.png') |