MazeGame型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
A MAZE BEING DRAWN, as pure functions: each takes a game and returns a new one (or the same one, when nothing changed), so a page, a server and a test play by the same rules.
A line starts at the start cell and runs through open passages, one cell to the next. A cell the line is on again cuts the line back to it, so drawing back shortens it and a line never crosses itself, and never enters a cell with a stone on it (stones.ts). A key is picked up by passing over it and stays picked up when the line is drawn back. The maze is solved when the line's end is on the goal and every key is picked up; after that the line is fixed until Undo or Restart.
A finger is a stroke: pressMaze begins one (on the start, on the line's end, or on any cell of
the line, which cuts it back there), dragMaze follows it into each cell, liftMaze ends it and
is what Undo undoes. A tap, where the page offers it, is tapMaze.
インポート
import type { MazeGame } from "@johnmorrisdotca/meikyuu";
定義
type MazeGame<M extends MazeCore = Maze> = {
readonly maze: M;
readonly path: readonly number[];
readonly collected: readonly number[];
readonly solved: boolean;
readonly drawing: boolean;
readonly strokes: number;
readonly stones: readonly number[];
readonly rules: StoneRules | null;
readonly undo: readonly {
readonly path: readonly number[];
readonly collected: readonly number[];
readonly solved: boolean;
readonly stones: readonly number[];
}[];
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
maze | M | |
path | readonly number[] | The line, from the start; empty until it is begun. |
collected | readonly number[] | The keys picked up, in the order they were. |
solved | boolean | |
drawing | boolean | Whether a stroke is being drawn. |
strokes | number | How many strokes have been made, to count moves. |
stones | readonly number[] | The cells with a stone on them, in the order they were laid (see stones.ts); always empty in a game with no |
rules | StoneRules | null | What stones may be laid ( |
undo | readonly { readonly path: readonly number[]; readonly collected: readonly number[]; readonly solved: boolean; readonly stones: readonly number[]; }[] | What each finished stroke (or each stone laid or taken up) started from, newest last, for Undo. |
例
import type { MazeGame, MazeRecipe } from "@johnmorrisdotca/meikyuu";
import { buildMaze, newMazeGame } from "@johnmorrisdotca/meikyuu";
const recipe: MazeRecipe = {shape:"square",w:5,h:5,algorithm:"backtracker",mode:"to-goal",seed:42};
const maze = buildMaze(recipe);
const game = newMazeGame(maze);
const value: MazeGame = game;
console.log(value);{
maze: {
recipe: {
shape: 'square',
w: 5,
h: 5,
algorithm: 'backtracker',
mode: 'to-goal',
seed: 42
},
grid: {
shape: 'square',
w: 5,
h: 5,
centres: [Array],
sides: [Array],
box: [Object],
at: [Function: at],
cells: 25,
neighbours: [Array]
},
links: [
[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]
],
start: 6,
goal: 15,
entrance: null,
exit: null,
keys: []
},
path: [],
collected: [],
solved: false,
drawing: false,
strokes: 0,
undo: [],
stones: [],
rules: null
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。