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
b3b52cb9
Commit
b3b52cb9
authored
1 month ago
by
remi.greub
Browse files
Options
Downloads
Patches
Plain Diff
factorisation de fonction qui detecte une case de libre dans une colonne donnée
parent
20ac8f0c
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/puissance4.c
+19
-5
19 additions, 5 deletions
puissance4_GRB/puissance4.c
puissance4_GRB/puissance4.h
+2
-1
2 additions, 1 deletion
puissance4_GRB/puissance4.h
with
21 additions
and
6 deletions
puissance4_GRB/puissance4.c
+
19
−
5
View file @
b3b52cb9
...
...
@@ -73,14 +73,28 @@ int kill_game(){
}*/
int
put_free_cell
(
int
j_p
,
int
i
,
symbol_t
symbol
){
i
f
(
game
.
cells
[
j_p
][
i
].
symbol
==
EMPTY
){
//put the player's symbol
int
put_free_cell
(
int
j_p
,
symbol_t
symbol
){
i
nt
i
=
0
;
if
((
i
=
is_cell_free
(
j_p
,
0
,
game
.
players
[
game
.
curr_player
].
symbol
))
!=
-
1
){
game
.
cells
[
j_p
][
i
].
symbol
=
symbol
;
}
return
i
;
}
/*
retourne la ligne d'une cellule de libre dans une
colonne donnée
(si il y en a une, retourn -1 si il n'y en a aucune)
*/
int
is_cell_free
(
int
j_p
,
int
i
,
symbol_t
symbol
){
if
(
game
.
cells
[
j_p
][
i
].
symbol
==
EMPTY
){
//retourne la ligne disponible
return
i
;
}
else
{
if
(
i
<
=
game
.
height
){
return
put_free_cell
(
j_p
,
i
+
1
,
symbol
);
if
(
i
<
(
game
.
width
-
1
)
){
return
is_cell_free
(
j_p
,
i
+
1
,
symbol
);
}
else
{
printf
(
"il n'y a plus de case de disponible sur cette colonne
\n
"
);
return
-
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
puissance4_GRB/puissance4.h
+
2
−
1
View file @
b3b52cb9
...
...
@@ -45,7 +45,8 @@ void init_puissance4(int height, int width);
void
cell_destroy
(
struct
cell
**
cells
,
int
height
);
int
kill_game
();
int
put_free_cell
(
int
j_p
,
int
i
,
symbol_t
symbol
);
int
put_free_cell
(
int
j_p
,
symbol_t
symbol
);
int
is_cell_free
(
int
j_p
,
int
i
,
symbol_t
symbol
);
int
Launch_puissance4
();
bool
Is_Grid_full
();
...
...
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