|
1 | 1 | import { Grid } from "./objects/grid.ts"; |
2 | 2 | import { FinderEnum } from "./finders/finder.enum.ts"; |
3 | | -import { drawLayout } from "./utils/grid.utils.ts"; |
| 3 | +import { drawLayout, transpose } from "./utils/grid.utils.ts"; |
4 | 4 |
|
5 | | -const layout = [ |
6 | | - [1, 1, 1, 1, null], |
7 | | - [1, null, null, 1, 1, 1, 1], |
8 | | - [1, null, 1, 1, 1], |
9 | | - [1, null, 1, 1, 1, 1, 1, 1], |
10 | | - [1, null, 1, 1, 1, 1, 1, 1], |
11 | | -] as number[][]; |
| 5 | +const original = [ |
| 6 | + [0, 0, 0, 2, 0, 0, 0, 0, 0], |
| 7 | + [0, 0, 1, 1, 1, 1, 0, 1, 1], |
| 8 | + [0, 1, 1, 1, 1, 1, 1, 1, 1], |
| 9 | + [0, 1, 1, 1, 1, 1, 1, 1, 1], |
| 10 | + [2, 1, 1, 1, 1, 1], |
| 11 | + [0, 1, 1, 1, 1, 1, 1, 1, 1, 1], |
| 12 | + [0, 1, 1, 1, 1, 1, 1, 0, 1, 1], |
| 13 | +]; |
| 14 | + |
| 15 | +const layout = transpose(original); // (original); |
12 | 16 |
|
13 | 17 | const grid = new Grid(layout); |
14 | | -const start = { x: 6, y: 3 }; |
15 | | -const end = { x: 6, y: 1 }; |
| 18 | +const start = { x: 2, y: 6 }; |
| 19 | +const end = { x: 5, y: 9 }; |
16 | 20 |
|
17 | 21 | console.log(start, "->", end); |
18 | 22 | const path = grid.findPath(start, end, 1, FinderEnum.JUMP_POINT); |
19 | 23 | console.log(path); |
20 | 24 |
|
21 | | -drawLayout(layout, path); |
| 25 | +drawLayout(layout, path, start, end); |
0 commit comments