def visualize_forward_induction():
"""Illustration graphique de l'induction avant."""
fig, axes = plt.subplots(1, 2, figsize=(14, 5))
# Gauche: Arbre de jeu
ax1 = axes[0]
# Positions
positions = {
'root': (2, 3),
'out': (0, 2),
'game': (4, 2),
'j2_s': (3, 1),
'j2_h': (5, 1),
'ss': (2.5, 0),
'sh': (3.5, 0),
'hs': (4.5, 0),
'hh': (5.5, 0)
}
labels = {
'root': 'J1\n(In/Out)',
'out': '(2,2)',
'game': 'J1\n(S/H)',
'j2_s': 'J2',
'j2_h': 'J2',
'ss': '(4,4)',
'sh': '(0,3)',
'hs': '(3,0)',
'hh': '(3,3)'
}
colors = {
'root': 'lightblue',
'out': 'lightgray',
'game': 'lightblue',
'j2_s': 'lightgreen',
'j2_h': 'lightgreen',
'ss': 'gold',
'sh': 'lightgray',
'hs': 'lightgray',
'hh': 'lightyellow'
}
# Dessiner les noeuds
for node, pos in positions.items():
ax1.scatter(*pos, s=1500, c=colors[node], zorder=5, edgecolors='black')
ax1.annotate(labels[node], pos, ha='center', va='center', fontsize=9)
# Aretes
edges = [
('root', 'out', 'Out'),
('root', 'game', 'In'),
('game', 'j2_s', 'S'),
('game', 'j2_h', 'H'),
('j2_s', 'ss', 'S'),
('j2_s', 'sh', 'H'),
('j2_h', 'hs', 'S'),
('j2_h', 'hh', 'H')
]
for n1, n2, label in edges:
x1, y1 = positions[n1]
x2, y2 = positions[n2]
ax1.plot([x1, x2], [y1, y2], 'k-', linewidth=1.5)
ax1.annotate(label, ((x1+x2)/2, (y1+y2)/2 + 0.15), fontsize=9)
# Ellipse infoset J2
from matplotlib.patches import Ellipse
ellipse = Ellipse((4, 1), 3, 0.8, fill=False, linestyle='--',
edgecolor='red', linewidth=2)
ax1.add_patch(ellipse)
ax1.annotate('Infoset J2', (4, 0.3), ha='center', color='red', fontsize=10)
ax1.set_xlim(-0.5, 6.5)
ax1.set_ylim(-0.5, 3.5)
ax1.axis('off')
ax1.set_title('Arbre de jeu', fontsize=12)
# Droite: Raisonnement
ax2 = axes[1]
ax2.axis('off')
text = """
INDUCTION AVANT
1. J1 choisit In au lieu de Out (2,2)
2. Pourquoi renoncer a 2 garanti?
- Si J1 joue Hare: gain max = 3
- Si J1 joue Stag: gain = 4 ou 0
3. Raisonnement de J2:
"J1 est rationnel. S'il avait voulu
jouer Hare (risque 3 vs 2), ca aurait
du sens. MAIS s'il veut 4, il joue Stag.
Je devrais jouer Stag aussi."
4. Conclusion:
L'option exterieure "brule" l'equilibre
(Hare, Hare) car elle revele l'intention
de J1 de jouer Stag.
SPE selectionne: (In, Stag, Stag) -> (4, 4)
"""
ax2.text(0.1, 0.95, text, transform=ax2.transAxes, fontsize=11,
verticalalignment='top', fontfamily='monospace')
ax2.set_title('Raisonnement par induction avant', fontsize=12)
plt.tight_layout()
plt.show()
visualize_forward_induction()
2.2 Comment Rendre une Menace Credible?