-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathminesweeper solver.cpp
95 lines (69 loc) · 1.36 KB
/
minesweeper solver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <iostream>
#include <vector>
using namespace std;
struct Point {
int x = 0;
int y = 0;
}
int SurroundingMines(Point point, vector<Point> m) {
int numOfMines = 0;
Point p = point;
p.x++;
IsMine(p, m) ? numOfMines++ : numOfMines+= 0;
p = point;
p.x--;
IsMine(p, m) ? numOfMines++ : numOfMines+= 0;
p = point;
p.y--;
IsMine(p, m) ? numOfMines++ : numOfMines+= 0;
p = point;
p.y++;
IsMine(p, m) ? numOfMines++ : numOfMines+= 0;
p = point;
p.x--;
p.y--;
IsMine(p, m) ? numOfMines++ : numOfMines+= 0;
p = point;
p.x--;
p.y++;
IsMine(p, m) ? numOfMines++ : numOfMines+= 0;
p = point;
p.x++;
p.y--;
IsMine(p, m) ? numOfMines++ : numOfMines+= 0;
p = point;
p.x++;
p.y++;
IsMine(p, m) ? numOfMines++ : numOfMines+= 0;
return numOfMines;
}
bool IsMine(Point p, vector<Point> m) {
return FindInVector(p, m);
}
bool FindInVector(Point p, vector<Point> v) {
for(int i = 0; i < v.size; i++) {
if (v[i] == p) {
return true;
}
}
return false;
}
void EndGame() {
}
int main() {
vector<Point> mines,
visited;
int mineNum = 0,
squareNum = 0;
Point check;
//ask user for field dimentions
//ask user for mine locations
//Setup Minefield
//Display Minefield
while (visited.size() > squareNum - mineNum) {
//Ask user to check position
if (IsMine(check, mines)) {
EndGame();
}
return 0;
}