Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MLOD_ProjectC
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Erwan MERLY
MLOD_ProjectC
Commits
3d9ce1c2
Commit
3d9ce1c2
authored
Oct 31, 2020
by
Erwan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix de la generation des mines (on obtient bien le nombre d'entrée)
parent
7a8c3fc0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
minesweeper.c
minesweeper.c
+12
-7
No files found.
minesweeper.c
View file @
3d9ce1c2
...
...
@@ -111,15 +111,20 @@ bool revelerCase(CelluleDemineur** matriceMines, int line, int column, int nbLig
}
void
generationMines
(
int
nbMines
,
int
nbLigneMatrice
,
int
nbColonneMatrice
,
CelluleDemineur
**
matriceMines
){
int
lineRand
=
rand
()
%
nbLigneMatrice
;
int
colRand
=
rand
()
%
nbColonneMatrice
;
for
(
int
i
=
0
;
i
<
nbMines
;
i
++
){
int
lineRand
=
rand
()
%
nbLigneMatrice
;
int
colRand
=
rand
()
%
nbColonneMatrice
;
while
(
!
containsMine
(
lineRand
,
colRand
,
matriceMines
)){
matriceMines
[
lineRand
][
colRand
]
->
hasMine
=
true
;
matriceMines
[
lineRand
][
colRand
]
->
nearbyMine
=
-
9
;
incrementationVoisinMine
(
lineRand
,
colRand
,
matriceMines
,
nbLigneMatrice
,
nbColonneMatrice
);
while
(
containsMine
(
lineRand
,
colRand
,
matriceMines
)){
lineRand
=
rand
()
%
nbLigneMatrice
;
colRand
=
rand
()
%
nbColonneMatrice
;
}
matriceMines
[
lineRand
][
colRand
]
->
hasMine
=
true
;
matriceMines
[
lineRand
][
colRand
]
->
nearbyMine
=
-
9
;
incrementationVoisinMine
(
lineRand
,
colRand
,
matriceMines
,
nbLigneMatrice
,
nbColonneMatrice
);
}
}
...
...
@@ -164,7 +169,7 @@ int main(void)
srand
(
time
(
NULL
));
int
nbLigneMatrice
=
1
0
,
nbColonneMatrice
=
10
,
nbMines
=
80
;
int
nbLigneMatrice
=
1
7
,
nbColonneMatrice
=
21
,
nbMines
=
80
;
int
curCaseX
=
0
,
curCaseY
=
0
,
flaggedMines
=
0
;
bool
lose
=
false
,
win
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment