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
6e212a84
Commit
6e212a84
authored
2 weeks ago
by
remi.greub
Browse files
Options
Downloads
Patches
Plain Diff
dernieres corrections sur smartbot
parent
fc0c4e1a
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
puissance4_GRB/puissance4.c
+11
-4
11 additions, 4 deletions
puissance4_GRB/puissance4.c
with
11 additions
and
4 deletions
puissance4_GRB/puissance4.c
+
11
−
4
View file @
6e212a84
...
...
@@ -358,6 +358,7 @@ int Launch_puissance4_smartBot(int seed){
int
SmartBot
(){
int
pos
=
0
;
int
chfr1
=
-
1
,
chfr2
=
-
1
;
for
(
int
chfr
=
0
;
chfr
<
game
.
width
;
chfr
++
){
//verifie que le coup est jouable
if
((
pos
=
put_free_cell
(
chfr
,
game
.
players
[
game
.
curr_player
].
symbol
))
>=
0
){
...
...
@@ -366,20 +367,26 @@ int SmartBot(){
if
(
Find_winner
(
game
.
cells
,
game
.
cells
[
chfr
][
pos
])
==
game
.
players
[
game
.
curr_player
].
symbol
){
//1er cas : a trouvé le bon coup à jouer pour gagner
tempCell
->
symbol
=
EMPTY
;
return
chfr
;
chfr1
=
chfr
;
}
//tente de chercher si l'autre joueur a un coup gagnant
tempCell
->
symbol
=
game
.
players
[
game
.
curr_player
^
1
].
symbol
;
if
(
Find_winner
(
game
.
cells
,
game
.
cells
[
chfr
][
pos
])
==
game
.
players
[
game
.
curr_player
^
1
].
symbol
){
//2e cas : joue le coup gagnant de l'autre joueur pour le bloquer
tempCell
->
symbol
=
EMPTY
;
return
chfr
;
chfr2
=
chfr
;
}
tempCell
->
symbol
=
EMPTY
;
}
}
//3e cas : joue un coup au hasard
return
rand
()
%
game
.
width
;
if
(
chfr1
!=
-
1
){
return
chfr1
;
}
else
if
(
chfr2
!=
-
1
){
return
chfr2
;
}
else
{
//3e cas : joue un coup au hasard
return
rand
()
%
game
.
width
;
}
}
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