Skip to content
Snippets Groups Projects
Commit 52d40b53 authored by Boujerfaoui Yassine's avatar Boujerfaoui Yassine
Browse files

Midification de la fonction GoL Simulate

parent bd1f4dd8
No related branches found
No related tags found
No related merge requests found
......@@ -11,10 +11,12 @@ def simulate(size, type_seed, iterations):
#Création de l'univers et ajout de la graine
universe = generate_universe(size)
seed = create_seed(type_seed)
print(seed)
#Placement aléatoire de la graine
x_start = rd.randint(0,size[0]-len(seed))
y_start = rd.randint(0,size[1]-len(seed[0]))
universe = add_seed_to_universe(seed,universe, x_start, y_start)
universe = add_seed_to_universe(seed,universe,x_start,y_start)
print(universe)
fig = plt.figure()
ax = plt.axes(xlim=(-1,size[1]+1),ylim=(-1,size[0]+1))
plt.gca().invert_yaxis()
......@@ -37,5 +39,4 @@ def simulate(size, type_seed, iterations):
ani = animation.FuncAnimation(fig, animate, init_func=init, frames=iterations, blit=True, interval=20, repeat=False)
plt.show()
if "__name__" = "__main__":
simulate((6,6), "beacon", 20)
simulate((6,6),"beacon",20)
......@@ -2,7 +2,7 @@ import numpy as np
def generate_universe(size):
"Crée un univers remplie de cellules mortes à partir de la donnée d'un couple représentant les dimensions"
universe=np.array([[0 for j in range(0,size[1])]for i in range(0,size[0])])
universe=np.array([[0 for j in range(0,size[0])]for i in range(0,size[1])])
return universe
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment