Update genForet.py
Respect norme PEP 8
This commit is contained in:
parent
c763e17923
commit
489a8bbb21
1 changed files with 67 additions and 61 deletions
10
genForet.py
10
genForet.py
|
|
@ -7,7 +7,6 @@ Created on Fri Feb 1 11:30:02 2019
|
|||
import numpy as np
|
||||
import random
|
||||
import tkinter as tk
|
||||
from PIL import Image
|
||||
"""
|
||||
Les états possibles de nos cases :
|
||||
- 0 : pas d'arbre
|
||||
|
|
@ -16,6 +15,8 @@ from PIL import Image
|
|||
- -2 : un arbre mort
|
||||
"""
|
||||
# Fonctions agissant sur la matrice
|
||||
|
||||
|
||||
def genForet(n, p):
|
||||
if n >= 2:
|
||||
foret = np.full(shape=(n, n), fill_value=0)
|
||||
|
|
@ -27,6 +28,7 @@ def genForet(n,p):
|
|||
else:
|
||||
raise ValueError("n doit prendre une valeur de 2 au moins")
|
||||
|
||||
|
||||
def enflammer(foret, x, y): # Fonction mettant le feu aléatoirement à une case
|
||||
if x == -1:
|
||||
x = random.randint(0, foret.shape[0]-1)
|
||||
|
|
@ -58,6 +60,7 @@ def propager(F,k,i,j):
|
|||
except IndexError:
|
||||
pass
|
||||
|
||||
|
||||
def feuDeForet(F):
|
||||
k = 2
|
||||
while -1 in F[k-1]:
|
||||
|
|
@ -86,6 +89,7 @@ def wildfire(n, p, x=-1, y=-1):
|
|||
feuDeForet(F)
|
||||
return F
|
||||
|
||||
|
||||
def affichage(F):
|
||||
for k in range(0, len(F)):
|
||||
fenetre = tk.Tk() # Crée la fenêtre que l'on va modifier
|
||||
|
|
@ -104,8 +108,10 @@ def affichage(F):
|
|||
canvas.pack()
|
||||
bouton = tk.Button(fenetre, text="Suivant", command=fenetre.destroy)
|
||||
bouton.pack()
|
||||
fenetre.mainloop() #affiche la fenêtre
|
||||
fenetre.mainloop() # Affiche la fenêtre
|
||||
|
||||
|
||||
# Fonctions utiles à l'affichage
|
||||
|
||||
def pause():
|
||||
input("Appuyer sur Entrée pour continuer . . .")
|
||||
Loading…
Add table
Reference in a new issue