2017-03-08 10:32:11 +01:00
|
|
|
import matplotlib.pyplot as plt; plt.rcdefaults()
|
|
|
|
import numpy as np
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
from pylab import *
|
|
|
|
|
|
|
|
|
2017-03-08 10:56:11 +01:00
|
|
|
TailleGrilleX = 15
|
|
|
|
TailleGrilleY = 15
|
2017-03-08 10:32:11 +01:00
|
|
|
GrilleInitiale = 0
|
|
|
|
HistoriqueGrille = list()
|
|
|
|
StratsResultats = list()
|
|
|
|
ListeStrategies = list()
|
|
|
|
|
2017-03-08 12:01:38 +01:00
|
|
|
def simulation():
|
|
|
|
"""->Grille"""
|
|
|
|
iterations = 0
|
|
|
|
while iterations <= MaxIterations :
|
|
|
|
partie_globale()
|
|
|
|
pass
|
2017-03-08 10:32:11 +01:00
|
|
|
|
2017-03-09 12:26:24 +01:00
|
|
|
def matStratIté(i):
|
2017-03-08 11:46:07 +01:00
|
|
|
array*str-> array
|
2017-03-09 12:26:24 +01:00
|
|
|
"""Récupère la matrice avec seulement le paramètre stratégie pour chaque joueur , à litération i voulue"""
|
2017-03-08 10:32:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
matR = np.random.randint(0,1,TailleGrilleX,TailleGrilleY)
|
|
|
|
|
2017-03-08 12:26:00 +01:00
|
|
|
matrice = HistoriqueGrille[i]
|
|
|
|
|
2017-03-08 10:32:11 +01:00
|
|
|
for ligne in range (0,TailleGrilleX): #int ligne
|
|
|
|
for colonne in range (0, TailleGrilleY): #int colonne
|
2017-03-09 12:26:24 +01:00
|
|
|
matStrat[ligne][colonne]=matrice[ligne][colonne]['strategie']
|
2017-03-08 11:02:26 +01:00
|
|
|
|
2017-03-08 12:26:00 +01:00
|
|
|
return matStrat
|
|
|
|
|
|
|
|
|
2017-03-08 12:07:10 +01:00
|
|
|
|
|
|
|
|
2017-03-08 12:26:00 +01:00
|
|
|
|
2017-03-08 12:00:03 +01:00
|
|
|
|
2017-03-08 10:32:11 +01:00
|
|
|
def bar_chart():
|
|
|
|
"""array->graph
|
2017-03-08 11:56:06 +01:00
|
|
|
Retourne les diagrammes en baton qui mettent en évidence le nombre d'années
|
2017-03-08 12:26:00 +01:00
|
|
|
de prison en fonction de la stratégie et le nombre d'utilisation de chaque stratégies """
|
2017-03-08 11:56:06 +01:00
|
|
|
|
2017-03-08 10:32:11 +01:00
|
|
|
|
2017-03-09 12:26:24 +01:00
|
|
|
|
2017-03-08 10:32:11 +01:00
|
|
|
#initialisation des paramètres
|
|
|
|
#list gain
|
|
|
|
gain=[]
|
|
|
|
#list strat
|
2017-03-09 12:26:24 +01:00
|
|
|
stratUtili=[]
|
2017-03-08 10:32:11 +01:00
|
|
|
|
|
|
|
for i in range(5):
|
|
|
|
|
|
|
|
gain.append(0)
|
2017-03-09 12:26:24 +01:00
|
|
|
stratUtili.append(0)
|
2017-03-08 10:32:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-08 11:45:12 +01:00
|
|
|
for i in range(0,len(ListeStrategies)):
|
2017-03-09 12:26:24 +01:00
|
|
|
stratUtili[i]=StratsResultats[i]['nb_utilisations']
|
2017-03-08 11:45:12 +01:00
|
|
|
gain[i]=StratsResultats[i]['total_ans_prisons']
|
|
|
|
|
2017-03-08 10:32:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Strat=('1','2', '3','4' ,'5')
|
|
|
|
|
|
|
|
x_pos = np.arange(len(Strat))
|
|
|
|
|
|
|
|
plt.subplot(221)
|
|
|
|
|
|
|
|
plt.bar(x_pos, gain, align='center', color='b' )
|
|
|
|
|
|
|
|
plt.xlabel("Stratégies")
|
|
|
|
plt.ylabel("Nombre d'années de prison")
|
|
|
|
|
|
|
|
plt.subplot(222)
|
2017-03-09 12:26:24 +01:00
|
|
|
plt.bar(x_pos, stratUtili, align='center' , color='r')
|
2017-03-08 10:32:11 +01:00
|
|
|
plt.xlabel("Stratégies")
|
|
|
|
plt.ylabel("NB individus ayant adopté stratégie")
|
|
|
|
|
|
|
|
|
|
|
|
plt.xticks(x_pos,Strat)
|
|
|
|
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-08 10:56:11 +01:00
|
|
|
|