Skip to content

Commit 3bb7cff

Browse files
committed
..
1 parent aaf0dd9 commit 3bb7cff

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

packages/demo3/solver/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<script type="module" src="./index.ts"></script>
7+
</head>
8+
</html>

packages/demo3/solver/index.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import init, {
2+
get_grid_sample,
3+
IPoint,
4+
init_log,
5+
init_panic_hook,
6+
solve,
7+
} from "snk-js";
8+
import wasmUrl from "snk-js/snk_js_bg.wasm";
9+
import { createCanvas } from "../utils/canvas";
10+
11+
await init(wasmUrl);
12+
init_panic_hook();
13+
init_log();
14+
15+
const grid = get_grid_sample("cave2");
16+
const { canvas, draw, highlightCell } = createCanvas(grid);
17+
document.body.appendChild(canvas);
18+
19+
const path = solve(grid, [
20+
IPoint.create(0, -1),
21+
IPoint.create(1, -1),
22+
IPoint.create(2, -1),
23+
IPoint.create(3, -1),
24+
]);
25+
26+
draw(
27+
{ width: grid.width, height: grid.height, data: grid.cells },
28+
[] as any,
29+
[],
30+
);
31+
32+
console.log(path);
33+
34+
for (const { x, y } of path) highlightCell(x, y);

0 commit comments

Comments
 (0)