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
501a7982
Commit
501a7982
authored
1 month ago
by
remi.greub
Browse files
Options
Downloads
Patches
Plain Diff
affichage pour reussir les tests
parent
31f42163
Branches
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
puissance4_GRB/main.c
+8
-6
8 additions, 6 deletions
puissance4_GRB/main.c
puissance4_GRB/puissance4.c
+13
-9
13 additions, 9 deletions
puissance4_GRB/puissance4.c
with
21 additions
and
15 deletions
puissance4_GRB/main.c
+
8
−
6
View file @
501a7982
...
...
@@ -6,23 +6,25 @@
int
main
(
int
argc
,
char
**
argv
){
if
((
argc
<
2
)
||
(
argc
>
3
)){
if
((
argc
<
3
)
||
(
argc
>
4
)){
printf
(
"il manque des arguments
\n
"
);
return
EXIT_FAILURE
;
}
int
mode
=
atoi
(
argv
[
1
]);
//a gérer pour plus tard...
int
width
=
0
;
int
height
=
atoi
(
argv
[
1
]);
if
(
argc
<
3
){
width
=
atoi
(
argv
[
1
]);
}
else
{
int
height
=
atoi
(
argv
[
2
]);
if
(
argc
<
4
){
width
=
atoi
(
argv
[
2
]);
}
else
{
width
=
atoi
(
argv
[
3
]);
}
printf
(
"Board size is %dx%d (rows x col)
\n
"
,
height
,
width
);
init_puissance4
(
height
,
width
);
//print_game();
//print_gameCells();
int
win
=
Launch_puissance4
();
printf
(
"
\n
le winner c'est ça la : %d
\n
"
,
win
);
//
printf("\nle winner c'est ça la : %d\n",win);
//ici on va gérer probablement si on veut mettre a jour un score et relancer une nouvelle partie jusqu'à ce que l'utilisateur veut arrêter
return
EXIT_SUCCESS
;
...
...
This diff is collapsed.
Click to expand it.
puissance4_GRB/puissance4.c
+
13
−
9
View file @
501a7982
...
...
@@ -44,11 +44,11 @@ void print_gameCells(){
void
init_puissance4
(
int
height
,
int
width
){
game
.
players
[
1
].
check_win
=
0
;
game
.
players
[
1
].
score
=
0
;
game
.
players
[
1
].
symbol
=
C
ROSS
;
game
.
players
[
1
].
symbol
=
C
IRCLE
;
game
.
players
[
0
].
check_win
=
0
;
game
.
players
[
0
].
score
=
0
;
game
.
players
[
0
].
symbol
=
C
IRCLE
;
game
.
players
[
0
].
symbol
=
C
ROSS
;
game
.
curr_player
=
0
;
game
.
height
=
height
;
...
...
@@ -108,8 +108,9 @@ int Launch_puissance4(){
//print_grille();
//print_gameCells();
print_game
();
printf
(
"au tour de %d de jouer
\n
"
,
game
.
curr_player
);
printf
(
"balance un chiffre entre 1 et %d
\n
"
,
game
.
width
);
printf
(
"Column number? (starts at 1):
\n
"
);
//printf("au tour de %d de jouer\n", game.curr_player);
//printf("balance un chiffre entre 1 et %d\n", game.width);
do
{
scanf
(
"%d"
,
&
chiffre
);
chiffre
-=
1
;
//gestion des chiffres de 1 à n et non de 0 à n-1
...
...
@@ -146,7 +147,8 @@ int Launch_puissance4(){
//reset du jeu + mise a jour des scores (scores optionels)
//print_gameCells();
print_game
();
printf
(
"la croix a gagnée cette connasse
\n
"
);
//printf("la croix a gagnée cette connasse\n");
printf
(
"Player one won!
\n
"
);
//print joueur croix a gagné
//fin du jeu
return
CROSS
;
...
...
@@ -156,7 +158,8 @@ int Launch_puissance4(){
//print joueur cercle a gagné
//print_gameCells();
print_game
();
printf
(
"le cercle a gagné cet enorme zgeg
\n
"
);
//printf("le cercle a gagné cet enorme zgeg\n");
printf
(
"Player two won!
\n
"
);
//fin du jeu
return
CIRCLE
;
}
...
...
@@ -167,14 +170,15 @@ int Launch_puissance4(){
//print egalite + la fin de la grille
//print_gameCells();
print_game
();
printf
(
"y a un egalite dans les regles de l'art mash'allah
\n
"
);
//printf("y a un egalite dans les regles de l'art mash'allah\n");
printf
(
"It is a draw.
\n
"
);
//winner = EQUAL;
//fin du jeu
return
EQUAL
;
}
//y a juste pas encore de winner ducoup...
game
.
curr_player
^=
1
;
//switch de joueur
printf
(
"au tour de %d de jouer
\n
"
,
game
.
curr_player
);
//
printf("au tour de %d de jouer\n", game.curr_player);
}
}
return
winner
;
//boucle sa mere... jusqu'à ce que la grille soit pleine, ou que un winner a été détecté
...
...
@@ -262,7 +266,7 @@ symbol_t CheckWin_in_a_direction(int dir[2], struct cell **grid, struct cell cel
}
void
print_game
(){
printf
(
"h:%d, w:%d
\n
"
,
game
.
height
,
game
.
width
);
//
printf("h:%d, w:%d\n", game.height, game.width);
//affiche ┌─┬─┬─┬─┬─┬─┬─┐
for
(
int
i
=
0
;
i
<
(
game
.
width
*
2
)
+
1
;
i
++
){
if
(
i
%
2
){
...
...
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