-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyour-code-here.js
33 lines (26 loc) · 966 Bytes
/
your-code-here.js
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
// Welcome to the Minesweeper challenge!
// Uncomment following string if you are running on local server
//serverUrl = 'http://localhost:8154';
// Choose your name
const username = "Anonymous";
// Choose game difficulty: beginner, intermediate, expert
const level = "expert";
// How many moves per second you want to perform?
// (Hint: less values are good for step-to-step debugging, bigger values - for final testing)
// We recommend to start with 1 step per second
const TPS = 1;
function generateRandomCoordinatesAtField(field) {
var maxY = field.length;
var maxX = field[0].length;
return [
~~(Math.random() * maxX),
~~(Math.random() * maxY)
]
}
// This is where your magic happens
function onUpdate(newField) {
// In every game update you need to do a move
// Possible moves: open, mark (place flag), unmark
var coordinates = generateRandomCoordinatesAtField(newField);
return {action: "open", coordinates};
}