Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coding Week Gol Dolleans Boujerfaoui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Boujerfaoui Yassine
Coding Week Gol Dolleans Boujerfaoui
Commits
f498786a
Commit
f498786a
authored
6 years ago
by
Boujerfaoui Yassine
Browse files
Options
Downloads
Patches
Plain Diff
Ajout de commentaires à GoL Simulate (Fonctionnalité 8)
parent
b8184db2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
game_of_life/GoL_simulate.py
+11
-6
11 additions, 6 deletions
game_of_life/GoL_simulate.py
with
11 additions
and
6 deletions
game_of_life/GoL_simulate.py
+
11
−
6
View file @
f498786a
...
...
@@ -8,32 +8,37 @@ from matplotlib import animation
import
random
as
rd
def
simulate
(
size
,
type_seed
,
iterations
):
#Création de l'univers et ajout de la graine
"""
Size : taille de l
'
univers , Type_Seed : Type de la graine , Iterations : Nombre d
'
iterations d
'
univers
"""
"""
Création de l
'
univers et ajout de la graine
"""
universe
=
generate_universe
(
size
)
seed
=
create_seed
(
type_seed
)
#Placement aléatoir
e de la graine
"""
Choix aléatoire des coordonnées de la position aléatoire de la cellule tout en haut en gauch
e de la graine
"""
x_start
=
rd
.
randint
(
0
,
size
[
0
]
-
len
(
seed
))
y_start
=
rd
.
randint
(
0
,
size
[
1
]
-
len
(
seed
[
0
]))
"""
Ajout de la graine dans l
'
univers
"""
universe
=
add_seed_to_universe
(
seed
,
universe
,
x_start
,
y_start
)
"""
Gestion d
'
exceptions
"""
try
:
x_start
=
rd
.
randint
(
0
,
size
[
0
]
-
len
(
seed
))
y_start
=
rd
.
randint
(
0
,
size
[
1
]
-
len
(
seed
[
0
]))
except
:
print
(
"
la graine est trop grande pour l
'
univers
"
)
plt
.
imshow
(
universe
)
fig
=
plt
.
figure
()
im
=
plt
.
imshow
(
universe
,
cmap
=
"
Greys
"
,
animated
=
True
)
"""
cmap : Chaine de caractère de coloriation de la figure , animated : Variable booléene pour l
'
activation de l
'
animation
"""
"""
Fonction d
'
animation
"""
def
animate
(
i
):
universe
=
im
.
get_array
()
im
.
set_array
(
generation
(
universe
))
return
im
,
anim
=
animation
.
FuncAnimation
(
fig
,
animate
,
interval
=
500
,
frames
=
iterations
,
blit
=
True
)
"""
Interval : le nombre de millisecondes entre deux mise à jour de la figure
"""
plt
.
show
()
"""
Exécution de la fonction pour la grille beacon du dictionnaire seeds
"""
simulate
((
6
,
6
),
"
beacon
"
,
10
)
def
main
():
"""
def main():
x = int(input(
"
Entrer la largeur de l
'
univers
"
))
y = int(input(
"
Entrer la hauteur de l
'
univers
"
))
type_seed = input(
"
Entrer le type de graine
"
)
...
...
@@ -42,4 +47,4 @@ def main():
if __name__ ==
"
__main__
"
:
main
()
main()
"""
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment