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
5325da61
Commit
5325da61
authored
6 years ago
by
Dolleans Geoffrey
Browse files
Options
Downloads
Patches
Plain Diff
Chaque fonction séparément semble fonctionner
parent
f405dba3
No related branches found
Branches containing commit
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/Pygame_GoL.py
+9
-5
9 additions, 5 deletions
game_of_life/Pygame_GoL.py
with
9 additions
and
5 deletions
game_of_life/Pygame_GoL.py
+
9
−
5
View file @
5325da61
...
...
@@ -50,15 +50,17 @@ def count_voisin(cell, universe):
size
=
len
(
universe
),
len
(
universe
[
0
])
for
i
in
range
(
-
1
,
2
):
for
j
in
range
(
-
1
,
2
):
if
i
!=
0
and
j
!=
0
:
if
i
!=
0
or
j
!=
0
:
dx
,
dy
=
wrap_around
(
x
+
i
,
y
+
j
,
size
)
cell
.
voisin
+=
universe
[
dx
][
dy
].
etat
def
update
(
universe
):
for
x
in
range
(
len
(
universe
)):
for
y
in
range
(
len
(
universe
[
0
])):
count_voisin
(
universe
[
x
][
y
],
universe
)
def
decide_colour_nxt_state
(
cell
):
"""
change l
'
état de la cellule si nécessaire et renvoie la couleur qui la rpz
"""
if
cell
.
etat
==
1
:
...
...
@@ -93,6 +95,8 @@ def play():
mainsrf
.
fill
(
WHITE
)
universe
=
generate
(
size
)
time
.
sleep
(
5
)
taille_rect_x
=
500
/
size_x
taille_rect_y
=
500
/
size_y
while
1
:
#tracking quitting
for
event
in
pygame
.
event
.
get
():
...
...
@@ -100,13 +104,13 @@ def play():
pygame
.
quit
()
sys
.
exit
()
#drawing
for
y
in
range
(
size
[
0
]):
for
x
in
range
(
size
[
1
]):
pygame
.
draw
.
rect
(
mainsrf
,
decide_colour_nxt_state
(
universe
[
x
][
y
]),
(
x
*
10
,
y
*
10
,
10
,
10
))
for
x
in
range
(
size
[
0
]):
for
y
in
range
(
size
[
1
]):
pygame
.
draw
.
rect
(
mainsrf
,
decide_colour_nxt_state
(
universe
[
x
][
y
]),
(
x
*
taille_rect_x
,
y
*
taille_rect_y
,
taille_rect_x
,
taille_rect_y
))
update
(
universe
)
scrn
.
blit
(
mainsrf
,
(
0
,
0
))
pygame
.
display
.
update
()
time
.
sleep
(
1
)
time
.
sleep
(
5
)
if
__name__
==
"
__main__
"
:
play
()
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