Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Puissance 4
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MAZAT Julian
Puissance 4
Commits
23f5568a
Commit
23f5568a
authored
Oct 10, 2023
by
MAZAT Julian
Browse files
Options
Downloads
Patches
Plain Diff
Ajoute la classe Grille
parent
4e48bfc9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
board.py
+58
-0
58 additions, 0 deletions
board.py
with
58 additions
and
0 deletions
board.py
0 → 100644
+
58
−
0
View file @
23f5568a
import
numpy
as
np
class
Grille
:
def
__init__
(
self
,
nLigne
,
nColonne
):
self
.
nLigne
=
nLigne
self
.
nColonne
=
nColonne
self
.
grille
=
np
.
zeros
((
nLigne
,
nColonne
))
# reinitialise la grille
def
reinit
(
self
):
self
.
grille
=
np
.
zeros
((
self
.
nLigne
,
self
.
nColonne
))
# affiche la grille
def
afficherGrid
(
self
):
print
(
np
.
flip
(
self
.
grille
,
0
))
# retourne la première position pouvant
# accueillir un jeton
def
premierLibre
(
self
,
colonne
):
for
row
in
range
(
self
.
nLigne
):
if
self
.
grille
[
row
,
colonne
]
==
0
:
return
row
# place un jeton du joueur donné
def
placer
(
self
,
row
,
colonne
,
joueur
):
self
.
grille
[
row
,
colonne
]
=
joueur
# vérifie si le joueur donné est gagnant
def
estGagant
(
self
,
joueur
):
for
r
in
range
(
self
.
nLigne
):
for
c
in
range
(
self
.
nColonne
-
3
):
if
self
.
grille
[
r
,
c
]
==
joueur
and
self
.
grille
[
r
,
c
+
1
]
==
joueur
and
self
.
grille
[
r
,
c
+
2
]
==
joueur
and
self
.
grille
[
r
,
c
+
3
]
==
joueur
:
return
True
for
r
in
range
(
self
.
nLigne
-
3
):
for
c
in
range
(
self
.
nColonne
):
if
self
.
grille
[
r
,
c
]
==
joueur
and
self
.
grille
[
r
+
1
,
c
]
==
joueur
and
self
.
grille
[
r
+
2
,
c
]
==
joueur
and
self
.
grille
[
r
+
3
,
c
]
==
joueur
:
return
True
for
r
in
range
(
self
.
nLigne
-
3
):
for
c
in
range
(
self
.
nColonne
-
3
):
if
self
.
grille
[
r
,
c
]
==
joueur
and
self
.
grille
[
r
+
1
,
c
+
1
]
==
joueur
and
self
.
grille
[
r
+
2
,
c
+
2
]
==
joueur
and
self
.
grille
[
r
+
3
,
c
+
3
]
==
joueur
:
return
True
for
r
in
range
(
3
,
self
.
nLigne
):
for
c
in
range
(
self
.
nColonne
-
3
):
if
self
.
grille
[
r
,
c
]
==
joueur
and
self
.
grille
[
r
-
1
,
c
+
1
]
==
joueur
and
self
.
grille
[
r
-
2
,
c
+
2
]
==
joueur
and
self
.
grille
[
r
-
3
,
c
+
3
]
==
joueur
:
return
True
return
False
#vérifie si la grille est pleine
def
estPlein
(
self
):
return
self
.
grille
.
all
()
# vérifie si une colonne est pleine
def
peutAccueillir
(
self
,
colonne
):
return
self
.
grille
[
self
.
nLigne
-
1
,
colonne
]
==
0
\ No newline at end of file
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