-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathexample.html
More file actions
35 lines (33 loc) · 976 Bytes
/
example.html
File metadata and controls
35 lines (33 loc) · 976 Bytes
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
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
</head>
<body>
See console logs.
<script type="module">
// This is an example file for how to use the nokamute.js interface.
import init, { uhp } from './pkg/nokamute.js';
async function run() {
// Wait for wasm library to load and initialize.
await init();
// The only exported function is `uhp`.
// It accepts a single UHP command,
// and returns the output string.
console.log(uhp("info"));
let game_state = uhp("newgame Base+MLP");
console.log(uhp("validmoves"));
while (true) {
let start = performance.now();
let move = uhp("bestmove depth 4");
console.log(move + " - " + (performance.now()-start) + "ms");
game_state = uhp("play " + move);
if (!game_state.includes("InProgress")) {
break;
}
}
console.log(game_state);
}
run();
</script>
</body>
</html>