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-08 11:57:26 +01:00
|
|
|
def recup_mat(matrice, param):
|
2017-03-08 11:46:07 +01:00
|
|
|
array*str-> array
|
2017-03-08 10:32:11 +01:00
|
|
|
Récupère la matrice avec seulement le paramètre (état,strat,années de prison) voulu afin de pouvoir avoir les stats plus facilement"""
|
|
|
|
|
|
|
|
|
|
|
|
matR = np.random.randint(0,1,TailleGrilleX,TailleGrilleY)
|
|
|
|
|
|
|
|
for ligne in range (0,TailleGrilleX): #int ligne
|
|
|
|
for colonne in range (0, TailleGrilleY): #int colonne
|
2017-03-08 11:45:12 +01:00
|
|
|
matR[ligne][colonne]=Grille [ligne][colonne][param]
|
2017-03-08 11:02:26 +01:00
|
|
|
|
2017-03-08 11:57:26 +01:00
|
|
|
return matR
|
2017-03-08 12:07:10 +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
|
|
|
|
de prison en fonction de la stratégie et le nombre d'utilisation de chaque stratégies
|
|
|
|
|
2017-03-08 10:32:11 +01:00
|
|
|
|
2017-03-08 11:45:12 +01:00
|
|
|
matStrat=recup_mat('strategie')
|
|
|
|
matGain= recup_mat('annees_de_prison')
|
2017-03-08 10:32:11 +01:00
|
|
|
|
|
|
|
#initialisation des paramètres
|
|
|
|
#list gain
|
|
|
|
gain=[]
|
|
|
|
#list strat
|
|
|
|
strat=[]
|
|
|
|
|
|
|
|
for i in range(5):
|
|
|
|
|
|
|
|
gain.append(0)
|
|
|
|
strat.append(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-08 11:45:12 +01:00
|
|
|
for i in range(0,len(ListeStrategies)):
|
|
|
|
strat[i]=StratsResultats[i]['nb_utilisations']
|
|
|
|
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)
|
|
|
|
plt.bar(x_pos, strat, align='center' , color='r')
|
|
|
|
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
|
|
|
|