# Graphiques de resultats
fig, axes = plt.subplots(1, 3, figsize=(18, 6))
# 1. Barres empilees : victoires / nuls / defaites
ax = axes[0]
names_ranked = [name for name, _ in ranked]
wins_list = [results[n]['wins'] for n in names_ranked]
draws_list = [results[n]['draws'] for n in names_ranked]
losses_list = [results[n]['losses'] for n in names_ranked]
x = range(len(names_ranked))
ax.bar(x, wins_list, label='Victoires', color='#4CAF50', edgecolor='black')
ax.bar(x, draws_list, bottom=wins_list, label='Nuls', color='#FFC107', edgecolor='black')
bottom2 = [w + d for w, d in zip(wins_list, draws_list)]
ax.bar(x, losses_list, bottom=bottom2, label='Defaites', color='#F44336', edgecolor='black')
ax.set_xticks(x)
ax.set_xticklabels(names_ranked, rotation=30, ha='right', fontsize=9)
ax.set_ylabel('Nombre de parties', fontsize=11)
ax.set_title('Resultats par IA', fontsize=13, fontweight='bold')
ax.legend(fontsize=9)
ax.grid(axis='y', alpha=0.3)
# 2. Score (3 pts/victoire, 1 pt/nul)
ax = axes[1]
scores = [results[n]['wins'] * 3 + results[n]['draws'] for n in names_ranked]
colors = ['#1565C0', '#42A5F5', '#64B5F6', '#90CAF9', '#BBDEFB']
bars = ax.bar(x, scores, color=colors[:len(x)], edgecolor='black')
for bar, s in zip(bars, scores):
ax.text(bar.get_x() + bar.get_width() / 2, bar.get_height() + 0.5,
str(s), ha='center', va='bottom', fontsize=11, fontweight='bold')
ax.set_xticks(x)
ax.set_xticklabels(names_ranked, rotation=30, ha='right', fontsize=9)
ax.set_ylabel('Score (3V + 1N)', fontsize=11)
ax.set_title('Classement', fontsize=13, fontweight='bold')
ax.grid(axis='y', alpha=0.3)
# 3. Temps moyen par coup
ax = axes[2]
avg_times = [np.mean(results[n]['times']) * 1000 if results[n]['times'] else 0 for n in names_ranked]
bars = ax.bar(x, avg_times, color='#FF7043', edgecolor='black')
for bar, t in zip(bars, avg_times):
ax.text(bar.get_x() + bar.get_width() / 2, bar.get_height(),
f"{t:.0f}", ha='center', va='bottom', fontsize=9)
ax.set_xticks(x)
ax.set_xticklabels(names_ranked, rotation=30, ha='right', fontsize=9)
ax.set_ylabel('Temps moyen (ms/coup)', fontsize=11)
ax.set_title('Cout en temps de calcul', fontsize=13, fontweight='bold')
ax.grid(axis='y', alpha=0.3)
plt.suptitle('Tournoi Puissance 4 -- 5 IA, 20 parties par paire',
fontsize=14, fontweight='bold', y=1.02)
plt.tight_layout()
plt.show()