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
819097ef
Commit
819097ef
authored
6 years ago
by
Boujerfaoui Yassine
Browse files
Options
Downloads
Plain Diff
Test
parents
e2933ce9
af5995c2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
game_of_life/AffichageTkinter.py
+0
-89
0 additions, 89 deletions
game_of_life/AffichageTkinter.py
game_of_life/add_seed.py
+2
-0
2 additions, 0 deletions
game_of_life/add_seed.py
with
2 additions
and
89 deletions
game_of_life/AffichageTkinter.py
deleted
100644 → 0
+
0
−
89
View file @
e2933ce9
from
tkinter
import
*
from
game_of_life.generate_universe
import
*
from
game_of_life.generation
import
*
from
game_of_life.survival
import
*
from
game_of_life.add_seed
import
*
from
game_of_life.Affichage_universe
import
*
import
random
as
rd
fenetre
=
Tk
()
game_of_life
=
Toplevel
(
fenetre
,
width
=
1000
,
height
=
1000
)
game_of_life
.
grid
()
canvas
=
Canvas
(
game_of_life
)
canvas
.
pack
()
var_text
=
StringVar
ligne_texte
=
Entry
(
fenetre
,
textvariable
=
var_text
,
width
=
30
)
ligne_texte
.
pack
()
def
create_a_grid
():
"""
create the grid for the graphic interface
"""
global
universe
print
(
"
création de la grille
"
)
universe
=
generate_universe
((
100
,
100
))
width
=
game_of_life
.
winfo_width
()
heigth
=
game_of_life
.
winfo_height
()
global
zones
#contient l'ensemble des zones representant des cellules
zones
=
[]
for
x
in
range
(
len
(
universe
)):
zones
.
append
([])
for
y
in
range
(
len
(
universe
[
0
])):
if
universe
[
x
][
y
]
==
1
:
zones
[
x
].
append
(
canvas
.
create_rectangle
(
x
*
10
,
y
*
10
,(
x
+
1
)
*
10
,(
y
+
1
)
*
10
),
fill
=
"
black
"
)
else
:
zones
[
x
].
append
(
canvas
.
create_rectangle
(
x
*
10
,
y
*
10
,(
x
+
1
)
*
10
,(
y
+
1
)
*
10
,
fill
=
"
white
"
))
def
update_grid
():
"""
met la grille à jour
"""
global
universe
for
x
in
range
(
len
(
universe
)):
for
y
in
range
(
len
(
universe
[
0
])):
if
universe
[
x
][
y
]
==
0
:
if
naissance
(
universe
,(
x
,
y
))
==
1
:
"
colorier la case zones[x][y] en vert
"
canvas
.
itemconfig
(
zones
[
x
][
y
],
fill
=
"
green
"
)
else
:
"
colorier la case zones[x][y] en banc
"
canvas
.
itemconfig
(
zones
[
x
][
y
],
fill
=
"
white
"
)
else
:
if
survival
(
universe
,(
x
,
y
))
==
0
:
"
colorier la case zones[x][y] en rouge
"
canvas
.
itemconfig
(
zones
[
x
][
y
],
fill
=
"
red
"
)
else
:
"
colorier la case zones[x][y] en noir
"
canvas
.
itemconfig
(
zones
[
x
][
y
],
fill
=
"
black
"
)
universe
=
generation
(
universe
)
def
create_cell_on_click
(
event
):
"""
créer une cellule vivante la ou l
'
utilisateur clique
"""
global
universe
x
=
event
.
x
//
10
y
=
event
.
y
//
10
universe
[
x
][
y
]
=
1
def
add_seed_tk
():
"""
ajoute la graine donnée dans la fenetre principale
"""
global
universe
type_seed
=
ligne_texte
.
get
()
seed
=
create_seed
(
type_seed
)
try
:
x_start
=
rd
.
randint
(
0
,
100
-
len
(
seed
))
y_start
=
rd
.
randint
(
0
,
100
-
len
(
seed
[
0
]))
universe
=
add_seed_to_universe
(
seed
,
universe
,
x_start
,
y_start
)
except
:
print
(
"
la graine n
'
a pas été ajoutée
"
)
button_add_seed
=
Button
(
fenetre
,
text
=
"
ajoute la graine
"
,
command
=
add_seed_tk
)
button_add_seed
.
pack
()
button_next_step
=
Button
(
fenetre
,
text
=
"
go to next gen
"
,
command
=
update_grid
)
button_next_step
.
pack
()
create_a_grid
()
canvas
.
bind
(
"
<Button-1>
"
,
create_cell_on_click
)
fenetre
.
mainloop
()
This diff is collapsed.
Click to expand it.
game_of_life/add_seed.py
+
2
−
0
View file @
819097ef
...
...
@@ -51,6 +51,8 @@ def create_seed(type_seed):
return
seed
except
KeyError
:
print
(
"
Ce type de graine est inconnu
"
)
except
:
print
(
"
probleme lors de la création de la graine
"
)
...
...
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