Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Puissance4_Greub_Remi
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
remi.greub
Puissance4_Greub_Remi
Commits
23268279
Commit
23268279
authored
2 months ago
by
remi.greub
Browse files
Options
Downloads
Patches
Plain Diff
ajout gestion affichage
parent
545b5540
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
puissance4_GRB/main.c
+2
-2
2 additions, 2 deletions
puissance4_GRB/main.c
puissance4_GRB/puissance4.c
+98
-5
98 additions, 5 deletions
puissance4_GRB/puissance4.c
puissance4_GRB/puissance4.h
+2
-0
2 additions, 0 deletions
puissance4_GRB/puissance4.h
with
102 additions
and
7 deletions
puissance4_GRB/main.c
+
2
−
2
View file @
23268279
...
...
@@ -19,6 +19,7 @@ int main(int argc, char** argv){
}
init_puissance4
(
height
,
width
);
//print_game();
//print_gameCells();
int
win
=
Launch_puissance4
();
printf
(
"
\n
le winner c'est ça la : %d
\n
"
,
win
);
...
...
@@ -29,5 +30,4 @@ int main(int argc, char** argv){
// dessine une quadrillage puissance4.h
// créé un quadrillage virtuel puissance4.h
// trouve qui a gagner puissance4.h
\ No newline at end of file
// trouve qui a gagner puissance4.h
\ No newline at end of file
This diff is collapsed.
Click to expand it.
puissance4_GRB/puissance4.c
+
98
−
5
View file @
23268279
...
...
@@ -106,7 +106,8 @@ int Launch_puissance4(){
while
(
winner
==
EMPTY
){
//print_grille();
print_gameCells
();
//print_gameCells();
print_game
();
printf
(
"au tour de %d de jouer
\n
"
,
game
.
curr_player
);
printf
(
"balance un chiffre entre 0 et %d
\n
"
,
game
.
width
-
1
);
do
{
...
...
@@ -131,7 +132,8 @@ int Launch_puissance4(){
//il y a un bug de zinzin
printf
(
"ok la y a un bug de zinzin check ca
\n
"
);
//print la grille pour debug
print_gameCells
();
//print_gameCells();
print_game
();
//fin du jeu
return
-
1
;
//erreur
}
...
...
@@ -141,7 +143,8 @@ int Launch_puissance4(){
if
(
winner
!=
EMPTY
){
if
(
winner
==
CROSS
){
//reset du jeu + mise a jour des scores (scores optionels)
print_gameCells
();
//print_gameCells();
print_game
();
printf
(
"la croix a gagnée cette connasse
\n
"
);
//print joueur croix a gagné
//fin du jeu
...
...
@@ -150,7 +153,8 @@ int Launch_puissance4(){
if
(
winner
==
CIRCLE
){
//reset du jeu + mise a jour des scores (scores optionels)
//print joueur cercle a gagné
print_gameCells
();
//print_gameCells();
print_game
();
printf
(
"le cercle a gagné cet enorme zgeg
\n
"
);
//fin du jeu
return
CIRCLE
;
...
...
@@ -160,7 +164,8 @@ int Launch_puissance4(){
if
(
Is_Grid_full
()){
//la grille est pleine
//print egalite + la fin de la grille
print_gameCells
();
//print_gameCells();
print_game
();
printf
(
"y a un egalite dans les regles de l'art mash'allah
\n
"
);
//winner = EQUAL;
//fin du jeu
...
...
@@ -253,4 +258,92 @@ symbol_t CheckWin_in_a_direction(int dir[2], struct cell **grid, struct cell cel
}
}
return
result
;
}
void
print_game
(){
printf
(
"h:%d, w:%d
\n
"
,
game
.
height
,
game
.
width
);
//affiche ┌─┬─┬─┬─┬─┬─┬─┐
for
(
int
i
=
0
;
i
<
(
game
.
width
*
2
)
+
1
;
i
++
){
if
(
i
%
2
){
printf
(
"─"
);
}
else
{
if
(
i
==
0
){
printf
(
"┌"
);
}
else
if
(
i
==
(
game
.
width
*
2
)){
printf
(
"┐"
);
}
else
{
printf
(
"┬"
);
}
}
}
printf
(
"
\n
"
);
//affiche le jeu-> │ │ │X│O│ │ │ │
for
(
int
i
=
0
;
i
<
game
.
height
;
i
++
){
printf
(
"│"
);
for
(
int
j
=
0
;
j
<
game
.
width
;
j
++
){
if
(
game
.
cells
[
j
][(
game
.
height
-
i
)
-
1
].
symbol
==
EMPTY
){
printf
(
" "
);
}
else
if
(
game
.
cells
[
j
][(
game
.
height
-
i
)
-
1
].
symbol
==
CROSS
){
printf
(
"X"
);
}
else
if
(
game
.
cells
[
j
][(
game
.
height
-
i
)
-
1
].
symbol
==
CIRCLE
){
printf
(
"O"
);
}
else
{
printf
(
"E"
);
}
printf
(
"│"
);
}
printf
(
"
\n
"
);
if
(
i
<
game
.
height
-
1
){
//Dessine ├─┼─┼─┼─┼─┼─┼─┤ ...
for
(
int
cnt
=
0
;
cnt
<
((
game
.
width
*
2
)
+
1
);
cnt
++
){
if
(
cnt
%
2
){
printf
(
"─"
);
}
else
{
if
(
cnt
==
0
){
printf
(
"├"
);
}
else
if
(
cnt
==
(
game
.
width
*
2
)){
printf
(
"┤"
);
}
else
{
printf
(
"┼"
);
}
}
}
printf
(
"
\n
"
);
}
}
//Affiche └─┴─┴─┴─┴─┴─┴─┘
for
(
int
i
=
0
;
i
<
(
game
.
width
*
2
)
+
1
;
i
++
){
if
(
i
%
2
){
printf
(
"─"
);
}
else
{
if
(
i
==
0
){
printf
(
"└"
);
}
else
if
(
i
==
(
game
.
width
*
2
)){
printf
(
"┘"
);
}
else
{
printf
(
"┴"
);
}
}
}
printf
(
"
\n
"
);
//affiche les numéros
int
cnt
=
0
;
for
(
int
i
=
0
;
i
<
(
game
.
width
*
2
)
+
1
;
i
++
){
if
(
i
%
2
){
printf
(
"%d"
,
++
cnt
);
}
else
{
printf
(
" "
);
}
}
printf
(
"
\n
"
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
puissance4_GRB/puissance4.h
+
2
−
0
View file @
23268279
...
...
@@ -50,6 +50,8 @@ int is_cell_free(int j_p, int i, symbol_t symbol);
int
Launch_puissance4
();
bool
Is_Grid_full
();
void
print_game
();
symbol_t
Find_winner
(
struct
cell
**
grid
,
struct
cell
cellPlayed
);
symbol_t
CheckWin_in_a_direction
(
int
dir
[
2
],
struct
cell
**
grid
,
struct
cell
cell
);
...
...
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