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
3e585697
Commit
3e585697
authored
6 years ago
by
Dolleans Geoffrey
Browse files
Options
Downloads
Patches
Plain Diff
début de GoL en Pycharm
parent
947096df
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
+48
-0
48 additions, 0 deletions
game_of_life/Pygame_GoL.py
with
48 additions
and
0 deletions
game_of_life/Pygame_GoL.py
0 → 100644
+
48
−
0
View file @
3e585697
import
copy
import
pygame
from
pygame
import
*
import
random
as
rd
#couleur
RED
=
(
255
,
0
,
0
)
GREEN
=
(
0
,
255
,
255
)
BlACK
=
(
0
,
0
,
0
)
WHITE
=
(
0
,
0
,
0
)
#création de la classe cellule
class
cell
:
def
__init__
(
self
,
état
,
x
,
y
):
self
.
etat
=
état
self
.
voisin
=
0
self
.
x
=
x
self
.
y
=
y
#création de la grille
def
generate
(
size
):
"""
créer un univers rempli de cellule dans un état aléatoire de la taille donnée
"""
size_x
,
size_y
=
size
#initialise l'univers
universe
=
[]
for
x
in
range
(
size_x
):
universe
.
append
([])
for
y
in
range
(
size_y
):
#ajoute des cellules dans un état aléatoire à l'univers
universe
[
x
].
append
(
cellule
(
rd
.
randint
(
0
,
1
),
x
,
y
)
def
wrap_around
(
dx
,
dy
,
size
):
"""
Si on sort de l
'
univers on revient de l
'
autre coté
"""
size_x
,
size_y
=
size
if
dy
>
size_y
-
1
:
dy
=
0
elif
dy
<
0
:
dy
=
size_y
-
1
if
dx
>
size_x
-
1
:
dx
=
0
elif
dx
<
0
:
dx
=
size_x
-
1
return
dx
,
dy
def
count_voisin
(
cell
):
"""
place le nombre de voisin vivant de la cellule dans cell.voisin
"""
x
,
y
=
cell
.
x
,
cell
.
y
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