Maze型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
A seeded flat maze with its cell graph, passages, doors, endpoints and optional keys.
インポート
import type { Maze } from "@johnmorrisdotca/meikyuu";
定義
type Maze = {
readonly recipe: MazeRecipe;
readonly grid: Grid;
readonly links: Links;
readonly start: number;
readonly goal: number;
readonly entrance: Door | null;
readonly exit: Door | null;
readonly keys: readonly number[];
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
recipe | MazeRecipe | |
grid | Grid | |
links | Links | Each cell's open neighbours. |
start | number | The cell the line starts in. |
goal | number | The cell the line must reach. |
entrance | Door | null | The door the line comes in by, for |
exit | Door | null | The door the line goes out by, for |
keys | readonly number[] | The keys to collect, for |
例
import type { Maze, MazeRecipe } from "@johnmorrisdotca/meikyuu";
import { buildMaze } from "@johnmorrisdotca/meikyuu";
const recipe: MazeRecipe = {shape:"square",w:5,h:5,algorithm:"backtracker",mode:"to-goal",seed:42};
const maze = buildMaze(recipe);
const value: Maze = maze;
console.log(value);{
recipe: {
shape: 'square',
w: 5,
h: 5,
algorithm: 'backtracker',
mode: 'to-goal',
seed: 42
},
grid: {
shape: 'square',
w: 5,
h: 5,
centres: [
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array]
],
sides: [
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array]
],
box: { x: 0, y: 0, w: 5, h: 5 },
at: [Function: at],
cells: 25,
neighbours: [
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array], [Array], [Array],
[Array]
]
},
links: [
[ 1, 5 ], [ 2, 0 ],
[ 7, 3, 1 ], [ 2, 4 ],
[ 3 ], [ 0, 6 ],
[ 5, 11 ], [ 8, 2 ],
[ 9, 7 ], [ 14, 8 ],
[ 11 ], [ 6, 12, 10 ],
[ 11, 17, 13 ], [ 12 ],
[ 19, 9 ], [ 16 ],
[ 15, 21 ], [ 12 ],
[ 23, 19 ], [ 18, 24, 14 ],
[ 21 ], [ 16, 20, 22 ],
[ 21, 23 ], [ 22, 18 ],
[ 19 ]
],
start: 6,
goal: 15,
entrance: null,
exit: null,
keys: []
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。