forked from DavidNHill/JSMinesweeper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
292 lines (236 loc) · 13.1 KB
/
index.html
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<!DOCTYPE html>
<html style="width: 100%; height: 100%">
<head>
<meta charset="ISO-8859-1">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="Minesweeper/client/main.css">
<link rel="icon" type="image/png" href="resources/images/flagged.png" />
<title>Minesweeper solver</title>
</head>
<body style="position: absolute; left:0px; right:0px; top:0px; bottom:0px; zoom: 1.0;" onresize="browserResized()">
<!-- Title at the top -->
<h1><label id="title">Minesweeper solver</label><label style="float: right;"><a href="https://github.com/DavidNHill/JSMinesweeper#readme" target="_blank"><i>help</i></a></label></h1>
<!-- control panel on the left -->
<nav id="controls" style="zoom: 0.9; position:relative; left:0px; top:0px">
<div class="checkboxes">
<label><input type="checkbox" class="checkbox" id="analysismode" onclick="setAnalysis()" /> <span>Analysis mode</span></label>
</div>
<div id="play0" style="margin-top: 15px;">
<div class="checkboxes">
<label><input type="checkbox" class="checkbox" id="useSeed" /> <span>Use seed</span></label>
</div>
<div>
<input id="seed" type="text" style="width: 150px" />
</div>
<div class="checkboxes">
<label><input type="checkbox" class="checkbox" id="gameTypeZero" /> <span>Opening on start</span></label>
</div>
<div class="checkboxes">
<label><input type="checkbox" class="checkbox" id="fastPlay" /> <span>Fast mode</span></label>
</div>
<!--
<div style="margin-top: 1em;" class="radioButtons">
<label><input id="gameTypeSafe" type="radio" class="radioButton" name="gameType" value="safe"><span>Safe start</span></label>
<label><input id="gameTypeZero" type="radio" class="radioButton" name="gameType" value="zero" checked><span>Zero start</span></label>
</div>
-->
</div>
<div class="radioButtons" style="margin-top: 15px;">
<label><input id="beginner" type="radio" class="radioButton" name="boardSize" value="0"><span>Beginner</span></label>
<label><input id="intermediate" type="radio" class="radioButton" name="boardSize" value="1"><span>Intermediate</span></label>
<label><input id="expert" type="radio" class="radioButton" name="boardSize" value="2" checked><span>Expert</span></label>
<label style="margin-bottom: 0.5em;"><input id="custom" type="radio" class="radioButton" name="boardSize" value="3"><span>Custom</span></label>
</div>
<div style="margin-top: 10px;">
<div class="block">
<label>Width:</label>
<input id="width" onkeypress="makeCustom()" type="text" />
</div>
<div class="block">
<label>Height:</label>
<input id="height" onkeypress="makeCustom()" type="text" />
</div>
<div class="block">
<label>Mines:</label>
<input id="mines" onkeypress="makeCustom()" type="text" />
</div>
</div>
<div style="margin-top: 1em; display: none;" class="radioButtons" id="analysis0">
<label><input id="buildHidden" type="radio" class="radioButton" name="buildType" value="hidden"><span>Build all hidden</span></label>
<label><input id="buildZero" type="radio" class="radioButton" name="buildType" value="zero" checked><span>Build all zero</span></label>
<button style="margin-top: 1em;" id="localStorageButton" onclick="openLocalStorage()">Local Storage</button>
</div>
<button style="margin-top: 1em;" id="NewGame" onclick="apply()">New game</button>
<button style="margin-top: 0em;" id="repeatGame" onclick="playAgain()">Play again</button>
<div style="margin-top: 10px;">
<label>Style:</label>
<select id="playstyle">
<option value="flag">Flagging</option>
<option value="noflag">No flagging</option>
<option value="eff">Efficiency</option>
</select>
</div>
<div style="margin-top: 10px;">
<label>Tile size:</label>
<select id="tilesize">
<option value="12">12 pixels</option>
<option value="16">16 pixels</option>
<option value="20">20 pixels</option>
<option selected value="24">24 pixels</option>
<option value="28">28 pixels</option>
<option value="32">32 pixels</option>
</select>
</div>
<div style="margin-top: 1em;" class="checkboxes" id="play1">
<label><input type="checkbox" class="checkbox" id="showhints" checked /> <span>Show hints</span></label>
<label><input type="checkbox" class="checkbox" id="autoplay" /> <span>Auto play</span></label>
<label><input type="checkbox" class="checkbox" id="acceptguesses" /> <span>Accept guesses</span></label>
</div>
<div style="margin-top: 1em; display: none;" class="checkboxes" id="analysis1">
<label><input type="checkbox" class="checkbox" id="lockMineCount" /> <span><u>L</u>ock mine count</span></label>
</div>
<button style="margin-top: 1em;" id="AnalysisButton" onclick="doAnalysis()"><u>A</u>nalyse</button>
</nav>
<!-- where the board goes -->
<div style="position: absolute; left: 180px; right: 10px; top: 75px; bottom: 60px;">
<section class="tooltip" id="canvas" style="position: absolute; left: 10px; top: 0px; bottom: 0px; right: 0px;">
<div id="display" ondrop="dropHandler(event)" ondragover="dragOverHandler(event)">
<canvas class="led" id="myMinesLeft" width="96" height="40" oncontextmenu="return false"></canvas>
</div>
<div id="board" style="overflow: auto; position: relative; top:0px; left:0px;">
<canvas id="myCanvas" width="500" height="500" oncontextmenu="return false" style="position: absolute; top: 0px; left: 0px;"></canvas>
<canvas id="myHints" width="500" height="500" oncontextmenu="return false" style="position: absolute; top: 0px; left: 0px; pointer-events: none;"></canvas>
</div>
<span id="tooltip" class="tooltiptext" style="pointer-events: none;">Tooltip text</span>
<!-- A hyperlimnk to download the board -->
<a id="downloadmbf" style="position: relative; left: 3px; top: 5px" onclick="downloadAsMBF()" download="" href="">Download as MBF</a>
</section>
</div>
<!-- message line at the bottom -->
<div class="raised" style="position: absolute; bottom: 0px; left: 0px; right: 0px; margin: 10px;">
<label id="messageLine" style="font-size:20px; padding:5px;">A message line</label>
</div>
<!-- Local storage popup -->
<div id="localStorage" class="modal">
<!-- Modal content -->
<div class="modal-content" style="position: relative; width: 600px; height: 600px">
<p>From here you can store and fetch positions from the browsers local storage. This storage persists between sessions.</p>
<select style="width: 100%" id="localStorageSelection" size="24" onchange="localStorageKey.value = localStorageSelection.value">
</select>
<input id="localStorageKey" type="text" style="width: 98%" />
<button style="position: absolute; bottom: 50px; left: 5px" id="localStorageDelete" onclick="deleteLocalStorage()">Delete</button>
<button style="position: absolute; bottom: 50px; left: 225px" id="localStorageSave" onclick="saveLocalStorage()">Store</button>
<button style="position: absolute; bottom: 50px; Right: 5px" id="localStorageLoad" onclick="loadLocalStorage()">Fetch</button>
<button style="position: absolute; bottom: 5px; right: 5px" id="localStorageCancel" onclick="closeLocalStorage()">Cancel</button>
</div>
</div>
<!-- Properties popup -->
<div id="properties">
<!-- Modal content -->
<div style="position: relative; width: 200px; height: 300px" --->
<div id="propertiesHeader">Properties</div>
<table style="width: 100%" id="propertiesTable" size="24">
</table>
<button style="position: absolute; bottom: 5px; Right: 15px" id="propertiesClose" onclick="propertiesClose()">Close</button>
</div>
</div>
<script src="Minesweeper/client/Board.js" type="text/javascript"></script>
<script src="Minesweeper/client/Tile.js" type="text/javascript"></script>
<script src="Minesweeper/client/solver_main.js" type="text/javascript"></script>
<script src="Minesweeper/client/solver_probability_engine.js" type="text/javascript"></script>
<script src="Minesweeper/client/Brute_force.js" type="text/javascript"></script>
<script src="Minesweeper/client/BruteForceAnalysis.js" type="text/javascript"></script>
<script src="Minesweeper/client/MinesweeperGame.js" type="text/javascript"></script>
<script src="Minesweeper/client/SolutionCounter.js" type="text/javascript"></script>
<script src="Minesweeper/client/EfficiencyHelper.js" type="text/javascript"></script>
<script src="Minesweeper/client/FiftyFiftyHelper.js" type="text/javascript"></script>
<script src="Minesweeper/client/main.js" type="text/javascript"></script>
<script src="Minesweeper/Utility/PrimeSieve.js" type="text/javascript"></script>
<script src="Minesweeper/Utility/Binomial.js" type="text/javascript"></script>
<script type="text/javascript">
function apply() {
if (document.getElementById("beginner").checked) {
doNewGame(9, 9, 10);
return;
}
if (document.getElementById("intermediate").checked) {
doNewGame(16, 16, 40);
return;
}
if (document.getElementById("expert").checked) {
doNewGame(30, 16, 99);
return;
}
const MAX_WIDTH = 200;
const MAX_HEIGHT = 200;
var widthX = document.getElementById("width").value;
var heightX = document.getElementById("height").value;
var minesX = document.getElementById("mines").value;
if (isNaN(widthX)) {
return;
}
if (isNaN(heightX)) {
return;
}
if (isNaN(minesX)) {
return;
}
var width = Number(widthX);
var height = Number(heightX);
var mines = Number(minesX);
if (width < 1) {
document.getElementById("width").value = 1
width = 1;
}
if (width > MAX_WIDTH) {
document.getElementById("width").value = MAX_WIDTH;
width = MAX_WIDTH;
}
if (height < 1) {
document.getElementById("height").value = 1
height = 1;
}
if (height > MAX_HEIGHT) {
document.getElementById("height").value = MAX_HEIGHT;
height = MAX_HEIGHT;
}
if (mines < 1) {
document.getElementById("mines").value = 1;
mines = 1;
}
if (mines > width * height - 1) {
document.getElementById("mines").value = width * height - 1;
mines = width * height - 1;
}
doNewGame(width, height, mines);
}
function doNewGame(width, height, mines) {
if (document.getElementById("useSeed").checked) {
newGame(width, height, mines, document.getElementById("seed").value);
} else {
newGame(width, height, mines, 0);
}
}
function setAnalysis() {
if (document.getElementById("analysismode").checked) {
document.getElementById("play0").style.display = "none";
document.getElementById("play1").style.display = "none";
document.getElementById("analysis0").style.display = "block";
document.getElementById("analysis1").style.display = "block";
document.getElementById("repeatGame").style.display = "none";
document.getElementById("NewGame").innerHTML = "Reset board";
} else {
document.getElementById("play0").style.display = "block";
document.getElementById("play1").style.display = "block";
document.getElementById("analysis0").style.display = "none";
document.getElementById("analysis1").style.display = "none";
document.getElementById("repeatGame").style.display = "block";
document.getElementById("NewGame").innerHTML = "New game";
}
}
function makeCustom() {
document.getElementById("custom").checked = true;
}
</script>
</body>
</html>